chore(09-01): add i18n infrastructure and fix text domain
- Update text domain from 'umzugsliste' to 'siegel-umzugsliste' in plugin header - Add siegel_umzugsliste_load_textdomain() function hooked on init priority 1 - Add change_locale hook to reload text domain (workaround for WP core bug #39210) - Text domain loading enables translation file support in languages/ directory
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Description: Email-basiertes Möbelauswahlsystem für Siegel Umzüge
|
||||
* Version: 1.0.0
|
||||
* Author: Siegel Umzüge
|
||||
* Text Domain: umzugsliste
|
||||
* Text Domain: siegel-umzugsliste
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,31 @@ define( 'UMZUGSLISTE_VERSION', '1.0.0' );
|
||||
define( 'UMZUGSLISTE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'UMZUGSLISTE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
/**
|
||||
* Load plugin text domain for translations
|
||||
*/
|
||||
function siegel_umzugsliste_load_textdomain() {
|
||||
load_plugin_textdomain(
|
||||
'siegel-umzugsliste',
|
||||
false,
|
||||
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'siegel_umzugsliste_load_textdomain', 1 );
|
||||
|
||||
/**
|
||||
* Reload text domain on locale change
|
||||
* Workaround for WordPress core bug #39210 where switch_to_locale() doesn't reload plugin translations
|
||||
*/
|
||||
add_action( 'change_locale', function() {
|
||||
unload_textdomain( 'siegel-umzugsliste' );
|
||||
load_plugin_textdomain(
|
||||
'siegel-umzugsliste',
|
||||
false,
|
||||
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
||||
);
|
||||
} );
|
||||
|
||||
/**
|
||||
* Main plugin class
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user