Month: July 2009

  • Gotchas with gettext in PHP

    Be careful when you first try gettext in PHP, it can be very unreliable/unpredictable because of different naming conventions. $vLang = ‘vi_VN’; $vDomain = ‘MyApp’; putenv(“LANGUAGE=”.$vLang); putenv(“LANG=”.$vLang); bindtextdomain($vDomain,AS_BASEDIR.’locale’); bind_textdomain_codeset($vDomain,”UTF-8″); setlocale(LC_ALL,$vLang.”.utf8″,$vLang.”.UTF8″,$vLang.”.utf-8″,$vLang.”.UTF-8″,$vLang); textdomain($vDomain); MyApp.po vs MyApp.mo PO is the human-readable and you perform the translation in here. MO is the binary file and it’s cached by Apache.…