Adding a New Language

Adding a new language to your message.json file should be a simple process, as long as you have someone that can translate for you. If needed, our default message.json file already supports the languages that have a ✅ beside them. You can get the file here. If you wish to add your own languages instead, we will now show you how to! First we need to go to our message.json file, then we can now take a look at the primary property. "en". What is that? Well, it's an ISO 639-1 Code, like mentioned before. It's the standard way to list languages in a two character format. Each new language that you add will be a new ISO code in your message.json file.

// ./message.json
{
"en": {
...defaultValues,
"TESTING": "This is a response from the message.json file!"
}
}

So we have our values all stored in our message.json file like shown above, pretty simple layout, and only one extra property. Now, when creating a new language, it is recommended that you translate all of the same values from one language to the other language, or else you will most likely encounter errors or unwanted behaviour. To add the new language it's as easy as adding a new property to the file like so.

// ./message.json
{
"en": {
...defaultValues,
"TESTING": "This is a response from the message.json file!"
},
"es": {
...defaultValues_translated,
"TESTING": "¡Esta es una respuesta del archivo message.json!"
}
}

The above translation was done using Google Translate, so it may not be entirely accurate, but you should get the idea. We added a new language, in this case Spanish (es), and added all of the properties that English had and translated them into Spanish. You can add as many language codes as you want as long as you can translate every property value into the other language.