pty( $i18n_schema ) || empty( $settings ) || empty( $textdomain ) ) { return $settings; } if ( is_string( $i18n_schema ) && is_string( $settings ) ) { return translate_with_gettext_context( $settings, $i18n_schema, $textdomain ); } if ( is_array( $i18n_schema ) && is_array( $settings ) ) { $translated_settings = array(); foreach ( $settings as $value ) { $translated_settings[] = translate_settings_using_i18n_schema( $i18n_schema[0], $value, $textdomain ); } return $translated_settings; } if ( is_object( $i18n_schema ) && is_array( $settings ) ) { $group_key = '*'; $translated_settings = array(); foreach ( $settings as $key => $value ) { if ( isset( $i18n_schema->$key ) ) { $translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $value, $textdomain ); } elseif ( isset( $i18n_schema->$group_key ) ) { $translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$group_key, $value, $textdomain ); } else { $translated_settings[ $key ] = $value; } } return $translated_settings; } return $settings; } /** * Retrieves the list item separator based on the locale. * * @since 6.0.0 * * @global WP_Locale $wp_locale WordPress date and time locale object. * * @return string Locale-specific list item separator. */ function wp_get_list_item_separator() { global $wp_locale; if ( ! ( $wp_locale instanceof WP_Locale ) ) { // Default value of WP_Locale::get_list_item_separator(). /* translators: Used between list items, there is a space after the comma. */ return __( ', ' ); } return $wp_locale->get_list_item_separator(); } /** * Retrieves the word count type based on the locale. * * @since 6.2.0 * * @global WP_Locale $wp_locale WordPress date and time locale object. * * @return string Locale-specific word count type. Possible values are `characters_excluding_spaces`, * `characters_including_spaces`, or `words`. Defaults to `words`. */ function wp_get_word_count_type() { global $wp_locale; if ( ! ( $wp_locale instanceof WP_Locale ) ) { // Default value of WP_Locale::get_word_count_type(). return 'words'; } return $wp_locale->get_word_count_type(); } /** * Returns a boolean to indicate whether a translation exists for a given string with optional text domain and locale. * * @since 6.7.0 * * @param string $singular Singular translation to check. * @param string $textdomain Optional. Text domain. Default 'default'. * @param ?string $locale Optional. Locale. Default current locale. * @return bool True if the translation exists, false otherwise. */ function has_translation( string $singular, string $textdomain = 'default', ?string $locale = null ): bool { return WP_Translation_Controller::get_instance()->has_translation( $singular, $textdomain, $locale ); }