WP_Theme_JSON_Resolver::extract_paths_to_translate( array $i18n_partial, array $current_path = array() )
Converts a tree as in i18n-theme.json into a linear array containing metadata to translate a theme.json file.
Description
For example, given this input:
{
"settings": {
"*": {
"typography": {
"fontSizes": [ { "name": "Font size name" } ],
"fontStyles": [ { "name": "Font size name" } ]
}
}
}
}
will return this output:
[
0 => [
'path' => [ 'settings', '*', 'typography', 'fontSizes' ],
'key' => 'name',
'context' => 'Font size name'
],
1 => [
'path' => [ 'settings', '*', 'typography', 'fontStyles' ],
'key' => 'name',
'context' => 'Font style name'
]
]
Parameters
- $i18n_partial
-
(array) (Required) A tree that follows the format of i18n-theme.json.
- $current_path
-
(array) (Optional) Keeps track of the path as we walk down the given tree.
Default value: array()
Return
(array) A linear array containing the paths to translate.
Source
File: wp-includes/class-wp-theme-json-resolver.php
self::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema; } return translate_settings_using_i18n_schema( self::$i18n_schema, $theme_json, $domain ); } /** * Return core's origin config. * * @since 5.8.0 * * @return WP_Theme_JSON Entity that holds core data. */ public static function get_core_data() { if ( null !== self::$core ) { return self::$core; } $config = self::read_json_file( __DIR__ . '/theme.json' ); $config = self::translate( $config );
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |