...
The configuration will look like this:
...
Here too, :
...
How it works:
The “language” node will contain the language as per the JSON path and the '#' placeholder.
#
is replaced by the source or target language codes
...
in the Wordbee project.
The JSON path selects all array elements by language.
...
It uses a JSON path condition
...
:
[?( … condition …)]
...
When the filter looks for the English content, it selects the array elements using
[?(@.language ==
...
‘en-US')]
- assuming that this is the file’s source language.Translations are inserted back by cloning each source array elements.
Important (!!):
You also need to add “language” to the list of “Translate nodes”. Otherwise, the system will not localize the language-nodes and save back the target locales.
If you tick the option to translate all child nodes then you do not think about this detail.
Example 4 - Translate array elements with language indicator, no 2
...
The configuration now is $.products[….]
. The array elements are indeed located under the products
property. With JSON paths, the $
sign is the root of the document and writing $.products
locates the product node at the root. We further instructed to only translate the “text” properties but not any of the other ones.
...
...
Important (!!):
You also need to add “language” to the list of “Translate nodes”. Otherwise, the system will not localize the language-nodes and save back the target locales.
If you tick the option to translate all child nodes then you do not think about this detail.
Info |
---|
When the system inserts back the translations, it will clone the source language node or array element for each target language. If the target objects/elements already exist fully or partially in the source file, the system will keep any existing properties and replace only those that we are translating. |
Example
...
5 - Arrays in arrays in arrays
All the examples up to here are simple and you may come across more advanced files.
Keep in mind that you can configure multiple JSON paths at any time. The example below translates array based content (first selector #1below) and object based content (second selector #1below).
...
It is even possible to translate multilingual content containing multilingual content - if anyone ever wants to do it!
Code Block |
---|
{ "products": [ { "language": "English", "text": "This is an example", "features": { "English": "English feature", "French": "French translation", "Spanish": "Spanish translation" } } { "language": "French", "text": "Ceci est un exemple", } ] } |
Example
...
6 - Reading meta data
Please check out the meta-data examples we explain with monolingual files.
The mechanism and configuration options are the same.
...