etnt / gettext

Erlang internationalization library.
http://www.redhoterlang.com/
MIT License
70 stars 45 forks source link

Reload default language,etc. #7

Closed bipthelin closed 12 years ago

bipthelin commented 12 years ago

Hi,

This is more of a question than a issue but given:

?TXT2("Foo", LC) where the key "Foo" exists in default/en shouldn't ?TXT2("Foo", "blah") print the value from default/en? instead of "Foo". If the key doesn't exist in default/en I understand why "Foo" is being printed. Yes, gettext:default_lang() prints "en".

Also, is there a way to reload the default language. Looking through the code it looks like it's only possible to reload a custom language.

Given the above I fail to see the purpose of the default lang vs. having it as a custom lang.

Please, help me grok this.

jordi-chacon commented 12 years ago

Hi Bip,

I don't know the question to your answer unfortunately. The main Gettext developer is Tobbe Tornkvist. He should be able to solve your question :)

Best regards, Jordi

On 7 December 2011 15:30, Bip Thelin < reply@reply.github.com

wrote:

Hi,

This is more of a question than a issue but given:

?TXT2("Foo", LC) where the key "Foo" exists in default/en shouldn't ?TXT2("Foo", "blah") print the value from default/en? instead of "Foo". If the key doesn't exist in default/en I understand why "Foo" is being printed. Yes, gettext:default_lang() prints "en".

Also, is there a way to reload the default language. Looking through the code it looks like it's only possible to reload a custom language.

Given the above I fail to see the purpose of the default lang vs. having it as a custom lang.

Please, help me grok this.


Reply to this email directly or view it on GitHub: https://github.com/etnt/gettext/issues/7

etnt commented 12 years ago

Yes, ?TXT("Foo","blah") should give you whatever translation of "Foo" that you have in your default/gettext.po file.

gettext:recreate_db() will reload the complete gettext database.

When it comes to default language: my advice is to have a custom language also for the 'default' language, i.e if you have 'en' as default language today, then create a custom-en where you have your English text. This way you get around the problem of having certain texts that may only be applicable for one (or a few) markets. The 'default' po-file will reflect all the text that you have in your source, but you now have the option of translating it where it makes sense.

Cheers, Tobbe

bipthelin commented 12 years ago

Tobbe, you have any idea if recreate_db() is safe to do while in production or will it block or fail while recreating.

I can't get the behavior you describe where ?TXT("Foo","blah") should give me the translation from default/en/gettext.po when gettext:default_lang() == "en". I get "Foo" instead.

bipthelin commented 12 years ago

I've added a pull request where I change the behavior so ?TXT("Foo","blah") gives me the translation from default/en/gettext.po when gettext:default_lang() == "en".

Browsing through lookup/3 this wasn't the case before, it would just return Key.

etnt commented 12 years ago

Yes, we are using the recreate_db() in our production system. I'll look into that pull-request. Also, if you are using translators for doing the translation, you should have a look at: https://github.com/etnt/polish