WordPress.org

Ready to get started?Download WordPress

Forums

Localizing themes: how to "enforce" UTF-8? (2 posts)

  1. Berlueur
    Member
    Posted 9 years ago #

    OK, I'm an utter newbie at both WordPress and PHP.

    I want to translate some themes in French -- for instance, the Wuhan one (yes, I know about the existing French translation, but I had started doing my own version before discovering it and, besides, it seems to contain errors AND, apparently, it doesn't use UTF-8).

    Obviously, I want to use good and yummy UTF-8.

    So I take the *.php files, convert their encoding to UTF-8 (it seems to me that some of them are not in UTF-8 -- even translated ones... am I right about this?) and translate stuff.

    But how do I make sure that all the browsers in the world will know for sure that the characters I "painfully" translated must be interpreted as UTF-8?

    Can I use something like the tag that is used in HTML files:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    Can I use that, "as is", do I have to modify it... or is there another way to enforce the interpretation of the theme's characters as UTF-8?

    Thanks for your help.

  2. Berlueur
    Member
    Posted 9 years ago #

    OK, replying to my own question here.

    Not much love was given to my post... but, not to worry, I found out how things worked on my own.

    So, for the benefit of others who might be in the same newbic position I was in (who knows? there really might be some...), here goes.

    The normal practice is to define the theme's encoding in the "header.php" file. It is done in the usual manner, i.e.:

    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

    with the added twist that the content type and charset are retrieved by appropriate PHP functions, which obediently return the settings defined by the user (though I believe the "html_type" is not settable through the standard admin interface).

    So, after verifying that the theme's designer has correctly placed this bit of code in the theme's "header.php" file (or after having added it himself/herself if it was missing), the theme localizer can then translate all the theme's files with his/her choice of encoding, in accordance with the encoding setting of his/her blog (ideally UTF-8), cradled by the unassailable comfort of knowing that his beloved idiosyncratic characters will be treated with respect and devotion all around the world.

Topic Closed

This topic has been closed to new replies.

About this Topic