React-Intl Simple JSON

Manage React Intl locale files in PhraseApp

File Extensions .json
API Extension react_simple_json
Format Options No
Import Yes
Export Yes
Pluralization supported? Yes
Descriptions/Comments supported? No

Example

{
  "app_title":"My Software Project",
  "greeting":"Hello 'User'!\nHow are you doing today?"
}

You can import and export locale files for React Intl projects by extracting your messages into separate JSON files which translate to the “React-Intl Simple JSON” format in PhraseApp.

How to use React Intl with PhraseApp

Typically your translations reside in a .js file like this:

module.exports = {
    "locales": ["en-US"],
    "messages": {
        "hello" : "World",
        other_hello : 'Other World',
    },
    "formats": {}
};

Move your messages into a separate locale file, e.g. en-US.json:

{
    "hello" : "World",
    other_hello : 'Other World',
}

Make sure the messages are valid JSON syntax:

{
    "hello" : "World",
    "other_hello" : "Other World"
}

See the official JSON guidelines for more information how to convert your file to valid JSON. You can also use the JSON linter to check if your JSON files are valid.

Now, include the messages with a require statement:

module.exports = {
    "locales": ["en-US"],
    "messages": require('./en-US.json'),
    "formats": {}
};

You can now use the React-Intl Simple JSON format to upload/download your React Intl locale files

Nested Messages

If you’re using nested messages please use the React-Intl Nested JSON format instead. Note that this is deprecated in React Intl v2.


Further Reading

  • React-Intl Nested JSON Format
  • React Intl
  • FormatJS