1

I'm trying to add translations to my webpage. Unfortunately my translation isn't being read.

However, one translation is read (even though I ask for a different one).

My php code looks like this:

$language = "en_US"; //Hardcoded for debugging purposes
define("FOLDER_SPECIFICATION", "./locale/");
define("DOMAIN", "messages");
define("CODE_SET", "UTF-8");

putenv("LANG=" . $language);
setlocale(LC_ALL, $language);

bindtextdomain(DOMAIN, FOLDER_SPECIFICATION);
bind_textdomain_codeset(DOMAIN, CODE_SET);

textdomain(DOMAIN);

My folder structure looks like this:

root > 
    locale >
       en_US >
           LC_MESSAGES >
             messages.mo
             messages.po

       nl_NL >
           LC_MESSAGES >
             messages.mo
             messages.po

If I change the $language variable to en_US or nl_NL it still grabs the translation from nl_NL, if I remove the nl_NL folder it doesnt translate at all, this together means one thing: The en_US translation isn't being read.

Both messages.po contain headers and such and both are valid (I loaded them in poedit).

My question is: Why does it grab nl_NL even though I never told the code to grab it, and why isn't the other translation (en_US) being read?

Both .po files look like this (the 'Language' tag in the headers are obviously different):

msgid ""
msgstr ""
"Project-Id-Version: My Project\n"
"POT-Creation-Date: 2014-08-05 13:32+0100\n"
"PO-Revision-Date: 2016-04-19 10:43+0200\n"
"Last-Translator: \n"
"Language-Team: someone <s.omeone@something.com> \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: nl_UL\n"
"X-Poedit-SourceCharset: UTF-8\n"

msgid "Banaan"
msgstr "Banana"

msgid "Appel"
msgstr "Apple"
Mariia
  • 13
  • 4
Dubb
  • 423
  • 1
  • 7
  • 21

0 Answers0