Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

iOS Workflow #61

Closed
williamsjj opened this Issue Jun 24, 2014 · 10 comments

Comments

2 participants

I'm a little fuzzy on the iOS workflow. I understand twine can import existing .strings files into its master file, and can also export its master file back out to .strings files.

However, does that mean from now on, we just add translations to the master file? Do we still use NSLocalizedString and if so what is the key we use in NSLocalizedString? The twine translation key? Or the English translation?

Owner

scelis commented Jun 26, 2014

@williamsjj I would recommend editing the master file directly as much as possible. The importing (from .strings files and other formats) is designed for the initial import or for incorporating changes made by translators.

And yes, you continue to use NSLocalizedString with the twine string keys.

Hmm. That's too bad. It would be nice if Twine could do NSLocalizedString extraction and update the master file. I'm used to being able to do a very similar thing in Python using _() to wrap the text.

Owner

scelis commented Jun 26, 2014

I'm not sure I follow. You mean a genstrings kind of thing for generating twine string files instead of .strings files? You could do that pretty easily with a shell script that first uses genstrings and then imports those strings into your twine strings file using twine.

Basically. What is Twine's rule for merging an already existing entry? Keep the existing master value?

Owner

scelis commented Jun 26, 2014

Given you are importing file foo.strings into twine file strings.txt, the translations in foo.strings will overwrite ones that already exist in strings.txt.

So if you use genstrings to update the English and pull out new phrases and then import it, an existing pair like "TRANSLATION_KEY_FOR_DONE_BUTTON=TRANSLATION_KEY_FOR_DONE_BUTTON", would overwrite the English of TRANSLATION_KEY_FOR_DONE_BUTTON in the master file?

Owner

scelis commented Jun 26, 2014

Hmmm, thinking about it some more, I don't think this will really work all that well. I believe genstrings assumes that the english string is the string key. I have always found this to be a bad idea (see this blog post). I also don't think the definitions of strings really belong scattered around various source code files.

All that said, twine was really designed as a way to store and manage all of your string files in an easy-to-parse format. It was designed this way to allow people to create their own workflows around the tool using twine for importing and exporting of these string keys and their translations. The format and code is also simple enough that it would be fairly easy for people to create custom ways of working with their twine string file.

But it does sound to me like you are still thinking about the strings as being defined in your source code, which isn't really the way twine was designed.

I'm thinking of using NSLocalizedString(@"MY_NEW_KEY", @"Explanation of what it means."), and then auto-updating the Master file by finding the NSLocalizedString instances and adding "MY_NEW_KEY" if it isn't in the Master file yet. That way programmers can simply define a new key in their code as they go.

Owner

scelis commented Jun 26, 2014

I see a key there and a comment but no translation of the key. Where would that come from? I guess you could write a script that looks for NSLocalizedStringWithDefaultValue and parses out the default value as the english translation.

Translation would have to be manually added. Or the comment could be used as the English translation.

@scelis scelis closed this Jul 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment