I am having a strange problem with gettext on a server I am forced to use to redesign a website. The customer is used to having Network Solutions as provider so currently it's not an option to change providers. Anyway the problem is the following:
I thought it might not have gettext installed so I checked phpinfo and it is enabled.
gettext GetText Support enabled
I also checked using
if (!function_exists("gettext")) { echo "gettext is not installed\n"; } else { echo "gettext is supported\n"; }
The output says gettext is supported
I then thought perhaps the server is having issues with the native gettext so I tried using this one https://launchpad.net/php-gettext/. I uploaded it to the server and it's not working either.
The configuration in my header is
putenv("LC_ALL=".$locale.".utf8");
putenv("LANGUAGE=".$locale."utf8");
setlocale(LC_ALL, $locale.".utf8");
bindtextdomain($domain, "./locale");
bind_textdomain_codeset($domain, "UTF-8");
textdomain($domain);`
The $locale
and $domain
server are assigned before the functions.
The same code with gettext worked fine on my local apache server.
What could be the issue? As the site is not really that big I am considering using a database storage for the translations although I am not really into the idea but I am out of ideas why this is happening.
I have my locale file correctly located in ./locale/language_code/LC_MESSAGES/file.po
and file.mo
when I echo the return of the bindtextdomain it shows the full path to the locale.
Any suggestions?
After contacting Network Solutions via chat they told me that using their shared hosting you cannot use locales. There's also the problem with specific .htaccess syntax especially for their server which is a pain in the a**. I would definitely not recommend their hosting for shared servers. Anyway, thanks to @jacob-budin and @mike for helping.