From 8751eacdf23231b3769b5eaddd87f97e25a0a4fe Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Fri, 6 Feb 2026 23:39:15 +0900 Subject: [PATCH] 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 --- umzugsliste.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/umzugsliste.php b/umzugsliste.php index 6cb62e3..42b4b7a 100644 --- a/umzugsliste.php +++ b/umzugsliste.php @@ -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 */