BartyCrouch icon indicating copy to clipboard operation
BartyCrouch copied to clipboard

Possible to use default translation for new strings entries?

Open mlostekk opened this issue 4 years ago • 1 comments

I am using the "transform" with this setup

[update]
tasks = ["transform", "normalize"]

[update.interfaces]
path = "Wynton/"
defaultToBase = true
ignoreEmptyStrings = true
unstripped = false

[update.code]
codePath = "Wynton/"
localizablePath = "."
defaultToKeys = true
additive = false
unstripped = false

[update.transform]
codePath = "Wynton/"
localizablePath = "Wynton/Localization"
transformer = "swiftgenStructured"
supportedLanguageEnumPath = "Wynton/Localization"
typeName = "BartyCrouch"
translateMethodName = "translate"

[update.normalize]
path = "Wynton/Localization"
sourceLocale = "en"
harmonizeWithSource = true
sortByKeys = false

[lint]
path = "Wynton/Localization"
duplicateKeys = true
emptyValues = true

Now when i create new localized text like this

        textView.text = BartyCrouch.translate(key: "something went wront",
                                              translations: [.english: "Something went wrong"],
                                              comment: "Something went wrong message bla bla")

Then this value only shows up in the english translation. But is it possible to make a default text to all other languages or to use the base langauge (like en here) for all languages.

For QA its a bit strange if the text is empty and not something obviously wrong. Because if they test the app, then they just dont see a label e.g. and think the screen is fine. But if there would be a default string like <untranslated> or just the english translation (e.g. in an chinese app) then they would instantly see that something is buggy/not yet translated.

Is there a way to set a default string when generating a new entry in the strings files?

mlostekk avatar Jan 13 '20 14:01 mlostekk

@mlostekk Thank you for reporting this. I think, there is no such feature at the moment. Please note though that adding the English text to other languages is dangerous for several reasons. But changing the empty string to a different string if there's no translation provided to make the text show up in translation actually makes sense. Such an option could be added. I won't have the time to work on this for quite a while though, but I would love to review a PR if you would like to add such a feature yourself.

Please note though that there's a lint task which can check for empty values and that you could run the bartycrouch lint command on your CI to make sure that there are never any empty strings in your project. This is what the lint command was created for. :)

Jeehut avatar Jan 27 '20 10:01 Jeehut