'fr_FR', 'es' => 'es_ES', 'en' => 'en_US' ]; public static function load(): void { self::$translations = [ 'Activate' => __( 'Activate', 'aec-kiosque' ), 'AEC Secret key' => __( 'AEC Secret key', 'aec-kiosque' ), 'By' => __( 'By', 'aec-kiosque' ), 'Default domain' => __( 'Default domain', 'aec-kiosque' ), 'Establishment type' => __( 'Establishment type', 'aec-kiosque' ), 'Help center' => __( 'Help center', 'aec-kiosque' ), 'Kiosque URL' => __( 'Kiosque URL', 'aec-kiosque' ), 'Other' => __( 'Other', 'aec-kiosque' ), 'Request help' => __( 'aec_text_request_help', 'aec-kiosque' ), 'Save changes' => __( 'Save changes', 'aec-kiosque' ), 'Select the domain to use' => __( 'Select the domain to use', 'aec-kiosque' ), 'Settings' => __( 'Settings', 'aec-kiosque' ), 'Shortcode documentation' => __( 'Shortcode documentation', 'aec-kiosque' ), 'Shortcode generator' => __( 'Shortcode generator', 'aec-kiosque' ), 'To start using AEC please provide your AEC Secret Key.' => __( 'To start using AEC please provide your AEC Secret Key.', 'aec-kiosque' ), 'Welcome' => __( 'Welcome', 'aec-kiosque' ), ]; } private static function get( string $value ): string { return Aec_Translations::$translations[$value] ?? $value; } public static function get_translation( string $value ): string { if( ( $translation = Aec_Translations::get( $value ) ) !== $value ) { return $translation; } if( ( $default_translation = Aec_Translations::get_default_translation( $value ) ) !== $value ) { return $default_translation; } return $value; } private static function get_default_translation( string $value ): string { Aec_Translations::switch_to_locale( Aec_Translations::get_target_locale() ); $translation = Aec_Translations::get( $value ); Aec_Translations::restore_previous_locale(); return $translation; } private static function switch_to_locale( string $locale ): void { switch_to_locale( $locale ); Aec_Translations::load(); } private static function restore_previous_locale(): void { restore_previous_locale(); Aec_Translations::load(); } private static function get_target_locale(): string { foreach( Aec_Translations::$base_locale_mappings as $prefix => $targetLocale ) { if( strpos( get_locale(), $prefix ) === 0 ) { return $targetLocale; } } return Aec_Translations::$default_locale; } }