Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
added debug
Source Link
Owl
  • 231
  • 4
  • 15

I try to localize my plugin.

in the plugin php file my-plugin.php I have the textdomain

Text Domain: my-plugin

and the action on "plugins_loaded"

// load textdomain on plugin
function my-plugin_load_textdomain() {
  echo '<script>console.log("fired");</script>'; 
  if (load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' )) {
       echo '<script>console.log("ok");</script>';
  } else {
       echo '<script>console.log("not");</script>';
  }
}
add_action( 'plugins_loaded', 'my-plugin_load_textdomain' );

The plugin itselfs displays a shortcode and loads the my-plugin-output.php which has following echos

<h4><?php _e( 'Ausgabe', 'my-plugin' ); ?></h4>

I have in the folder languages the my-plugin-de.mo files which I translated via poedit to my-plugin-en.mo. The translation is complete. Following files are in the languages folder:

my-plugin-de.mo

my-plugin-de.pot

my-plugin-en.mo

my-plugin-en.po

I have read several tutorials, however many of them say I should add a define WP-LANG, but this is not needed in WordPress 4.0 and above?

My site language is now selected as english. The basic code in the plugin is german, but it should display the english language.

When I activate the plugin the console gives me the message that the load_plugin_textdomain returns false, on codex I see this

Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

What does this mean? I translated the files with poedit, and I can open it in poedit without problems. If I validate the en.po file in poedit, it says everything is ok. The language folder is also correct.

Am I missing here something? Thanks very much

EDIT:

The output from debug translations:

Debug Translations (Version 2013.09.05)

Locale: en_US


Domain:    default
File:      C:\xampp\htdocs\projekte\WP/wp-content/languages/en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-settings.php line 306 load_default_textdomain

Domain:    twentyfourteen
File:      C:\xampp\htdocs\projekte\WP/wp-content/themes/twentyfourteen/languages/en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-content\themes\twentyfourteen\functions.php line 68 load_theme_textdomain

Domain:    twentyfourteen
File:      C:\xampp\htdocs\projekte\WP/wp-content/languages/themes/twentyfourteen-en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-content\themes\twentyfourteen\functions.php line 68 load_theme_textdomain

My plugin is not listed at all? It is activated and does also output on the page? This is strange

I try to localize my plugin.

in the plugin php file my-plugin.php I have the textdomain

Text Domain: my-plugin

and the action on "plugins_loaded"

// load textdomain on plugin
function my-plugin_load_textdomain() {
  echo '<script>console.log("fired");</script>'; 
  if (load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' )) {
       echo '<script>console.log("ok");</script>';
  } else {
       echo '<script>console.log("not");</script>';
  }
}
add_action( 'plugins_loaded', 'my-plugin_load_textdomain' );

The plugin itselfs displays a shortcode and loads the my-plugin-output.php which has following echos

<h4><?php _e( 'Ausgabe', 'my-plugin' ); ?></h4>

I have in the folder languages the my-plugin-de.mo files which I translated via poedit to my-plugin-en.mo. The translation is complete. Following files are in the languages folder:

my-plugin-de.mo

my-plugin-de.pot

my-plugin-en.mo

my-plugin-en.po

I have read several tutorials, however many of them say I should add a define WP-LANG, but this is not needed in WordPress 4.0 and above?

My site language is now selected as english. The basic code in the plugin is german, but it should display the english language.

When I activate the plugin the console gives me the message that the load_plugin_textdomain returns false, on codex I see this

Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

What does this mean? I translated the files with poedit, and I can open it in poedit without problems. If I validate the en.po file in poedit, it says everything is ok. The language folder is also correct.

Am I missing here something? Thanks very much

I try to localize my plugin.

in the plugin php file my-plugin.php I have the textdomain

Text Domain: my-plugin

and the action on "plugins_loaded"

// load textdomain on plugin
function my-plugin_load_textdomain() {
  echo '<script>console.log("fired");</script>'; 
  if (load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' )) {
       echo '<script>console.log("ok");</script>';
  } else {
       echo '<script>console.log("not");</script>';
  }
}
add_action( 'plugins_loaded', 'my-plugin_load_textdomain' );

The plugin itselfs displays a shortcode and loads the my-plugin-output.php which has following echos

<h4><?php _e( 'Ausgabe', 'my-plugin' ); ?></h4>

I have in the folder languages the my-plugin-de.mo files which I translated via poedit to my-plugin-en.mo. The translation is complete. Following files are in the languages folder:

my-plugin-de.mo

my-plugin-de.pot

my-plugin-en.mo

my-plugin-en.po

I have read several tutorials, however many of them say I should add a define WP-LANG, but this is not needed in WordPress 4.0 and above?

My site language is now selected as english. The basic code in the plugin is german, but it should display the english language.

When I activate the plugin the console gives me the message that the load_plugin_textdomain returns false, on codex I see this

Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

What does this mean? I translated the files with poedit, and I can open it in poedit without problems. If I validate the en.po file in poedit, it says everything is ok. The language folder is also correct.

Am I missing here something? Thanks very much

EDIT:

The output from debug translations:

Debug Translations (Version 2013.09.05)

Locale: en_US


Domain:    default
File:      C:\xampp\htdocs\projekte\WP/wp-content/languages/en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-settings.php line 306 load_default_textdomain

Domain:    twentyfourteen
File:      C:\xampp\htdocs\projekte\WP/wp-content/themes/twentyfourteen/languages/en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-content\themes\twentyfourteen\functions.php line 68 load_theme_textdomain

Domain:    twentyfourteen
File:      C:\xampp\htdocs\projekte\WP/wp-content/languages/themes/twentyfourteen-en_US.mo (not found)
Called in: C:\xampp\htdocs\projekte\WP\wp-content\themes\twentyfourteen\functions.php line 68 load_theme_textdomain

My plugin is not listed at all? It is activated and does also output on the page? This is strange

Source Link
Owl
  • 231
  • 4
  • 15

Plugin translation ready - mo file not loaded

I try to localize my plugin.

in the plugin php file my-plugin.php I have the textdomain

Text Domain: my-plugin

and the action on "plugins_loaded"

// load textdomain on plugin
function my-plugin_load_textdomain() {
  echo '<script>console.log("fired");</script>'; 
  if (load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' )) {
       echo '<script>console.log("ok");</script>';
  } else {
       echo '<script>console.log("not");</script>';
  }
}
add_action( 'plugins_loaded', 'my-plugin_load_textdomain' );

The plugin itselfs displays a shortcode and loads the my-plugin-output.php which has following echos

<h4><?php _e( 'Ausgabe', 'my-plugin' ); ?></h4>

I have in the folder languages the my-plugin-de.mo files which I translated via poedit to my-plugin-en.mo. The translation is complete. Following files are in the languages folder:

my-plugin-de.mo

my-plugin-de.pot

my-plugin-en.mo

my-plugin-en.po

I have read several tutorials, however many of them say I should add a define WP-LANG, but this is not needed in WordPress 4.0 and above?

My site language is now selected as english. The basic code in the plugin is german, but it should display the english language.

When I activate the plugin the console gives me the message that the load_plugin_textdomain returns false, on codex I see this

Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

What does this mean? I translated the files with poedit, and I can open it in poedit without problems. If I validate the en.po file in poedit, it says everything is ok. The language folder is also correct.

Am I missing here something? Thanks very much