Xcode Localization Update
Asked Answered
I

7

7

So I have localized a storyboard in Xcode using Use Base Internationalization.

I went in and translated all the strings in the strings files. Yay. That took forever.

Now I added a new element in the base file of my storyboard. It has a label in it, with a string that I need to internationalize. I saved it, built it, etc. But that new element is nowhere to be found in my pretty strings files.

Please do not tell me that I now have to manually add ALL of my elements?

Ignescent answered 13/12, 2012 at 22:50 Comment(0)
H
0

The Xcode release notes says:

To resynchronize your strings files with new content from your user interface documents, use the --generate-stings-file option of the ibtool command to produce new strings files. Then, manually merge the new files into your existing localized strings.

That's pretty lame, but there you go. You could use something like FileMerge to help you sort out the differences. (We have a set of scripts that read in the strings files and merges them that way; it's not too hard to write such a thing.)

Hearten answered 13/12, 2012 at 23:25 Comment(1)
That is about as lame as it gets. Time for some serious custom software......give me a few days - this cannot be that hard to do elegantly.Ignescent
T
2

Manually find the object ID in IB's inspector(under the class section). Manually write those new element yourself.

Telles answered 19/8, 2013 at 16:18 Comment(1)
more clever one, create new localised language that not necessary for your project then copy the new element to paste in your old languages file, after that, delete it.Telles
R
2

I solved this problem like this.

  1. Uncheck one by one the checkboxes of your Localization utilities panel.

  2. Xcode will ask, Do you want to remove the English (language) localization for Main.storyboard?

  3. there is another checkbox in the dialog, don't check it

  4. click remove.

  5. Again select your story board, and recheck each language

  6. Xcode will say File already exist

  7. Selecte Replace file

  8. Xcode automatically regenerate the strings files from your updated UI and replace your file.

good luck.

Rolf answered 6/9, 2014 at 16:19 Comment(0)
T
1

I've found that it's easier to keep track of all the strings in a separate spreadsheet, and then automagically generate the .strings files for each language from there.

You still have to keep track of the translation keys in 2 places (in xcode and in the spreadsheet), but then at least you don't have to edit or merge all your Localizable.strings files each time you want to add some strings.

See example Excel spreadsheet with VBA macro here: http://members.home.nl/bas.de.reuver/files/multilanguage.zip

Timid answered 14/12, 2012 at 0:29 Comment(1)
Yes, agreed. This is part of what we do as well.Hearten
F
1

While waiting for Xcode 6 and his new localization features (that I hope will tackle this l10n update pain in the ass), we could theoretically automate these steps (never tried)

This gist script (not easy to pronounce:) seems usefull too (again not tested yet)

Furr answered 10/7, 2014 at 17:9 Comment(0)
H
0

The Xcode release notes says:

To resynchronize your strings files with new content from your user interface documents, use the --generate-stings-file option of the ibtool command to produce new strings files. Then, manually merge the new files into your existing localized strings.

That's pretty lame, but there you go. You could use something like FileMerge to help you sort out the differences. (We have a set of scripts that read in the strings files and merges them that way; it's not too hard to write such a thing.)

Hearten answered 13/12, 2012 at 23:25 Comment(1)
That is about as lame as it gets. Time for some serious custom software......give me a few days - this cannot be that hard to do elegantly.Ignescent
T
0

I found another lame solution, but it is less lame than the one found in Xcode release notes; tick the Localization languages off, delete the file from disk and now tick on again. This will recreate the .strings files.

Traditional answered 3/6, 2013 at 16:2 Comment(2)
I do this too. Note though, that this still requires the developer to manually merge the previous file and the current file.Domitian
Yes, but this can easily be done with merge software and Git revision. Still lame.Phototonus
B
0

You might also consider to keep your translations in one clean XML file and make this Maven Plugin generate your strings files during each build: https://github.com/hoereth/i18n-maven-plugin

Brewis answered 6/11, 2018 at 9:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.