• 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!

 
Does anyone know what happens if you override a vanilla entry in localization.txt but only provide an English translation?

For example, the vanilla 7D2D localization.txt file has this entry:

quest_BasicSurvival1,Quest,Quest Info,,,Basic Survival 1/8,,Das 1x1 des Überlebens 1/8,Supervivencia básica 1/8,Les bases de la survie 1/8,Basi della sopravvivenza 1/8,生き残るための基礎知識 1/8,기본 생존 1/8,Podstawy przetrwania 1/8,Sobrevivência Básica 1/8,Основы выживания 1/8,Temel Hayatta Kalma 1/8,基础生存 1/8,基本生存 1/8,Supervivencia básica 1/8




Let's say you wanted to insert a basic survival quest before that one, so that it is now 2 of 9. What happens if you supply this?

quest_BasicSurvival1,Quest,Quest Info,,,Basic Survival 2/9,,,,,,,,,,,,,,




Do non-English speakers still see the "1/8" text? Or does the game assume there is no localized text for that language, and display the English text?

 
Quick update. It looks like the site I suggested (smodin.me) doesn't really work any more.

But I found an even easier option.

If anyone uses Google Sheets, it turns out that Google has included a function to translate cells automatically. Why does this matter? Because, basically, Localization.txt is just a renamed CSV file ("comma separated values"). Those can be imported and exported by pretty much any spreadsheet software, Google Sheets included.

To translate a cell, just enter this formula:

=GoogleTranslate(F2, "en", "de")




...where "F2" is the cell you're translating, and "de" is the language code for the translation ("de" is German). If you copy a formula to another cell, the reference to the original cell ("F2") gets updated. You can easily copy a formula to other cells by double-clicking on the little square icon in the bottom right corner when you select a cell with a formula in it.

EDIT: That is assuming that your original language is English. If you're translating from another language, put in that language code instead of "en" - and make sure you also put that formula into the place where the English version goes.

So, you can set up a template with those formulas entered for every language that 7D2D supports. Copy that template, add the relevant information into your spreadsheet (the key, the English original text, etc.) and export the whole thing as a CSV file. Then rename that file to Localization.txt.

Bingo bango - you now have a modlet that has all the translations for all your text, not just English.

I've already used this and it's stupid simple. You do sometimes get errors - I suspect Google is throttling the translation services - but reloading the spreadsheet fixes them in my experience.

Microsoft also has translation services, so there's probably some similar functionality for Excel, but I don't use Excel.

EDIT 2: To make things easier, here's a link to the Google Sheet that I use as a template. Anyone with this link should be able to view it, but not modify it (and if I'm wrong... please don't modify it).

https://docs.google.com/spreadsheets/d/1UzO2_8ahCbOYD9buwP_yNDlXNXSeW6ysR3cascG1gr0/edit?usp=sharing

 
Last edited by a moderator:
Quick update. It looks like the site I suggested (smodin.me) doesn't really work any more.

But I found an even easier option.

If anyone uses Google Sheets, it turns out that Google has included a function to translate cells automatically. Why does this matter? Because, basically, Localization.txt is just a renamed CSV file ("comma separated values"). Those can be imported and exported by pretty much any spreadsheet software, Google Sheets included.

To translate a cell, just enter this formula:

=GoogleTranslate(F2, "en", "de")




...where "F2" is the cell you're translating, and "de" is the language code for the translation ("de" is German). If you copy a formula to another cell, the reference to the original cell ("F2") gets updated. You can easily copy a formula to other cells by double-clicking on the little square icon in the bottom right corner when you select a cell with a formula in it.

EDIT: That is assuming that your original language is English. If you're translating from another language, put in that language code instead of "en" - and make sure you also put that formula into the place where the English version goes.

So, you can set up a template with those formulas entered for every language that 7D2D supports. Copy that template, add the relevant information into your spreadsheet (the key, the English original text, etc.) and export the whole thing as a CSV file. Then rename that file to Localization.txt.

Bingo bango - you now have a modlet that has all the translations for all your text, not just English.

I've already used this and it's stupid simple. You do sometimes get errors - I suspect Google is throttling the translation services - but reloading the spreadsheet fixes them in my experience.

Microsoft also has translation services, so there's probably some similar functionality for Excel, but I don't use Excel.

EDIT 2: To make things easier, here's a link to the Google Sheet that I use as a template. Anyone with this link should be able to view it, but not modify it (and if I'm wrong... please don't modify it).

https://docs.google.com/spreadsheets/d/1UzO2_8ahCbOYD9buwP_yNDlXNXSeW6ysR3cascG1gr0/edit?usp=sharing
Hello, thank you very much for your translation method. I have a new question. When I import the text, the quotes disappear automatically. How do you solve it?

 
Hello, thank you very much for your translation method. I have a new question. When I import the text, the quotes disappear automatically. How do you solve it?


You should be able to escape a double quote symbol by preceding it with another double quote symbol:

Code:
"He said, ""Hello, world!"" to me."
That should show on screen as:

Code:
He said, "Hello, world!" to me.


EDIT: If you're using Google Sheets, I thought it would do this for you automatically. I never tested it though.

 
Last edited by a moderator:
You should be able to escape a double quote symbol by preceding it with another double quote symbol:

Code:
"He said, ""Hello, world!"" to me."
That should show on screen as:

Code:
He said, "Hello, world!" to me.


EDIT: If you're using Google Sheets, I thought it would do this for you automatically. I never tested it though.
OK, thank you for your reply

 
Back
Top