Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

translate_settings_using_i18n_schema() WordPress Function

The translate_settings_using_i18n_schema() function is used to translate settings pages and fields using the WordPress translation system. This function will return an array of translated settings, which can be used to update the settings pages and fields in your WordPress site.

translate_settings_using_i18n_schema( string|string[]|array[]|object $i18n_schema, string|string[]|array[] $settings, string $textdomain ) #

Translates the provided settings value using its i18n schema.


Parameters

$i18n_schema

(string|string[]|array[]|object)(Required)I18n schema for the setting.

$settings

(string|string[]|array[])(Required)Value for the settings.

$textdomain

(string)(Required)Textdomain to use with translations.


Top ↑

Return

(string|string[]|array[]) Translated settings.


Top ↑

Source

File: wp-includes/l10n.php

function translate_settings_using_i18n_schema( $i18n_schema, $settings, $textdomain ) {
	if ( empty( $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;
}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.