mobiata/twine — pull request #1 by keverets (2012-02-09 12:13:43+00:00)
Title: Fixes for issues encountered when creating initial strings.txt

I have a project that has several existing strings.xml files, and I was trying to move those into a strings.txt so I can use twine from then on. Perhaps this is the wrong way, but I was trying to do:

twine consume-string-file strings.txt --lang en /src/project/res/values/strings.xml

This would not change the strings.txt file and just mark each entry as "not found in the strings data file." So the first commit still adds them, but puts them in the "Uncategorized" section.

Next, I tried adding another language with:

twine consume-string-file strings.txt --lang de /src/project/res/values-de/strings.xml

And this would fail to add the new language since it didn't already exist in the strings.txt file. So, now it adds the language_code to the list if it doesn't already exist.

Then there was the issue of having a translation in a non-developer language only. This comes up because the server gives back a static english text (the developer language in this case), so we don't have an english translation but there is a german and a dutch translation. One commit is to warn about this situation, but still insert it.

Finally, there's the issue where the strings.xml file has a multi-line translation (with built-in '\n') where, after importing, twine couldn't parse the file. This might be the wrong fix, since I should have made the parser more robust, but I thought that it should also be more strict in what it writes and since I was in the android parsing code anyway I stripped away the incoming newlines which were only there for human consumption in the source .xml file.