I need to make few basic changes on my local Windows Server to make gettext run properly. My local server is Windows with apache2.2.1 and php5.
- Enable the gettext.dll extention in php.ini file
- Download iconv.dll and put it under ext folder in PHP, this will enable the iconv extention.
In your global file in PHP just put this code
$language=$_SESSION['LanguageNm'];
putenv(”LANG=$language”);
setlocale(LC_ALL, $language);
$domain = ‘messages’;
include “locale”;
bindtextdomain($domain, “locale”);
bind_textdomain_codeset (domain, codeset); //Important for getting rid of question marks in translated words
textdomain($domain);
For making it run on Linux I had to make a small modification . The issue was on windows I was taking the language variable to be “es” or “ar” for Spanish or Arabic languages etc. but on linux it needs to be defined in a different way like “es_ES” or “ar_AR” so just change this line in the above code from
$language=$_SESSION['LanguageNm'];
to
$language=$_SESSION['LanguageNm'].”_”.strtoupper($_SESSION['LanguageNm'])
Hope this could help someone saving precious time