phpinternationalizationgettextpomo

Wordpress .po file won't recognize french accents


I've written a .po file for my wordpress theme. The charset is unicode as I cannot define it as 'utf-8' or it will not open in Poedit (the program I'm currently using to catalog my strings). Unfortunately, strings containing accents (french strings, as my base language is french) will not be rendered correctly by either Peoedit (and consequently it's .mo compilation), or the gettext handlings of __() and _e(). My .php files for my website are currently utf-8, to handle french accents.

Could a charset mismatch between .mo and web files be the culprit here? If so, how do I render my .po and .mo files under utf-8 charset and get it to work? Here is the header of my .po file (including utf-8 encoding that doesn't work):

msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: Patrick <shock_x_trooper@hotmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"

Solution

  • In lieu of any initialization code details or hexdumps of your actual .po or .mo files, the only thing that might be worth looking into is bind_textdomain_codeset. (Also setlocale or adding charset in LANG= or LC_ALL=.)

    msgfmt and php2po (via Pootle) are alternatives to Poedit, if you can't manage to make UTF-8 work. (Which is what you need to do.)