0

I have written a plugin to be translation-ready, and I have written a translation. As far as I can tell, the .mo files for the translation are loading correctly, yet the plugin is still displaying the original language instead of the translation.

Here is what I have done:

In the plugin, I define the language domain:

function cdashmm_language_init() {
  load_plugin_textdomain( 'cdashmm', false, 'chamber-dashboard-member-manager/languages' );
}
add_action('init', 'cdashmm_language_init');

Within the plugin, all of the strings are like this:

_e( 'This is a string', 'cdashmm' );

In the languages folder, I have files called cdashmm-en_GB.mo and cdashmm-en_GB.po. These files were generated by the Loco Translate plugin.

On the Settings --> General page, I have defined the language as English(UK).

I have installed a Debug Translations plugin: https://marketpress.com/product/debug-translations/ According to that plugin, the file called cdashmm-en_GB.mo is being loaded. Yet the page is not displaying the translated text.

What am I missing?

0

Ah ha! I found the answer, and it's a really weird one.

It just so happens that the particular strings I was trying to translate were the labels of required form fields, and looked like this:

<?php echo '<label>' . __( 'Email *', 'cdashmm' ) . '</label>' ?>

If I move the asterisk outside the string, like this:

<?php echo '<label>' . __( 'Email', 'cdashmm' ) . ' *</label>' ?>

then the translation works.

So I have solved the problem... but that does raise another question - why do asterisks inside strings make them untranslatable?

  • Some special characters do have issues with translators. I'm also not very clear on this as I don't have any programming bacground, but you can check out this – Pieter Goosen Apr 24 '15 at 5:40

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.