MDN/Development/CompatibilityTables/Translation: Difference between revisions

→‎Localizing API Strings: Add example of converting a raw data to JSON API
(Draft)
 
(→‎Localizing API Strings: Add example of converting a raw data to JSON API)
Line 133: Line 133:
* All current locales and translations must be included, or they will be removed.
* All current locales and translations must be included, or they will be removed.
* You can just include the attribute you are changing, and other omitted attributes will be untouched.
* You can just include the attribute you are changing, and other omitted attributes will be untouched.
* Whitespace doesn't matter, which can help when converting to the default raw data format to the JSON API format.
For example, the raw version looks like this:
<pre>
{
    "id": 6,
    "slug": "firefox_desktop",
    "name": {
        "en": "Firefox for Desktop",
        "fr": "Firefox pour PC de bureau"
    },
    "note": null,
    "history": [
        38,
        37,
        29,
        20,
        19,
        18,
        17,
        16,
        6
    ],
    "history_current": 38,
    "versions": [
        67,
        68,
        69,
        72,
        ...
    ]
}
</pre>
Delete all but the <code>name</code> section...
<pre>
    "name": {
        "en": "Firefox for Desktop",
        "fr": "Firefox pour PC de bureau"
    },
</pre>
Remove the trailing comma:
<pre>
    "name": {
        "en": "Firefox for Desktop",
        "fr": "Firefox pour PC de bureau"
    }
</pre>
And then wrap it in a resource for the JSON API format:
<pre>
{"browsers": {
    "name": {
        "en": "Firefox for Desktop",
        "fr": "Firefox pour PC de bureau"
    }
}}
</pre>
In the future, the default Raw Data format will be the JSON API format, making this easier.  And, shortly after, we'll have a web-based contribution interface which makes translations a lot easier.


=== Finding resources for a page ===
=== Finding resources for a page ===
''to do''
''to do''
67

edits