Last active
November 26, 2016 14:47
-
-
Save grappler/7060277 to your computer and use it in GitHub Desktop.
Loading theme and plugin translations in WordPress - https://ulrich.pogson.ch/load-theme-plugin-translations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function theme_name_setup(){ | |
$domain = 'theme-name'; | |
// wp-content/languages/theme-name/de_DE.mo | |
load_theme_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain ); | |
// wp-content/themes/child-theme-name/languages/de_DE.mo | |
load_theme_textdomain( $domain, get_stylesheet_directory() . '/languages' ); | |
// wp-content/themes/theme-name/languages/de_DE.mo | |
load_theme_textdomain( $domain, get_template_directory() . '/languages' ); | |
} | |
add_action( 'after_setup_theme', 'theme_name_setup' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function plugin_name_load_plugin_textdomain() { | |
$domain = 'plugin-name'; | |
$locale = apply_filters( 'plugin_locale', get_locale(), $domain ); | |
// wp-content/languages/plugin-name/plugin-name-de_DE.mo | |
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ); | |
// wp-content/plugins/plugin-name/languages/plugin-name-de_DE.mo | |
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); | |
} | |
add_action( 'init', 'plugin_name_load_plugin_textdomain' ); |
mszzarei, you can change the line 8 in "plugin-name.php" from:
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
to:
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $locale . '.mo' );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi.how can change name language plugin?
ex:change plugin-name-de_DE.mo to de_DE.mo?!