Supported File Types (Strings)

.JSON - React-Intl Simple (Strings)

Content is machine translated from English by Phrase Language AI.

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.

Plurals for JSON files

The most common format of plural key messages on various libraries:

"messages": {
    "one": "One message received.",
    "other": "%s messages received.",
    "zero": "No messages received."
}
Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.