Minor TranslationFileWriter maintenance (#11858)

* Replace confusing `[Food] Focus` template with prettier `[stat] Focus`

* Minor lint
This commit is contained in:
SomeTroglodyte
2024-06-29 22:57:42 +02:00
committed by GitHub
parent 4bb9d3bbc9
commit 3a16fcb021
2 changed files with 13 additions and 8 deletions

View File

@ -127,21 +127,16 @@ object TranslationFileWriter {
linesToTranslate += "$uniqueTarget = "
linesToTranslate += "\n\n#################### Lines from spy actions #######################\n"
for (spyAction in SpyAction.values()) {
for (spyAction in SpyAction.values())
linesToTranslate += "${spyAction.displayString} = "
}
linesToTranslate += "\n\n#################### Lines from diplomatic modifiers #######################\n"
for (diplomaticModifier in DiplomaticModifiers.values())
linesToTranslate += "${diplomaticModifier.text} = "
linesToTranslate += "\n\n#################### Lines from key bindings #######################\n"
for (category in KeyboardBinding.Category.values()) {
linesToTranslate += "${category.label} = "
}
for (binding in KeyboardBinding.values()) {
linesToTranslate += "${binding.label} = "
}
for (bindingLabel in KeyboardBinding.getTranslationEntries())
linesToTranslate += "$bindingLabel = "
for (baseRuleset in BaseRuleset.values()) {
val generatedStringsFromBaseRuleset =

View File

@ -13,6 +13,8 @@ private fun unCamelCase(name: String) = unCamelCaseRegex.replace(name, """$1$4 $
*
* Note a label is automatically generated from the name by inserting spaces before each uppercase letter (except the initial one),
* and translation keys are automatically generated for all labels. This also works for [KeyboardBinding.Category].
*
* [label] entries containing a placeholder need special treatment - see [getTranslationEntries] and update it when adding more.
*/
enum class KeyboardBinding(
val category: Category,
@ -259,6 +261,14 @@ enum class KeyboardBinding(
constructor(category: Category, key: Int) : this(category, KeyCharAndCode(key))
//endregion
companion object {
fun getTranslationEntries() = (
Category.values().asSequence().map { it.label }
+ values().asSequence().map { it.label }.filterNot { it.contains('[') }
+ sequenceOf("[stat] Focus")
)
}
/** Debug helper */
override fun toString() = "$category.$name($defaultKey)"
}