|
File Extensions |
.json |
|
API Extension |
react_simple_json |
|
Import |
Yes |
|
Export |
Yes |
|
Plural forms support |
Yes |
|
Description support |
Yes, with default message extraction. |
React-Intl is a JavaScript library designed to simplify internationalization (i18n) and (localization) primarily for applications developed in React. By default, React-Intl uses .js files to store its localized content. Localized content is decoupled into a standardized .JSON file (React-Intl Simple JSON) to be referenced in source code.
If using nested messages, use the React-Intl Nested JSON format. This is deprecated in React Intl v2.
AI chatbots can be very effective at generating a list of keys from a .JSON file.
Code Sample
{
"boolean_key": "--- true\n",
"empty_string_translation": "",
"key_with_description": "Check it out! This key has a description! (At least in some formats)",
"key_with_line-break": "This translations contains\na line-break.",
"nested.deeply.key": "I'm a deeply nested key.",
"nested.key": "This key is nested inside a namespace.",
"null_translation": null,
"pluralized_key.one": "Only one kitten found.",
"pluralized_key.other": "Wow, you have %s kittens!",
"pluralized_key.zero": "You have no kittens.",
"sample_collection": [
"first item",
"second item",
"third item"
],
"simple_key": "Simple key, simple message, so simple.",
"unverified_key": "This translation is not yet verified and waits for it. (In some formats we also export this status)"
}
Using React Intl
Translations normally reside in a .js file:
module.exports = {
"locales": ["en-US"],
"messages": {
"hello" : "World",
other_hello : 'Other World',
},
"formats": {}
};
Move messages into a separate locale file, e.g. en-US.json:
{
"hello" : "World",
other_hello : 'Other World',
}
Ensure messages have valid .JSON syntax:
{
"hello" : "World",
"other_hello" : "Other World"
}
Include the messages with a require statement:
module.exports = {
"locales": ["en-US"],
"messages": require('./en-US.json'),
"formats": {}
};
React-Intl Simple JSON format can now be used to upload/download React Intl locale files.