array( 'thousands_sep' => '.', 'decimal_point' => ',' ), ); public static function boot() { if ( false !== has_action( 'after_setup_theme', array( __CLASS__, 'apply' ) ) ) { return; } add_action( 'after_setup_theme', array( __CLASS__, 'apply' ), 0 ); add_action( 'change_locale', array( __CLASS__, 'apply' ), 0 ); } public static function apply( $locale = '' ) { global $wp_locale; if ( ! $wp_locale instanceof WP_Locale ) { return; } $locale = is_string( $locale ) && '' !== $locale ? $locale : determine_locale(); if ( '' === $locale || 0 === strpos( $locale, 'en' ) ) { return; } foreach ( array( 'thousands_sep' => 'number_format_thousands_sep', 'decimal_point' => 'number_format_decimal_point' ) as $key => $string ) { if ( $string !== translate( $string, 'default' ) ) { continue; } $own = self::separator( $locale, $key ); if ( null !== $own ) { $wp_locale->number_format[ $key ] = $own; } } } public static function separator( $locale, $key ) { if ( class_exists( 'NumberFormatter' ) ) { $format = NumberFormatter::create( (string) $locale, NumberFormatter::DECIMAL ); if ( $format ) { $symbol = $format->getSymbol( 'thousands_sep' === $key ? NumberFormatter::GROUPING_SEPARATOR_SYMBOL : NumberFormatter::DECIMAL_SEPARATOR_SYMBOL ); if ( is_string( $symbol ) && '' !== $symbol ) { return $symbol; } } } $lang = strtolower( (string) strtok( (string) $locale, '_-' ) ); return self::KNOWN[ $lang ][ $key ] ?? null; } } }