Localization category listing. ­ Textpattern CMS

FAQ: Localization

Non-ASCII characters are missing or incorrect

QUESTION:

Some characters are replaced with question marks on my pages



ANSWER:

This is most commonly caused by:

  • A missing DOCTYPE in your page template
  • A missing or incorrect character set in your page template
  • Using characters from a different character set (e.g. latin1 characters, when the charset is utf-8)
  • The mbstring.encoding_translation setting is turned on. This automatically converts all page output to some other character set, often ISO8859-1.

You can check the mbstring settings with php -i or phpinfo();. If mbstring.encoding_translation is on, ask your host about turning it off.

Textpattern has built-in support for Unicode. This means you don’t have to do anything special for non-ASCII characters to work. Just write articles using a modern browser, and enter any characters you like in the article title, body, and excerpt.

Don’t specify a legacy character set in your page doctype or HTML <meta> tags. The character set for all Textpattern pages should always be “utf-8”. If you use anything else, non-ASCII characters will be encoded incorrectly.

How do I display time and date formats in my local language?

The date and time functions used by Textpattern will automatically translate month and day names, provided the locale is set correctly, and provided your server supports it.

If you’ve selected the appropriate language in textpattern > admin > preferences and are still not seeing dates in your language, it most probably means that your web server’s operating system has limited support for your language. You should ask your hosting company to upgrade their locale support.

To use a different format for article dates, use the <txp:posted format="..." /> attribute. See here for more details.

To display an article date using a different language to the main Textpattern language, the following code will work on some systems:

&#60;txp:php>
global $locale;
setlocale(LC_ALL, 'nl_NL.UTF-8');
echo posted(array('format' => '%A %B %e %Y, %H:%M:%S'));
setlocale(LC_ALL, $locale);
&#60;/txp:php>

You’ll need to change the locale string (nl_NL.UTF-8) and format to suit.