I have been reading very carefully and more than once the documentation, yet I don't understand how to provide a plugin with multiple languages.

In the example there is an array, such as:

$strings = array(
    'somestring' => __('My custom Tinymce plugin', 'textdomain'),

but I am not clear on how to provide the same text in other languages... I am sure I just misunderstood something very simple but I cannot find my way out of it...

I also went through this Q&A but I don't see a clear example with at least 2 different languages.

Thanks for your help!

  • Hmmmm, I could find only this which says no more than what is already stated in the documentation I linked. It explains how to provide one single language for the placeholders, not how to provide N sets of translations... Am I wrong?
    – Mirko G.
    Nov 11 '14 at 20:33

Ok for everyone else's benefit this is what is not explained in the documentation:

  1. You need to specify a textdomain anyway in your plugin (and together with it the path to the directory containing the language files, as usual).
  2. The PHP file used for the translation should contain an array like:

    $strings = array(
        'string1' => esc_js( __('Your text 1', 'your_textdomain') ),
        'string2' => esc_js( __('Your text 2', 'your_textdomain') ),
  3. Now you can use tools like Poedit to get the master file you will use for the translations.

  4. The translations (.MO) must be included in the languages folder as per point 1 above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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