WP_Theme_JSON_Resolver::translate() WordPress Method
The WP_Theme_JSON_Resolver::translate() method is used to translate a string from one language to another. This is useful for making your theme more accessible to international users.
WP_Theme_JSON_Resolver::translate( array $theme_json, string $domain = 'default' ) #
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_json
(array)(Required)The theme.json to translate.
- $domain
(string)(Optional) Text domain. Unique identifier for retrieving translated strings.
Default value: 'default'
Return
(array) Returns the modified $theme_json_structure.
Source
File: wp-includes/class-wp-theme-json-resolver.php
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 ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |