0

I am facing a problem with some strings in Localizable.strings.

I created the files for the base language and the translations, I added the first keys and it worked like a charm. Later though, I made some additions in the code and I added some new keys with their respective translations. However when running the app on the simulator, instead of the text, only the keys appeared, no translation there (only for the new keys that I added, the old ones worked just fine).

I cleaned the project, I uninstalled the app, I reset the simulator: nothing worked.

At some point I moved the added keys at the top of the Localizable.strings file and it worked.

Has anybody else faced the same issue? Is there something I could do besides moving the new keys at the top in order to work?

6
  • 1
    You should be using genstrings to generate the main Localizable.strings file from your source code. This file should not be hand edited. That gives you the base localization. That generated one should then be used as the basis for the translated versions.
    – rmaddy
    May 20, 2016 at 18:31
  • @rmaddy what if I add new strings later on? If I run again the genstrings command will it add them again, wipe the old ones or just add the new ones? May 20, 2016 at 19:50
  • 1
    Every time you run genstrings, your main Localizable.strings file will be recreated. This is what you want. It removes outdated keys, adds new ones, and updates changed ones so it fully matches your code.
    – rmaddy
    May 20, 2016 at 19:52
  • @rmaddy So the old translations are not lost, right? May 20, 2016 at 19:52
  • 1
    No. It only updates the base strings file. Of course it shouldn't be a big deal if the other ones were to be deleted because you have them all checked into your source code control system as well as having a full backup of your computer (Time Machine or similar), right? So getting back a file that was deleted or changed by mistake is trivial.
    – rmaddy
    May 20, 2016 at 19:55

1 Answer 1

0

I had exactly the same issue with an Arabic .strings file, was driving me crazy because checking the structure using plutil -lint Localizable.strings was succeeding.

Then I discovered after trial and error there was a line with a weird invisible character that apparently was causing the following lines to be ignored.

After I removed that hidden character, worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.