• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

[HOW TO] Write a basic Localization.txt for your mod

 Hello everyone,

recently I was trying to help another modder who wanted to learn how to write his custom Localization.txt file for his mods. Although the original idea was to give him a quick answer, it turned out to be a little tutorial I thought someone else may find useful, so here it is for everyone:

Think of the content of Localization.txt as if it was the content of a table. As long as you stick to the vanilla format and follow its rules, you should be fine. Always try to match the vanilla format whenever possible.

Following these three simple rules will help you to write your own basic localizations from scratch:

1. First line of Localization.txt is always the table header with all kinds of labels or descriptions for entries below it. In other words, they should give you a hint as to which entry is expected where. This is the first line in vanilla:

Code:
Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish


2. As you can see in this first line, all the entries must be separated by commas thanks to which the game knows where the new entry is and everything after a comma is treated as a new entry. However, what if we needed to write a long text such as item description that may contain several commas that we actually want to show in game? That's what the rule number 2 is all about:

Writing long texts that have to include commas such as item descriptions would normally break the Localization.txt file format. To avoid that issue, the whole entry must be written inside double quotation marks like in the following example:

Code:
"This is one entry in Localization.txt, and this is still the same entry despite being written after the comma! All thanks to being written inside double quotation marks!"


3. Each line in Localization.txt file is considered a new line of entries in the table, so what if we wanted to write a pretty item description with paragraphs instead of showing a wall of text with no paragraphs?

To write a new line inside our text, we need to write a special mark that will tell the game to put the text that follows on a new line. The mark looks like this:

Code:
\n


Example:

Code:
This will be shown on the first line.\nThis will be shown on the second line.
In game this text will look like this:

Code:
This will be shown on the first line.
This will be shown on the second line.


If you wanted to leave one or more lines empty, you would have to put two or more of these marks together.

Example:

This will be shown on the first line.\n\nThis will be shown on the third line.


In game this text will look like this:

This will be shown on the first line.

This will be shown on the third line.




A good rule of thumb is to keep the length of your texts up to 80 characters per line, otherwise your text may show up a little bit broken, not neatly formatted the way you expected. It's because the game seems to put hard-coded line breaks after 80 characters, at least in some cases.

That's it for the basics. There are also some advanced things such as tags you can use inside Localization.txt that help you to show some special values that may be changing in game and it will always show the actual values, such as cvars, but honestly I'm not familiar with those yet, I never really had to use them and it's out of scope of this little tutorial point of which was to explain basics.

I hope this helps at least some of you to get started writing your first basic localizations for your new awesome mods. I hope you enjoyed it and I wish you good luck with your mods!

 
Great stuff here, succinctly explained. Love it.

For returning modders looking to update past work, you might want to note that quest localization no longer has its own file, plus the change to localization being pushed (I think--not playing around with a19 yet).

 
How do you make changes to vanilla Localization in my mod? All I can find is info on adding new items. I made a mod to change crafting perks and I want to modify the Localization in my mod to reflect the changes, but what I have does not change anything.

 Example of the header and one line that I am currently hacking at trying.

key,source,context,changes,english,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish
perkLightArmorRank1LongDesc,progression,perk Agi,"You have started on the path of the lightly armored warrior. Craft quality 3 fair light armor, reduce light armor movement penalty by 15% and stamina penalty by 10%. Improve durability by 50%.\nUnlocks leather armor crafting.",
 
How do you make changes to vanilla Localization in my mod? All I can find is info on adding new items. I made a mod to change crafting perks and I want to modify the Localization in my mod to reflect the changes, but what I have does not change anything.

 Example of the header and one line that I am currently hacking at trying.

key,source,context,changes,english,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish
perkLightArmorRank1LongDesc,progression,perk Agi,"You have started on the path of the lightly armored warrior. Craft quality 3 fair light armor, reduce light armor movement penalty by 15% and stamina penalty by 10%. Improve durability by 50%.\nUnlocks leather armor crafting.",
Apparently you didn't read the advices I wrote in the OP. Commas between the individual entries are there for a reason! Please refer to the line in vanilla Localization.txt starting with perkLightArmorRank1LongDesc and compare it to your own. The difference is the reason why it didn't work for you.

 
Thank you,

  Do you mean quotation marks? I used commas and quotation marks but I did not understand how the header list related to the body lines.

  I got it working by cutting it down to only the header entries of:

Key,File,Type,english,
perkLightArmorRank1LongDesc,progression,perk Agi,"You have started on the path of the lightly armored warrior. Craft quality 3 fair light armor, reduce light armor movement penalty by 15% and stamina penalty by 10%. Improve durability by 50%.\nUnlocks leather armor crafting.",

 
Last edited by a moderator:
Do you mean quotation marks? I used commas and quotation marks but I did not understand how the header list related to the body lines.


