EDIT – apparently this is all wrong so please disregard.
You can use the WP_LANG_DIR
constant to load translations from the update-safe languages directory first, and fall back to your plugin languages directory for any plugin-supplied translations. The default location is wp-content/languages
, and users can set WP_LANG_DIR
themselves in wp-config.php
. When you load translations from multiple sources, the first found instance will be used, so user translations will always override any plugin-supplied translations, and allow users to do partial translations without translating all strings.
function your_plugin_load_plugin_textdomain(){
$domain = 'your-plugin';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
// wp-content/languages/your-plugin/your-plugin-de_DE.mo
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . "https://wordpress.stackexchange.com/" . $domain . '-' . $locale . '.mo' );
// wp-content/plugins/your-plugin/languages/your-plugin-de_DE.mo
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'init', 'your_plugin_load_plugin_textdomain' );