I am working on a Plugin for Wordpress and I'm not able to get the Internationalization working.
Here is the GitHub Link:
I used wppb.me as a Boilerplate and titan framework as a Admin Panel Framework. I created the pot, po and mo with poedit + Loco Translate (Cause I only have the free versio of poedit).
The following is happening: In the Plugins Menue the translated short description is shown. In my own Menue none of the Strings is translated.
Structure for Translation is the following:
- studio-link-integration.php =>
new Studio_Link_Integration
( /includes/class-studio-link-integration.php ) __contruct => set_locale();
private function set_locale() { $plugin_i18n = new Studio_Link_Integration_i18n(); $plugin_i18n->set_domain( 'studio-link-integration' ); $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); }
in class
Studio_Link_Integration_i18n
public function load_plugin_textdomain() { load_plugin_textdomain( $this->domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); }
Language Files are in /languages/ and are named studio-link-integration-de_DE.
translation is done with __( 'Text to Translate', 'studio-link-integration' )
.
I really dont know, why it wont work. Can someone look at my Files and help me? Am I forgetting some new specifications for translating? I read the whole Codex about Localization and Internationalisation but havent found anything new out that helped me.
Thanks :)
I am working on a Plugin for Wordpress and I'm not able to get the Internationalization working.
Here is the GitHub Link: https://github/dev-nm/WP-StudioLink-Integration
I used wppb.me as a Boilerplate and titan framework as a Admin Panel Framework. I created the pot, po and mo with poedit + Loco Translate (Cause I only have the free versio of poedit).
The following is happening: In the Plugins Menue the translated short description is shown. In my own Menue none of the Strings is translated.
Structure for Translation is the following:
- studio-link-integration.php =>
new Studio_Link_Integration
( /includes/class-studio-link-integration.php ) __contruct => set_locale();
private function set_locale() { $plugin_i18n = new Studio_Link_Integration_i18n(); $plugin_i18n->set_domain( 'studio-link-integration' ); $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); }
in class
Studio_Link_Integration_i18n
public function load_plugin_textdomain() { load_plugin_textdomain( $this->domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); }
Language Files are in /languages/ and are named studio-link-integration-de_DE.
translation is done with __( 'Text to Translate', 'studio-link-integration' )
.
I really dont know, why it wont work. Can someone look at my Files and help me? Am I forgetting some new specifications for translating? I read the whole Codex about Localization and Internationalisation but havent found anything new out that helped me.
Thanks :)
Share Improve this question edited Jan 28, 2019 at 10:29 Pratik Patel 1,1091 gold badge11 silver badges23 bronze badges asked Jan 28, 2019 at 8:46 Nicolas MierbachNicolas Mierbach 33 bronze badges 4- Please give an example of an actual string that doesn't work. Your German file contains a lot of translations in English including your main menu items. – Tim Commented Jan 28, 2019 at 9:52
- Well, none of the Strings works. The only Text that apperas in German is the short description, but it gets loaded in another way I guess, cause it is translated even before activationg the Plugin. EDIT: I just read the Translation File. The short description is not translated there. – Nicolas Mierbach Commented Jan 28, 2019 at 9:55
- EDIT: Nevermind the EDIT of the Commentabove. I just fergot to update the Files in the GitHub. Just uploaded it now – Nicolas Mierbach Commented Jan 28, 2019 at 10:04
- These Translations work: LINK – Nicolas Mierbach Commented Jan 28, 2019 at 10:11
1 Answer
Reset to default 0Your error is here
The path to your bundled translations resolve to a languages
folder inside the includes
folder, which is one level down from where it actually is.
Try it with an extra dirname
and you will target it correctly:
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
Or to be a bit tidier:
plugin_basename( __DIR__.'/../languages' )