JavaScript Object Notation (JSON) files
In this window, you can choose how memoQ imports JSON files. This format is used in the localization of interactive websites as well as software products.
JSON stands for Java Script Object Notation. It's a text-based open standard and also a data-interchange format. JSON is easy to read and write for machines. It's based on a subset of the Java Script Programming Language.
JSON is used for serializing and transmitting structured data over a network connection (mainly to transmit data between a server and a web application). It is used as an alternative to XML.
JSON is a text format that is completely language-independent. It uses the syntax of the C-family programming languages such as C, C++ or C#.
The default character encoding for JSON is UTF-8, but JSON also supports UTF-16 and UTF-32.
To learn more about JSON: Click here (the link is available at the time of writing).
There are two types of JSON files. It's either a collection of name-value pairs of objects, or an ordered list of values.
memoQ uses the name-value pairs: memoQ imports the object name as context and the value as source text.
How to get here
- Start importing a JSON document.
- In the Document import options window, select the JSON documents, and click Change filter and configuration.
- The Document import settings window appears. From the Filter drop-down list, choose JSON filter.
What can you do?
Normally, memoQ detects the input encoding automatically.
If this doesn't work, clear the Automatically detect input encoding if possible check box. From the Select input encoding list, choose an encoding.
Always check if the text in Preview box appears correctly. Check thoroughly if every character is correct.
Normally, memoQ exports the translation in the same encoding as in the input file.
If the input file isn't Unicode (e.g. UTF-8), and the target language has a different script, this isn't possible. When this happens, clear the Same as input check box. From the Select output encoding drop-down box, choose an encoding.
Don't clear the Write BOM for unicode encoded files at export check box. For the system that uses the translation, this may be required to recognize the correct encoding.
Many JSON files have multiple nested blocks that look like this:
Normally, memoQ imports the name of the entry (the first part before the colon) as the context of the segment. But if the entry is part of a larger block (or several nested larger blocks), this context will not be unique. In this case, you can't efficiently use the name of the entry as the context. You need the entire 'path' of the entry, such as "Common"."metricCharacters".
To set this up, use the radio buttons on the Context tab:
- To get all the context information there is: Choose the Use keys as well and the only the translatable value's own key radio buttons.
- To add an even larger context, like a project or a document: Choose the Use keys as well and the all the keys up to the root, concatenated with radio buttons, and type the context label in the text box below it. You can invent this freely: the point is to make the context identifiers as unique as possible, so that you don't get false context matches from translation memories.
JSON files are used to describe data in general, similarly to XML files. Most of the time, a key - an item or an entry or a structure - in a JSON file is not text. It can be a number, a date, another data type, or a complex structure of further data.
If you need to translate text in a complex JSON file, you need to be able to extract translatable text.
To do this, use the Key options tab:
By default, the Translatability setting is set to translatable for all keys.
Whether a value is translatable or not is decided by the "sum" of the translatability of all its parents
How to sum two values
- 'weak translatable' is overruled by either 'strong translatable' or 'not translatable'
- when 'strong translatable' and 'not translatable' meet, the child wins
Parent is... | |||
---|---|---|---|
Child is... | strongly translatable | translatable | not translatable |
strongly translatable | strongly translatable | strongly translatable | strongly translatable |
translatable | strongly translatable | translatable | not translatable |
not translatable | not translatable | not translatable | not translatable |
Based on children's values
For now, we only allow for one of these conditions for a key.
If the condition is false, the translatability of the key is negated: 'translatable' turns into "not translatable, 'not translatable' turns into 'translatable'.
When you finish
To confirm the settings, and return to the Document import options window: Click OK.
To return the Document import options window, and not change the filter settings: Click Cancel.
If this is a cascading filter, you can change the settings of another filter in the chain: Click the name of the filter at the top of the window.
In the Document import options window: Click OK again to start importing the documents.