scelis / twine

Twine is a command line tool for managing your strings and their translations.
Other
840 stars 151 forks source link

use developer-language option for apple Base folder #219

Closed philippeauriach closed 7 years ago

philippeauriach commented 7 years ago

Today when we use the consume-all-localization-files command, Base folder is ignored. It should not be ignored when we specify a developer-language (Base.lproj is the fallback language, in the language set as the "developer language" in Xcode).

sebastianludwig commented 7 years ago

Hey @philippeauriach, thanks for reporting this issue and implementing a fix 👍

However I'm still not sure I understand the issue. Can you provide a more detailed example of the scenario that's going wrong and what your expected result is so we can implement a unit test? That'd be great!

Thanks again!

P.S. be sure to participate in the Hacktoberfest for all your contributions! :-)

philippeauriach commented 7 years ago

Sure :

What I want to achieve : initialize a twine.txt file using an existing Xcode project. Actual configuration : an Xcode project with two localized files :

PROJECT/_localizations/Base.lproj/Localizations.strings
PROJECT/_localizations/fr.lproj/Localizations.strings

The Base.lproj folder contains english (it is the Base folder as it is the fallback language for non translated locales, eg in my case, deutch phones will see the app in english)

Command executed :

touch twine.txt
twine consume-all-localization-files twine.txt PROJECT/_localizations --developer-language en --consume-all

The output is, for each key :

Adding new definition 'ADDCATCH_TITLE' to twine file.
Warning: ADDCATCH_TITLE does not exist in developer language 'en'

And the resulting twine.txt file does not contains english translations (Base.lproj folder is totally ignored) :

[[Uncategorized]]
    [ADDCATCH_TITLE]
        fr = Nouvelle Prise
    [ADDCATCH_SECTION_PICTURES_BUTTON]

Expected result :

[[Uncategorized]]
    [ADDCATCH_TITLE]
        en = New Catch
        fr = Nouvelle Prise

With my commit it is working, as it takes the "developer-language" option as the default value in case of Base.lproj, therefore using the "fallback language" on Apple Side as the "developer-language" on twine side.

As I'm writing this I realize it may not be straightforward for users, especially when developer-language option is used across twine for non apple specific code. Maybe we should add another option, called something like apple-base-language ? Let me know how you see things.

philippeauriach commented 7 years ago

I added a unit test, but I did not find any way of injecting the developer_language options only for this particular test, I had to add it for the entire test file (all of the tests now receive developer_language). Other tests did not break, but I'm not sure of this solution. Tell me what you think !

scelis commented 7 years ago

Awesome! Thanks. This LGTM