Created
October 20, 2013 12:00
-
-
Save grappler/7068629 to your computer and use it in GitHub Desktop.
Load only one translations file.
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'; | |
if ( $loaded = load_theme_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain ) ) { | |
return $loaded; | |
} elseif ( $loaded = load_theme_textdomain( $domain, get_stylesheet_directory() . '/languages' ) { | |
return $loaded; | |
} else { | |
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 ); | |
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ) ) { | |
return $loaded; | |
} else { | |
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); | |
} | |
} | |
add_action( 'init', 'plugin_name_load_plugin_textdomain' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment