etnt / gettext

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

Add clause to pt for key2str/2 calls #21

Closed gpouilloux closed 7 years ago

gpouilloux commented 7 years ago

WIthout this additional clause: -define(TXT(S), gettext:key2str(S)). matchs so a new message is generated in the .po file -define(TXT2(S, Lang), gettext:key2str(S, Lang)). doesn't match, no message detected

This fix allows us to benefit from the TXT2 macro in order to override the locale during a HTTP request for instance.

?TXT2("My message", i18n:get_locale_from_cookie(Cookie))

It avoids constructs such as:

put(gettext_language, i18n:get_locale_from_cookie(Cookie)),
?TXT("My message")
richcarl commented 7 years ago

Thank you! This feature has probably never been properly tested.