1

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?

2 Answers 2

2

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.

1
  • Ok - understood, i'll use an array :) Commented Oct 10, 2012 at 20:28
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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