mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-04-29 21:18:10 +08:00
* initial implementation suggestion * basic supported features snippets generation * Add API identifiers, read-only strings and common extensions to features table * generate doc features snippet files * autogenerated snippets cleanup * changelog update * delete one file to test auto-update * replace SUPPORTS_FUZZY with file format additional_states flag * docs: Documentation snippets update * fix include statetement typo * fix incorrect monolingual attributes * minor styling change * docs: Documentation snippets update * exclude snippets from being treated as standalone documents * Set YAMLFormat as both mono/bilingual * docs: Documentation snippets update * fix duplicate format IDs * only use backwards quotes for literals --------- Co-authored-by: gersona <6675010+gersona@users.noreply.github.com> Co-authored-by: Michal Čihař <michal@weblate.org>
91 lines
2.7 KiB
ReStructuredText
91 lines
2.7 KiB
ReStructuredText
.. _json:
|
|
|
|
JSON files
|
|
----------
|
|
|
|
.. index::
|
|
pair: JSON; file format
|
|
|
|
.. versionchanged:: 4.3
|
|
|
|
The structure of JSON file is properly preserved even for complex
|
|
situations which were broken in prior releases.
|
|
|
|
JSON format is used mostly for translating applications implemented in
|
|
JavaScript.
|
|
|
|
Weblate currently supports several variants of JSON translations:
|
|
|
|
* Simple key / value files, used for example by `vue-i18n` or `react-intl`.
|
|
* Files with nested keys.
|
|
* :ref:`js-i18next`
|
|
* :ref:`go-i18n-json`
|
|
* :ref:`gotext-json`
|
|
* :ref:`webex`
|
|
* :ref:`arb`
|
|
* :doc:`/formats/resjson`
|
|
* :doc:`/formats/nextcloud-json`
|
|
|
|
JSON translations are usually monolingual, so it is recommended to specify a base
|
|
file with (what is most often the) English strings.
|
|
|
|
.. hint::
|
|
|
|
The :guilabel:`JSON file` and :guilabel:`JSON nested structure file` can
|
|
both handle same type of files. Both preserve existing JSON structure when
|
|
translating.
|
|
|
|
The only difference between them is when adding new strings using Weblate.
|
|
The nested structure format parses the newly added key and inserts the new
|
|
string into the matching structure. For example ``app.name`` key is inserted as:
|
|
|
|
.. code-block:: json
|
|
|
|
{
|
|
"app": {
|
|
"name": "Weblate"
|
|
}
|
|
}
|
|
|
|
.. seealso::
|
|
|
|
* :doc:`tt:formats/json`
|
|
* :ref:`updating-target-files`
|
|
* :ref:`addon-weblate.json.customize`
|
|
* :ref:`addon-weblate.cleanup.generic`
|
|
|
|
Example files
|
|
+++++++++++++
|
|
|
|
Example file:
|
|
|
|
.. literalinclude:: ../../weblate/trans/tests/data/cs.json
|
|
:language: json
|
|
|
|
Nested files are supported as well (see above for requirements), such a file can look like:
|
|
|
|
.. literalinclude:: ../../weblate/trans/tests/data/cs-nested.json
|
|
:language: json
|
|
|
|
.. include:: /snippets/format-features/json-features.rst
|
|
|
|
Weblate configuration
|
|
+++++++++++++++++++++
|
|
|
|
+-------------------------------------------------------------------+
|
|
| Typical Weblate :ref:`component` |
|
|
+================================+==================================+
|
|
| File mask | ``langs/translation-*.json`` |
|
|
+--------------------------------+----------------------------------+
|
|
| Monolingual base language file | ``langs/translation-en.json`` |
|
|
+--------------------------------+----------------------------------+
|
|
| Template for new translations | `Empty` |
|
|
+--------------------------------+----------------------------------+
|
|
| File format | `JSON nested structure file` |
|
|
+--------------------------------+----------------------------------+
|
|
|
|
|
|
File format parameters
|
|
++++++++++++++++++++++
|
|
|
|
:ref:`file_format_params` with the pattern `json_*` can be used to configure the behavior of the JSON format.
|