This commit is contained in:
Yair Morgenstern
2021-06-30 21:02:57 +03:00
4 changed files with 16 additions and 10 deletions

View File

@ -1348,7 +1348,8 @@
"cost": 425,
"requiredTech": "Nuclear Fusion",
"requiredResource": "Uranium",
"uniques": ["Can move after attacking", "No defensive terrain bonus"]
"uniques": ["Can move after attacking", "No defensive terrain bonus"],
"attackSound": "gdrAttack"
},
{
"name": "Stealth Bomber",

Binary file not shown.

View File

@ -215,7 +215,7 @@ fun String.tr(): String {
}
// There might still be optimization potential here!
if (contains("[")) { // Placeholders!
if (contains('[')) { // Placeholders!
/**
* I'm SURE there's an easier way to do this but I can't think of it =\
* So what's all this then?
@ -231,31 +231,36 @@ fun String.tr(): String {
// Convert "work on [building] has completed in [city]" to "work on [] has completed in []"
val translationStringWithSquareBracketsOnly = this.getPlaceholderText()
val language = UncivGame.Current.settings.language
// That is now the key into the translation HashMap!
val translationEntry = UncivGame.Current.translations
.get(translationStringWithSquareBracketsOnly, UncivGame.Current.settings.language, activeMods)
.get(translationStringWithSquareBracketsOnly, language, activeMods)
if (translationEntry == null ||
!translationEntry.containsKey(UncivGame.Current.settings.language)) {
var languageSpecificPlaceholder: String
val originalEntry: String
if (translationEntry == null || !translationEntry.containsKey(language)) {
// Translation placeholder doesn't exist for this language, default to English
return this.replace(eitherSquareBraceRegex, "")
languageSpecificPlaceholder = this
originalEntry = this
} else {
languageSpecificPlaceholder = translationEntry[language]!!
originalEntry = translationEntry.entry
}
// Take the terms in the message, WITHOUT square brackets
val termsInMessage = this.getPlaceholderParameters()
// Take the term from the placeholder, INCLUDING the square brackets
val termsInTranslationPlaceholder = squareBraceRegex.findAll(translationEntry.entry).map { it.value }.toList()
val termsInTranslationPlaceholder = squareBraceRegex.findAll(originalEntry).map { it.value }.toList()
if (termsInMessage.size != termsInTranslationPlaceholder.size)
throw Exception("Message $this has a different number of terms than the placeholder $translationEntry!")
var languageSpecificPlaceholder = translationEntry[UncivGame.Current.settings.language]!!
for (i in termsInMessage.indices) {
languageSpecificPlaceholder = languageSpecificPlaceholder.replace(termsInTranslationPlaceholder[i], termsInMessage[i].tr())
}
return languageSpecificPlaceholder // every component is already translated
}
if (contains("{")) { // sentence
if (contains('{')) { // sentence
return curlyBraceRegex.replace(this) { it.groups[1]!!.value.tr() }
}

View File

@ -606,7 +606,7 @@ Sounds are from FreeSound.org and are either Creative Commons or Public Domain
* [Tornado-Siren-II](https://soundbible.com/1937-Tornado-Siren-II.html) by Delilah as part of 'nuke' sound (CC Attribution 3.0 license)
* [Explosion-Ultra-Bass](https://soundbible.com/1807-Explosion-Ultra-Bass.html) by Mark DiAngelo as part of 'nuke' sound (CC Attribution 3.0 license)
* [Short Choir](https://freesound.org/people/Breviceps/sounds/444491/) by Breviceps as 'choir' for free great person pick
* [Death Robot! Robotic scream](https://freesound.org/people/vultraz168/sounds/334660/) by vultraz168 for Giant Death Robot Attack (CC0 1.0 Universal license)
# Music
The following music is from https://filmmusic.io