FlineDev / BartyCrouch

Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.
MIT License
1.36k stars 121 forks source link

Existing localizations in Storyboard overwritten #140

Closed AndreasVerhoeven closed 4 years ago

AndreasVerhoeven commented 5 years ago

I'm trying to enable BartyCrouch for an existing project that has localized Storyboard files. When running the update interface command with the default configuration, all our existing localized strings are updated with the non localized version.

Do I misunderstand what is meant with "incremental" updates or is there something else going wrong?

Jeehut commented 5 years ago

With the default configuration, all keys that already have a localized value should not be "made empty", instead the translation should be kept. But if you also use the normalize task, then your keys will be sorted. Also, any keys that don't exist in your base language file will be removed from the translated languages, but this doesn't seem to be your issue at all.

Could you please send over your .bartycrouch.toml configuration file and an excerpt of your Localizable.strings file as well as its location within your project? Maybe this will clarify things.

Also which version of command line tools (swift -version) and BartyCrouch are you using?

AndreasVerhoeven commented 5 years ago

Thanks for replying!

.bartycrouch.toml:

[update]
tasks = ["interfaces"]

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

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

[update.transform]
codePath = "."
localizablePath = "."
transformer = "foundation"
supportedLanguageEnumPath = "."
typeName = "BartyCrouch"
translateMethodName = "translate"

[update.normalize]
path = "."
sourceLocale = "en"
harmonizeWithSource = true
sortByKeys = true

[lint]
path = "."
duplicateKeys = true
emptyValues = true

Main.string (localizable strings of Main.storyboard) excerpt:

/* Class = "UITableViewController"; title = "Logs"; ObjectID = "op1-yw-FjI"; */
"op1-yw-FjI.title" = "Logs";

/* Class = "UINavigationItem"; title = "Add Log"; ObjectID = "qex-Fy-jE2"; */
"qex-Fy-jE2.title" = "Voeg log toe";

/* Class = "UILabel"; text = "Title"; ObjectID = "r5v-m6-fj7"; */
"r5v-m6-fj7.text" = "Titel";

/* Class = "UITextField"; placeholder = "Password"; ObjectID = "rZf-GN-agX"; */
"rZf-GN-agX.placeholder" = "Wachtwoord";

/* Class = "UIBarButtonItem"; title = "Item"; ObjectID = "s7H-vZ-ZMg"; */
"s7H-vZ-ZMg.title" = "Item";

If I run bartycrouch, all those localized keys will be reverted to their Base language counterparts.

Location: Project\nl.lproj\Main.strings

BartyCrouch version: Version: 4.0.0 swift version: Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)

Jeehut commented 5 years ago

Okay, a few general things that I want to mention:

But other than that everything looks correct. Are you sure that the keys when BartyCrouch overwrites the file are exactly the same? I'm not sure why this is happening, it shouldn't ...

Could you please also add the build script you are executing? Where does your .bartycrouch.yml file lie? Does it lie in the same folder as the Xcode project? Other than that, I'm not sure why this is happening. A Demo project where you can replicate this issue would be very helpful to fix this.

aahung commented 5 years ago

I also have the same issue, when the comment is translated. If the comment is not translated, the translation is maintained.

https://github.com/aahung/Unshaky

image

Edit: my configuration is below

[update]
tasks = ["interfaces"]

[update.interfaces]
path = "."
defaultToBase = true
ignoreEmptyStrings = true
unstripped = false
Jeehut commented 5 years ago

@aahung Thank you for reporting the issue. I just checked out Unshaky, configured BartyCrouch there and can confirm the issue. Will write tests to replicate this within BartyCrouch once I have a little more time and fix it. Could take a week or so though, stay tuned.

aahung commented 5 years ago

Great. It does not block my overflow, take ur time. Thanks for making this. It is a great tool, saving a lot time!

AndreasVerhoeven commented 5 years ago

Translated comments indeed seem to trigger it!

Jeehut commented 4 years ago

I'm putting this on my TODO list now, will report the progress within the next weeks.

Jeehut commented 4 years ago

This was fixed via #182 and released in 4.2.0 and should be available via Homebrew soon. 🎉