Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks and regards,
René

share|improve this question

1 Answer 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 );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.