I'm using gettext for internationalization for my php files. this structure of the files is this
/file.php
/locale
/en_US
/LC_MESSAGES
messages.po
messages.mo
/mk_MK
/LC_MESSAGES
messages.po
messages.mo
I have the following code in file.php. This DOESN'T work
if(isset($_SESSION['lang']))
{
$domain = "messages";
bindtextdomain($domain, "locale");
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
}
else
{
$_SESSION['lang'] = "en_US";
putenv("LANG=" . $_SESSION['lang']);
setlocale(LC_ALL, $_SESSION['lang']);
$domain = "messages";
bindtextdomain($domain, "locale");
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
}
BUT if I change the $_SESSION['lang'] in "mk_MK" it does translate here are the 2 messages.po files
messages.po in mk folder
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.7\n"
"Language: Macedonian\n"
"X-Poedit-SourceCharset: UTF-8\n"
msgid "home"
msgstr "Дома"
msgid "about"
msgstr "За нас"
msgid "products"
msgstr "Производи"
msgid "projects"
msgstr "Проекти"
msgid "contact"
msgstr "Контакт"
msgid "title_home"
msgstr "СОЛЕМ"
msgid "title_about"
msgstr "СОЛЕМ - За нас"
msgid "title_products"
msgstr "СОЛЕМ - Производи"
msgid "title_projects"
msgstr "СОЛЕМ - Проекти"
msgid "title_contact"
msgstr "СОЛЕМ - Контакт"
msgid "SOLEM"
msgstr "СОЛЕМ"
msgid "address"
msgstr "Ул. Владимир Комаров 33/1-2 <br/> 1000 Скопје<br/> Р. Македонија"
msgid "telephone"
msgstr "Тел: 02/2467 551"
msgid "mail"
msgstr "e-mail: info@solem.org.mk"
msgid "facebook"
msgstr "Здружение СОЛЕМ"
and the english version of the same
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.7\n"
"Language: English\n"
"X-Poedit-SourceCharset: UTF-8\n"
msgid "home"
msgstr "Home"
msgid "about"
msgstr "About us"
msgid "products"
msgstr "Products"
msgid "projects"
msgstr "Projects"
msgid "contact"
msgstr "Contact"
msgid "title_home"
msgstr "SOLEM"
msgid "title_about"
msgstr "SOLEM - About us"
msgid "title_products"
msgstr "SOLEM - Products"
msgid "title_projects"
msgstr "SOLEM - Projects"
msgid "title_contact"
msgstr "SOLEM - Contact"
msgid "address"
msgstr ""
"Address: Ul. Vladimir Komarov 33/1-2 <br/> 1000 Skopje <br/> R. Macedonia"
msgid "mail"
msgstr "e-mail: info@solem.org.mk"
msgid "telephone"
msgstr "Tel: (+389) 2 2467 551"
msgid "facebook"
msgstr "Organisatoin SOLEM"
msgid "SOLEM"
msgstr "SOLEM"
I suspect it has something to do with the actual folder location because when i switched the files (English file in mk folder) it translated it OK (in English even though the session control is "mk_MK" but that is off course because the file is switched). i tried restarting the services in the WAMP server but it didnt change anything