2

I just used Poedit to translate a plugin with no translations.

I found strings to translate and I generated the .POT file and the .PO and .MO in my language.

I created a folder languages in the plugin directory and I put the files in, but it doesn't work.

Do I need to do something to say to my WordPress to look at this folder ? I don't understand what to do.

  • The plugin has to use load_plugin_textdomain to load the files. Which plugin is concerned ? – mmm Oct 21 '17 at 18:53
  • Oh ok, I will take a look and add it myself. The plugin is fr.wordpress.org/plugins/jquery-t-countdown-widget (I will fork I think after) – Vincent Decaux Oct 21 '17 at 18:54
  • I look the plugin and it searches the file wp-content/languages/plugins/jquery-t-countdown-widget-fr_FR.mo then just put the file in this directory. – mmm Oct 21 '17 at 19:02
  • Yes I saw the same, thanks for your help. You can put an answer with the function name, very useful to understand how it works, I will accept. – Vincent Decaux Oct 21 '17 at 19:15
  • 1
    I add just a warning about opensource plugins from wordpress.org. If a plugin provide a translation, the file is installed in languages/plugins and will erase your custom file. – mmm Oct 21 '17 at 21:22
1

Plugins and themes pull the translation files manually from (mostly) their directory. There are 2 different functions which handle this:

For plugins : load_plugin_textdomain()

For themes: load_theme_textdomain()

The syntax would be something like this, mostly hooked into init or plugins_loaded action hook:

load_plugin_textdomain( 'text-domain', get_template_directory() . '/some-directory' );

OR:

load_plugin_textdomain( 'text-domain', false, basename(dirname(__FILE__)).'/some-directory');

Look for that in your plugin's php file. After translation, you should paste move the translation file into that directory, and name it as follows, according to codex:

The .mo file should be named based on the domain followed by a dash, and then the locale exactly. For example, the locale for German is 'de_DE', and the locale for Danish is 'da_DK'. If your plugin's text domain is "my-plugin" the Danish .mo and.po files should be named "my-plugin-da_DK.mo" and "my-plugin-da_DK.po" Call this function in your plugin as early as the init action.

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.