67
edits
m (Jwhitlock moved page MDN/Development/CompatibilityTables/i18n to MDN/Development/CompatibilityTables/Translation: i18n is not as searchable) |
(→API Localized Strings: Add instructions for finding strings that require translation) |
||
Line 210: | Line 210: | ||
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. | 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. | ||
=== | === Localizing an MDN page === | ||
' | When building a MDN page, the <code>view_features</code> interface is used. For example, the macro that place the API-backed table on [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility Promise] is: | ||
<pre> | |||
{{ EmbedCompatTable("web-javascript-reference-global_objects-promise") }} | |||
</pre> | |||
The API endpoint is: | |||
https://browsercompat.herokuapp.com/api/v1/view_features/web-javascript-reference-global_objects-promise | |||
if you want to force the JSON version, you can go to: | |||
https://browsercompat.herokuapp.com/api/v1/view_features/web-javascript-reference-global_objects-promise | |||
Translating the page involves: | |||
# Find resources with strings needing translation in <code>view_features</code> | |||
# Using the above procedure to translate the resource | |||
# Force-refreshing the MDN page to call the API and regenerate the API-backed table. | |||
For example, if you search for the string <code>"en"</code> (<code>en</code> wrapped in quotes), you'll find some already translated strings (<code>features.mdn_uri</code> and <code>features.name</code> for the main feature), as well as some untranslated strings: | |||
<pre> | |||
... | |||
"linked": { | |||
"browsers": [ | |||
{ | |||
"id": "1", | |||
"slug": "android", | |||
"name": { | |||
"en": "Android Browser" | |||
}, | |||
"note": null, | |||
"links": { | |||
"history": [ | |||
"26", | |||
"1" | |||
], | |||
"history_current": "26" | |||
} | |||
}, | |||
... | |||
</pre> | |||
Most will be in the <code>linked</code> section, which are a list of resources linked to the main feature. Once you find a resource that needs translation, go to the browsable API for that resource (in this case, https://browsercompat.herokuapp.com/api/v1/browsers/1), and follow the above procedure to translate the string. | |||
You can refresh the <code>view_features</code> endpoint to confirm that the strings are translated. Once you are happy with the translations, force-refresh the MDN page to regenerate the API-backed table. | |||
In the future, code will be able to determine if a <code>view_feature</code> endpoint contains untranslated strings for a locale, and a web-based contribution interface will make it easier to translate the needed strings. | |||
In the future, the |
edits