Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Gettext - No translation
    primarykey
    data
    text
    <p>I am trying to use the PHP gettext extension in order to translate some strings. All functions appear to return the correct values but calling <code>gettext()</code>/<code>_()</code> returns the original string only. The PO/MO files seem correct and I believe I have set the directories up correctly. I am running WAMP Server with PHP 5.3.10 on Windows (also tried running 5.3.4 and 5.3.8 because I have the installations).</p> <p>Firstly, see <code>/new2/www/index.php</code>:</p> <pre><code>$locale = 'esn'; # returns Spanish_Spain.1252 in var dump putenv("LC_ALL={$locale}"); // Returns TRUE setlocale(LC_ALL, $locale); // Returns 'Spanish_Spain.1252' $domain = 'messages'; bindtextdomain($domain, './locale'); // Returns C:\wamp\www\new2\www\locale bind_textdomain_codeset($domain, 'UTF-8'); // Returns UTF-8 textdomain($domain); // Returns'messages' print gettext("In the dashboard"); // Prints the original text, not the translation. exit; </code></pre> <p>I have created the following file structure:</p> <pre><code>www/new2/www/locale/Spanish_Spain.1252/LC_MESSAGES/messages.mo </code></pre> <p>I have also tried replacing <code>Spanish_Spain.1252</code> with: <code>es_ES</code>, <code>esn</code>, <code>esp</code>, <code>Spanish</code>, and <code>Spanish_Spain</code>.</p> <p>The PO file used to generate the MO is like so (only the relevant entry given):</p> <pre><code>#: C:\wamp\www\new2/www/index.php:76 msgid "In the dashboard" msgstr "TRANSLATED es_ES DASHBOARD" </code></pre> <p>This was generated using PoEdit. I have restarted Apache after adding any new .MO file. Also note that I was previously using Zend_Translate with Gettext and it was translating correctly. I wish to rely on the native gettext extension, though, in part because I am attempting to create a lightweight framework of my own.</p> <p>Any help would be appreciated.</p> <p><em>Edit</em>: Amended directory structure. Note - will be able to try recent answers within 24hrs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload