Okapi ComponentsJSON Filter |
|
- Overview |
The JSON Filter is an Okapi component that implements the Okapi Filter Interface for JSON files.
JSON (JavaScript Object Notation) is a lightweight data format often used in Web-based applications. The specification can be found here: http://www.json.org/.
The following is an example of a simple JSON file.
{ "menu": { "id": "file", "value": "File", "popup": { "menuitem": [ { "value": "New", "onclick": "CreateNewDoc()" }, { "value": "Open", "onclick": "OpenDoc()" }, { "value": "Close", "onclick": "CloseDoc()" } ] } }}
Because any type of structure can be represented in JSON, there is no way to know what string values are translatable or not. The filter provides a default behavior and ways to override it.
The properties for the JSON Filter are the following:
Property | This Filter |
---|---|
INPUTFILE | Yes |
INPUTSTRING | Yes |
BILINGUALINPUT | No |
TEXTBASED | Yes |
OUTPUTFILE | Yes |
OUTPUTSTRING | Yes |
ANCILLARYOUTPUT | No |
XMLOUTPUT | No |
RTFOUTPUT | Yes |
USEKEY | No |
ISINDEMOMODE | No |
There is not encoding identifier in JSON format. So, the filter decides which encoding to use for the input file using the following logic:
The output encoding used is the one specified by the user.
By default the string extracted are all the value strings in the key-value pairs, and all the standalone strings. However, because JSON files can hold just about any type of data structure, you may have to change these defaults to extract less text. You can change these defaults in the Conditions and Options tabs as a last resort, you can also use DNL List Editing utility to specify non-translatable strings.
The Properties Filter supports localization directives. They are special comments you can use to override the default behavior of the filter regarding the parts to extract.
The syntax and behavior of the directives are the same across all Okapi filters. See the Localization Directives pages for detail information about what you can do with the mechanism.
NOT IMPLEMENTED YET. TODO
Use localization directives when they are present -- Set this option to enable the filter to recognize localization directives. If this option is not set, any localization directive in the input file will be ignored.
Extract items outside the scope of localization directives -- Set this option to extract any translatable item that is not within the scope of a localization directive. Selecting to extract or not outside localization directives allows you to mark up fewer parts of the source document. This option is enabled only when the Use localization directives when they are present option is set.
See the Localization Directives section for more details on how the filter deals with directives.
Use Do-Not-Localize list if a DNL file is present -- Set this
option to enable the filter to utilize any Do-Not-Localize list file found along
with a given input file. The DNL file has the path and name as the input file,
with an additional .dnl
extension. It contains a list of entries
that should not be extracted. Each entry is made of the resname
,
restype
and
text of a filter item. Use the
DNL List Editing
utility to create and maintained DNL files.
Extract standalone strings -- Set this option to extract strings that are not paired with a key, for example strings in an array of strings.
Extract all string values in key-values pairs -- Select this option to extract the string values in all the key+value pairs.
Extract none of the string values in key-values pairs -- Select this option to not extract any of the string values in all the key+value pairs.
Except for the strings with the following key values: -- Enter the list of the key values for which the corresponding strings should be treated the opposite of the default selection you made for the key+value pairs. Enter one value per line. The list is case-sensitive.
For example. If you select Extract all string values in key-values
pairs and enter resourceName
in the list, all strings in
key+value pairs will be extracted, except the ones that have resourceName
as their key value. If you select Extract none of the string values in
key-values pairs and enter label
in the list, none of the
strings in key+value pairs will be extracted, except the ones that have
label
as their key value.
Mark as inline codes the text parts matching this regular expression -- Set this option to use the specified regular expression to be use against the text of the extracted items. Any match will be converted to an inline code. By default the expression is:
((%(([-0+#]?)[-0+#]?)((\d\$)?)(([\d\*]*)(\.[\d\*]*)?)[dioxXucsfeEgGpn]) |((\\r\\n)|\\a|\\b|\\f|\\n|\\r|\\t|\\v) |(\{\d.*?\}))
This matches the C-style printf
variables (e.g. "%s
",
"%2.3f
", "%04X
", "%1$d
", etc.), the escaped sequences:
"\r\n
", "\a
", "\b
",
"\f
", "\n
", "\r
", "\t
", and "\v
",
as well as the Java MessageFormat
patterns (e.g. "{0}
",
"{3,number,integer}
", etc.)
Edit Expression -- Click this button to edit the regular expression and its options. This button opens the Inline Codes Rules dialog box.
See the Regular Expressions section for more information about the syntax and rules for building regular matching patterns.