4
votes

Here's our localization workflow:

  1. Build stuff in interface builder
  2. Export project for localization
  3. Translator looks at xliff files and applies translations for new strings (Only new untranslated strings)
  4. Import xliff into project

This works fine for building new stuff. But if the developer changes the text in a label in storyboard that has already been translated, he will have to remember to delete the translation for that label, so the translater sees that string as untranslated. If the developer forgets to delete that translation, the translation will be wrong, which is a very hard error to find.

When code is localized like this:

var testString = NSLocalizedString("Some text in english", comment: "just a test string")

The string ("Some text in english") defines the key in the xliff-file, which means that if the string is changed, then the exported xliff file will automatically have a new string that needs to be translated.

I've tried to solve the problem with xcode's "export for localization..." function, with genstrings, and with BartyCrounch, but all methods seems to use the UI Element's Object ID as a key for the .strings-files. Which means it won't react to changes in the actual string.

The only solution I've found so far, is to set every string that need translation in the storyboards in code via a IBOutlet, but this is a quite comprehensive solution.

Do you know any tools or methods that solve this problem?

1

1 Answers

1
votes

I tried what you said and understood what you meant. I think the solution is straightforward.

First, I added a new button in storyboard, named it "Test". Then I translated it in Chinese, imported the translation. Changed "Test" to "GoGo" and exported the translation again. The xliff part was changed from

<trans-unit id="jso-qF-Z1t.title">
        <source>Test</source>
        <target>测试</target>
        <note>Class = "NSButtonCell"; title = "Test"; ObjectID = "jso-qF-Z1t";</note>
</trans-unit>

to

<trans-unit id="jso-qF-Z1t.title">
        <source>GoGo</source>
        <target>测试</target>
        <note>Class = "NSButtonCell"; title = "GoGo"; ObjectID = "jso-qF-Z1t";</note>
</trans-unit>

What to do next

I don't know if there is a ready-tool for this. But you can use Git as it can always find the diffs.

Steps:

  1. add you translation folder to git
  2. commit current files
  3. export new translations from Xcode
  4. look at diffs with git

As you can see in the picture, git already shows what changes, that is where you should translate again.

git with translations