On this page
WP_Theme_JSON_Resolver::translate( array $theme_json, string $domain = 'default' ): array
Given a theme.json structure modifies it in place to update certain values by its translated strings according to the language set by the user.
Parameters
$theme_jsonarray Required-
The theme.json to translate.
$domainstring Optional-
Text domain. Unique identifier for retrieving translated strings.
Default'default'.Default:
'default'
Return
array Returns the modified $theme_json_structure.
Source
File: wp-includes/class-wp-theme-json-resolver.php. View all references
protected static function translate( $theme_json, $domain = 'default' ) {
if ( null === static::$i18n_schema ) {
$i18n_schema = wp_json_file_decode( __DIR__ . '/theme-i18n.json' );
static::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema;
}
return translate_settings_using_i18n_schema( static::$i18n_schema, $theme_json, $domain );
}
Related
Uses
| Uses | Description |
|---|---|
| translate_settings_using_i18n_schema() wp-includes/l10n.php | Translates the provided settings value using its i18n schema. |
| wp_json_file_decode() wp-includes/functions.php | Reads and decodes a JSON file. |
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/translate