I'm trying to implement translations with gettext but I can not translate anything.
My project has the structure:
Project:
-
index.php
-
locale
-
en_GB
-
LC_MESSAGES
- en_GB (.po and .mo)
-
I have looked in my php.ini that gettext is activated and the installed locales are the following:
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
es_AR.utf8
es_BO.utf8
es_CL.utf8
es_CO.utf8
es_CR.utf8
es_CU
es_CU.utf8
es_DO.utf8
es_EC.utf8
es_ES.utf8
es_GT.utf8
es_HN.utf8
es_MX.utf8
es_NI.utf8
es_PA.utf8
es_PE.utf8
es_PR.utf8
es_PY.utf8
es_SV.utf8
es_US.utf8
es_UY.utf8
es_VE.utf8
POSIX
My index.php file has the example structure that I saw in this link Gettext does not translate PHP web
<?php
$language = "en_GB";
if (isset($_GET['language']))
{
$language = $_GET['language'];
}
putenv("LANG=" . $language);
putenv("LC_ALL={$language}");
setlocale(LC_ALL, $language);
$domain = $language;
bindtextdomain($domain, "./locale/");
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
if (function_exists("gettext")){
echo _("La función gettext existe");
}
else{
echo _("La función gettext no existe");
}
echo '<br>' . $language . '<br>';
echo _("Hola mundo");
?>
I have done several tests, attempts, route changes for the locale, the names of my files and there is no way to translate the string.
What can happen to you?