$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - I dont know why my localization is not working|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - I dont know why my localization is not working

matteradmin10PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

Your 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' )
Post a comment

comment list (0)

  1. No comments so far