This is explained in OP:

Think of the content of Localization.txt as if it was the content of a table. As long as you stick to the vanilla format and follow its rules, you should be fine. Always try to match the vanilla format whenever possible.


Your original table didn't work, because the body of the table didn't match the header. It's really that simple, I can't really think of any other way to explain it to you...

Again, it's a table with columns and rows, so naturally the body of the table must match the header, not only in sense of the meaning of individual entries, but also in number of entries. The latter is done using commas which are there to let the game know that it's a new entry in the table. If you need to use a comma inside the entry, you have to mark the start and end of the entry with quotation marks like so: "<TABLE ENTRY GOES HERE>", because any comma outside quotation marks is considered a delimiter between table entries.

Your new table is also wrong as it's contains a comma after english and the entry with the perkLightArmorRank1LongDesc key also ends with a comma. Why did you leave those commas there? It's unnecessary and doesn't match the vanilla format.

Always try to match the vanilla format whenever possible.


I can't stress this enough. You may think that if it works, it doesn't need fixing, but then you will run into other issues if you ignore the way vanilla file is constructed and you will have no clue what went wrong again...

 
t63trQ5.jpg


I'm looking at adding 5.56mm ammo.. or rather have.  Issue I'm having is if I copy ammo762mmBulletBallDesc line into my localization.txt and change it from ammo762mmBulletBallDesc to ammo556mmBulletBallDesc in-game I get quite literally "ammo556mmBulletBallDesc" as the description.... everything else in the line is vanilla.

I'm unsure what I'm doing wrong?

Update:  Apparently it's required to have that first line that defines the table.  Once I had that as the first line in mine it now works properly.  (fixed my invisible icons too lol).   It may be worth putting in your OP that you need that first line that defines the table else it doesn't function when pushed.

Thanks for the guide!

 
Last edited by a moderator:
Hello i have been making a code adding a lot but for my Recipes it will have the picture of the custom item But will not give me the name of the ingredient EG below:
unknown issue.png
If anyone is to help me figure this out I would greatly appreciate it.

 
Hi there @Gouki yes i have a localization file i just have no idea who to write it
i have got my custom items with Desc and custom names for when hovering over them i just been trying to figure out how the code is written for a Recipes window.

thank so much for taking an interest in my issue

 
Last edited by a moderator:
Turns out the Materials_based="true" was the issue  fixed it now :D


yes, materials_based = "true" is implemented to work only in forge recipes.
Good that you have solved that problem.
For the location here is an example:

Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish
TitaniumBars,items,Item,,,Barras de Titanio
TitaniumBarsDesc,items,Item,,,"Mas fuertes que las barras de acero"
TitaniumBarsSchematic,items,item,,,Esquema de Barras de Titanio

Hope that helps you.

Regards

 
Last edited by a moderator:
 Hello everyone,

recently I was trying to help another modder who wanted to learn how to write his custom Localization.txt file for his mods. Although the original idea was to give him a quick answer, it turned out to be a little tutorial I thought someone else may find useful, so here it is for everyone:

Think of the content of Localization.txt as if it was the content of a table. As long as you stick to the vanilla format and follow its rules, you should be fine. Always try to match the vanilla format whenever possible.

Following these three simple rules will help you to write your own basic localizations from scratch:

1. First line of Localization.txt is always the table header with all kinds of labels or descriptions for entries below it. In other words, they should give you a hint as to which entry is expected where. This is the first line in vanilla:

Code:
Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish


2. As you can see in this first line, all the entries must be separated by commas thanks to which the game knows where the new entry is and everything after a comma is treated as a new entry. However, what if we needed to write a long text such as item description that may contain several commas that we actually want to show in game? That's what the rule number 2 is all about:

Writing long texts that have to include commas such as item descriptions would normally break the Localization.txt file format. To avoid that issue, the whole entry must be written inside double quotation marks like in the following example:

Code:
"This is one entry in Localization.txt, and this is still the same entry despite being written after the comma! All thanks to being written inside double quotation marks!"


3. Each line in Localization.txt file is considered a new line of entries in the table, so what if we wanted to write a pretty item description with paragraphs instead of showing a wall of text with no paragraphs?

To write a new line inside our text, we need to write a special mark that will tell the game to put the text that follows on a new line. The mark looks like this:

Code:
\n


Example:

Code:
This will be shown on the first line.\nThis will be shown on the second line.
In game this text will look like this:

Code:
This will be shown on the first line.
This will be shown on the second line.


If you wanted to leave one or more lines empty, you would have to put two or more of these marks together.

Example:

This will be shown on the first line.\n\nThis will be shown on the third line.


In game this text will look like this:

This will be shown on the first line.

This will be shown on the third line.




