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 writing a plugin and i wanted to i18n correctly text which i'm storing in the db or in an external file. How should i do that?As of now we are generating pot files with wordpress and so all the Translatable text is in calls

__( 'text', 'plugin_name');

But there is some text i would like to store in the db or in another format and that i don't know how to put into the POT files.

The only thing that come to my mind is to use arrays for these data structures so that i can translate the values, but are there other options?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Short answer: You don't. Not with the I18N functions. Data in the database is data that can change, and should be translated via some separate means. Data in the code is hard-coded, and doesn't change, and can be translated via the I18N functions.

If you want to store all your translatable text in a single PHP file as an array, and then reference it from elsewhere in the code, then that works fine.

share|improve this answer
    
Ok - understood, i'll use an array :) –  Nicola Peluchetti Oct 10 '12 at 20:28
add comment

But there is some text i would like to store in the db or in another format and that i don't know how to put into the POT files.

If the text is in the database, you can't translate it using a POT file. The entire point of translation is to set up a lookup against static strings used in your code. If the text is in the database, it's not static, and can't be translated.

Well, at least not with the standard i18n feature's you're trying to use.

share|improve this answer
add comment

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.