For us to modify an existing language file, we first need to open Minecraft in the version we want to work with, in my case; 1.18.1.
After this, we open the Options menu and then click on 'Language', then we select the language we want to edit, in my case, it will be English (US), therefore I don't have to do anything else.
We can now close Minecraft and extract the 'lang' folder from the assets, this folder will now contain the chosen language files we loaded in Minecraft before.
(Learn how here).
The name of the file will depend on the language chosen, the letters to the left of the underscore mean the language code while the ones to the right of it mean the country code (Complete list of languages here).
The .json file is structured very simply, let's take a look at an example:
{
"block.minecraft.stone": "Stone",
"block.minecraft.dirt": "Dirt"
}
We can see many things, first; the whole thing is wrapped between brackets, so that's the first thing we need to make sure of, that at the start and the end of the file there are opening and closing brackets respectively.
Another thing we can notice is how there is a name on the left, and one on the right. The one on the left is the coded name of the element, in this case, a stone block; the one on the right however, is how the element name displays in-game.
Also, you probably noticed there's a comma at the end of "Stone" but not at the end of "Dirt", the reason is to let the file know if there are more elements after a line, in this case, dirt is the last line so it doesn't have a comma.
We can change the color of the text in any element of the language file, of course, always on the right side and within the quotation marks. The default color is white, but this can easily be overwritten by adding the § symbol and the color character we want. (Color codes)
Aside from editing an existing language, we can create our own to be selected from the available language in the game. To do this, we first need to duplicate the language file we extracted before (in my case 'en_us.json')..
After this, we have the bases for our new language, but we still need to give it a name, we start with two characters, let's use 'pb' for example, then add an underscore and any other two characters of your choosing, for example, 'ev', the name of our file should be 'pb_ev.json'.
Now we can open the file and edit it as usual. After we're done, we need to edit our pack.mcmeta to add our new language to the list, to do this, we simply open our pack.mcmeta file and add this code:
"language": {
"LANG_COUNTRY": {
"name": "❬Name of the language❭",
"region": "❬Name of the region/country❭",
"bidirectional": ❬true/false❭
}
}
Therefore, our pack.mcmeta should look something like this:
{
"pack": {
"pack_format": ❬version_number❭,
"description": "❬Description❭"
},
"language": {
"LANG_COUNTRY": {
"name": "❬Name of the language❭",
"region": "❬Name of the region/country❭",
"bidirectional": ❬true/false❭
}
}
}
After we have this, we replace '❬Name of the language❭' with the name of our language, in my case 'My Language', and then replace '❬Name of the region/country❭' with the name of the country or region, in my case, it'll be 'Enhanced Vanilla' because it isn't any country. About the bidirectional part, the value 'true' is for languages written right to left (like Arabic) and false is for languages written left to right (default).