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
arrayrequired- A tree that follows the format of i18n-theme.json.
$current_path
arrayoptional- Keeps track of the path as we walk down the given tree.
Default:
array()
Source
/**
* Returns a data structure used in theme.json translation.
*
* @since 5.8.0
* @deprecated 5.9.0
*
* @return array An array of theme.json fields that are translatable and the keys that are translatable.
*/
public static function get_fields_to_translate() {
_deprecated_function( __METHOD__, '5.9.0' );
return 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.
*
* @since 5.8.0
*
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.