Making a configurable field translatable

I’m working on a theme right now that gives the admin the possibility to set different texts that are used within the theme, by configuring them in the admin panel (e.g. the text that is displayed, when a 404 error occurs).

I want to make these config fields translatable. What is the best way to do so, or what do I have to take into account for doing so?

Read More

Thanks and regards,
René

Related posts

Leave a Reply

1 comment

  1. What I have seen in translation plugins (qTranslate, WPML, Multilingual Press) are two approaches.


    One is qTranslate’s (and the defunct xLanguage): use one field (one for title, other for content, etc) to hold all translations. And then, in the front end, decode its output according to the actual language.

    <!--en-->English<--:--><!--es-->Español<--:-->
    

    In the back end, the plugin decodes/encodes this in different input fields. They behave as separate entities but are a single one in the database. Whenever needed, the notation [:en]English[:es]Español can be applied directly by the user.

    I’m mentioning it for the sake of documentation, but this approach is complicated, problematic and the plugin fate looms.


    And then, WPML and MultilingualPress: use different fields, posts, sites, for each language and link them together.

    In a theme/plugin options page it would mean two fields: page_404_en and page_404_es.

    Grabbing qTrans interface idea for the_content:
    create CSS/jQuery display tabs, English | Español and show one field in each.

    In the frontend, detect the language and display the correspondent field:

    $language = get_cookie_language(); // fake function
    $the_text = get_option( 'page_404_' . $language );