I am trying to build a multilingual site with PHP (Linux Mint in German, XAMPP) and I am not able to switch between languages.
To rule out all other potential problems, I broke the whole code down to the minimal example.
Index.php:
session_start();
$locale = "en_GB.utf8";
//To switch languages, (un)comment the following:
//$locale = "es_ES.utf8";
//$locale = "de_DE.utf8";
putenv("LANG=" . $locale);
setlocale(LC_ALL, $locale);
$domain = "strings";
bindtextdomain($domain, "locale");
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
echo _("Hello World!");
This code always shows me as output "Hallo Welt!" (the German translation), even if the locale is set to English or Spanish (hardcoded to simplify it).
Things I have done so far:
- Checked the folder structure (I tried with /locale/ll_CC/LC_MESSAGES/strings.po and /locale/ll_CC.utf8/LC_MESSAGES/strings.po)
- Checked installed locales on my system with
locale -a
- Restarted Apache after switching language
Thank you for your help!