A good rule of thumb is to keep the length of your texts up to 80 characters per line, otherwise your text may show up a little bit broken, not neatly formatted the way you expected. It's because the game seems to put hard-coded line breaks after 80 characters, at least in some cases.

That's it for the basics. There are also some advanced things such as tags you can use inside Localization.txt that help you to show some special values that may be changing in game and it will always show the actual values, such as cvars, but honestly I'm not familiar with those yet, I never really had to use them and it's out of scope of this little tutorial point of which was to explain basics.

I hope this helps at least some of you to get started writing your first basic localizations for your new awesome mods. I hope you enjoyed it and I wish you good luck with your mods!
Can you update your guide and add the "Key,English" way?

 
It may be worth putting in your OP that you need that first line that defines the table else it doesn't function when pushed.


It's already there in the rule number 1 with an example. I'm sorry, but I can't think of any better way how to explain it...

1. First line of Localization.txt is always the table header


  ...

Can you update your guide and add the "Key,English" way?
I am aware of the flexibility of the format of this file, but this was meant to be a short guide for beginners to teach the players how to format their first basic localization.txt file and how to make one quickly with as few errors as possible. The reason why I'm encouraging them to stick with the vanilla format is simply that there's always an example in vanilla localization.txt file, so if they ever get stuck, they could simply check out the vanilla file again, but if they decide to go with their custom format, they will be on their own with no example they could follow. Therefore adding something like this may be counter-productive. As you can see, some people find it difficult to even understand the vanilla format. If I added another option to the guide, they could be confused even more and make more mistakes.

 
Last edited by a moderator:
It's already there in the rule number 1 with an example. I'm sorry, but I can't think of any better way how to explain it...

  ...

I am aware of the flexibility of the format of this file, but this was meant to be a short guide for beginners to teach the players how to format their first basic localization.txt file and how to make one quickly with as few errors as possible. The reason why I'm encouraging them to stick with the vanilla format is simply that there's always an example in vanilla localization.txt file, so if they ever get stuck, they could simply check out the vanilla file again, but if they decide to go with their custom format, they will be on their own with no example they could follow. Therefore adding something like this may be counter-productive. As you can see, some people find it difficult to even understand the vanilla format. If I added another option to the guide, they could be confused even more and make more mistakes.
"Key,English" format is easier and better, because you don't have to write a lot of useless text you skip anyway

 
Last edited by a moderator:
"Key,English" format is easier and better, because you don't have to write a lot of useless text you skip anyway
This is an understatement of the vanilla format of localization.txt file. This is the same as if you said that you don't need a manual to assemble a chair from the parts, then you throw out some of the parts because you have no idea where they are supposed to go and as soon as you sit on it, it breaks.

Going with the simple format is neither easier nor better. Just because it seems to work even if you throw out some part of it doesn't mean that it's better, it just means that you don't understand the purpose of the part that you just threw out and you still might need it later.

Besides, what might seem as easier to you may seem more confusing to others who don't really know what are they doing, because they are still learning their way through this. Some people prefer a simple solution that would allow them to quickly copy and paste the lines they already have at their disposal (in vanilla file) and make some changes to them to repurpose them for their mod rather than trying to write their own lines from scratch, not really knowing how to do it correctly.

Ultimately, people first need to learn the vanilla format to understand how it works and how to do some changes to it safely without breaking it and this little guide is for them.

The knowledge how to simplify it comes along with it automatically, if they ever wanted to go that way.

 
Just an FYI for those people who actually want to do localization for their modlets, and not just add English entries...

I found this online tool helpful. It will translate English text into multiple languages at once:

https://smodin.me/translate-one-text-into-multiple-languages

I can't vouch for the quality of the translations. But, IMHO, something is usually better than nothing.

If anyone else knows of better translation services, then feel free to post them here.

 
After a glance at that site, I can kind of vouch for the quality, but not in a good way. Let's put it this way--in the interface, their translation of "Japanese" is "Japanese person" as opposed to "Japanese language." Context is hard, and I'm sure it probably works better for Romance languages, but the old adage of "Write what you know" goes double for translating. Best possible outcome: unintentional hilarity. Worst possible outcome: WWIII?

 
After a glance at that site, I can kind of vouch for the quality, but not in a good way. Let's put it this way--in the interface, their translation of "Japanese" is "Japanese person" as opposed to "Japanese language." Context is hard, and I'm sure it probably works better for Romance languages, but the old adage of "Write what you know" goes double for translating. Best possible outcome: unintentional hilarity. Worst possible outcome: WWIII?


You forget that this best outcome is actually the best outcome possible. If you give the word "japanese" to a translation service and do not supply a context by hand then even a human translator could not do better.

Asian companies have done this automatic translations of their product manuals for ages and it worked (i.e. they got to sell that stuff in the west, it was cheap for them and it did not start WWIII).

 
Back
Top