Jump to content

How do I write a custom localization file for a mod?


Noisy Pants

Recommended Posts

I made a mod that I would like to write a localization file for since it is otherwise confusing to players that see it. I found a hint yet it didn't help regarding writing localization files for mods especially since this is a oddball. I took a cube of water and tweaked it. The picture shows how far I got, the stuff between the arrows is a rough draft of the description I want to use.
Electric Eel Trap
 

localization.JPG

Link to comment
Share on other sites

8 hours ago, Noisy Pants said:

I made a mod that I would like to write a localization file for since it is otherwise confusing to players that see it. I found a hint yet it didn't help regarding writing localization files for mods especially since this is a oddball. I took a cube of water and tweaked it. The picture shows how far I got, the stuff between the arrows is a rough draft of the description I want to use.
Electric Eel Trap
 

localization.JPG

Hi

 

This is the way I use it to appear in Spanish, I guess it works for English language.

 

Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish
stonePickaxe,items,item,,,Pico de piedra


Or you can do it this other way.

 

Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,latam,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese,spanish
stonePickaxe,items,item,new,Stone Pick,,,,,

Link to comment
Share on other sites

Like Gouki said.

 

Just take a look at the vanilla localization, or the localization for any mod if you're having issues, but all of mine are like this:

 

Key,File,Type,UsedInMainMenu,NoTranslate,english
FRK_Coop,Blocks,block,,,Chicken Coop
FRK_Coop_Desc,Blocks,block,,,"Generate your own Eggs and feathers!\n\nUnlocked with the 'Living off the Land' perk."
FRK_Coop_Full,Blocks,block,,,Full Chicken Coop

 

 

 

Link to comment
Share on other sites

Imagine 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.

 

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:

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:

"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:

\n

 

Example:

This will be shown on the first line.\nThis will be shown on the second line.

In game this text will look like this:

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 your texts 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.

 

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 don't know how to use them, I never really had to and it's out of scope of this little tutorial point of which was to explain basics.

 

I hope this helps, enjoy and good luck!

Link to comment
Share on other sites

6 minutes ago, Reckis said:

@mr.devolver I don't know if that helped the OP, but I appreciate it immensely!

 

Now if I could just get someone to tell how to make a modlet look at the correct localization file, or if that happens automatically when you rename flags(?). In @FreakUK 's example above the FRK_Coop.

 

I'm not sure what did you mean by renaming the flags, but there is no other localization file than Localization.txt. All your localization entries related to your mod should go there and game opens this file and works with the entries there automatically, granted you use their key references in your modlet in the first place!

Link to comment
Share on other sites

mr. devolver, your information is awesome! I'm a visual learner so there is a few things I can't figure out since I put this mod together myself by trial and error - this mod is a product of "wow, look at that! it works!". I don't see anyone using this an I believe it's due to the lack of information. I'm figuring this all out with this forum, search engines, and an overheating thinking cap.

<config>
    <append xpath="/blocks">
                
        <block name="Electric Eel Trap">
            <property name="CreativeMode" value="Player"/>
            <property name="CustomIcon" value="Electric Eel Trap"/>
            <property name="Class" value="Liquidv2"/>
            <property name="Material" value="Mwater"/>
            <property name="Shape" value="Water"/>
            <property name="Mesh" value="water"/>
			<property name="DescriptionKey" value="Electric Eel Trap Desc"/>
            <property name="Model" value="water_full"/>
            <property name="Texture" value="223"/>
            <property name="Map.Color" value="0,0,0"/>
            <property name="Map.Color" value="0,0,0"/>
            <property name="BuffsWhenWalkedOn" value="buffShocked"/>
			<property name="BuffChance" value="1"/>
            <property name="Path" value="solid"/>
			<property name="Collide" value="movement"/>
            <property name="Group" value="Tools/Traps,Science,Chemicals,CFChemicals"/>
			<property name="EconomicValue" value="150"/>
            <property name="SortOrder1" value="70g0"/>
            <property name="FilterTags" value="fdecor,felectrical,ftraps"/>
        </block>
        
    </append>
</config>

As you can see I have the "<property name="DescriptionKey" value="Electric Eel Trap Desc"/>" in the code, using that I made this:
 

Quote

Key,File,Type,UsedInMainMenu,NoTranslate,english
Electric Eel Trap,Blocks,block,,,Electric Eel Trap
Electric Eel Trap Desc,Blocks,block"Unlock at level 3 Advanced Engineering.\n\Must be utilized in a container or moat of cube blocks of your choice."

if i understand correctly this is how it works: Electric Eel Trap is in the Electric Eel Trap mod folder, from there I follow the hierarchy regarding this line:  "Electric Eel Trap,Blocks,block,,,Electric Eel Trap"
next use the code from within the block code that says "Electric Eel Trap Desc" as a hook to introduce a description which i attempted yet failed

20200905005642_1.jpg

Link to comment
Share on other sites

26 minutes ago, Noisy Pants said:

mr. devolver, your information is awesome! I'm a visual learner so there is a few things I can't figure out since I put this mod together myself by trial and error - this mod is a product of "wow, look at that! it works!". I don't see anyone using this an I believe it's due to the lack of information. I'm figuring this all out with this forum, search engines, and an overheating thinking cap.


<config>
    <append xpath="/blocks">
                
        <block name="Electric Eel Trap">
            <property name="CreativeMode" value="Player"/>
            <property name="CustomIcon" value="Electric Eel Trap"/>
            <property name="Class" value="Liquidv2"/>
            <property name="Material" value="Mwater"/>
            <property name="Shape" value="Water"/>
            <property name="Mesh" value="water"/>
			<property name="DescriptionKey" value="Electric Eel Trap Desc"/>
            <property name="Model" value="water_full"/>
            <property name="Texture" value="223"/>
            <property name="Map.Color" value="0,0,0"/>
            <property name="Map.Color" value="0,0,0"/>
            <property name="BuffsWhenWalkedOn" value="buffShocked"/>
			<property name="BuffChance" value="1"/>
            <property name="Path" value="solid"/>
			<property name="Collide" value="movement"/>
            <property name="Group" value="Tools/Traps,Science,Chemicals,CFChemicals"/>
			<property name="EconomicValue" value="150"/>
            <property name="SortOrder1" value="70g0"/>
            <property name="FilterTags" value="fdecor,felectrical,ftraps"/>
        </block>
        
    </append>
</config>

As you can see I have the "<property name="DescriptionKey" value="Electric Eel Trap Desc"/>" in the code, using that I made this:
 

if i understand correctly this is how it works: Electric Eel Trap is in the Electric Eel Trap mod folder, from there I follow the hierarchy regarding this line:  "Electric Eel Trap,Blocks,block,,,Electric Eel Trap"
next use the code from within the block code that says "Electric Eel Trap Desc" as a hook to introduce a description which i attempted yet failed

20200905005642_1.jpg

So you're a visual learner, I see. I'm sorry, I can't provide a better visual representation of it, but you almost got it right, so let's just try some quick additional explanation as well as some little adjustments of the file and see where it goes from there...

 

Maybe I should also update my explanation in the previous post, for future reference...

 

First of all, your key references use spaces in their names. This is a big NO NO. Why? Because they are treated like a regular text by game. You can actually write the names and descriptions directly into the xml files, but that kinda defeats the purpose of using Localization.txt, where you can use different translations, so that the players can be always presented with the language they use, right? So the first thing you might want to do is change your key reference names to not cointain any spaces. For example, Electric Eel Trap will be ElectricEelTrap and Electric Eel Trap Desc will be ElectricEelTrapDesc.

 

Now, I'm not really sure if game is case sensitive in this part, but you may want to check case of initial letters in Blocks,block. In vanilla Localization.txt, it would be always written as blocks,Block. You may want to follow vanilla format whenever possible. Speaking of that, the second "Block" word belonging in the "Type" column may be changed into Trap (see vanilla Localization.txt for references such as "trapSpikesGroupDesc" etc.), because after all this is the trap type of block that you're trying to create, right?

 

Next thing is that your last line obviously cannot work, because its entries are not properly separated with commas.

 

I will just put that line here for you again and use red color to mark the missing commas as well as the other fixed parts to match the vanilla format:

Quote

ElectricEelTrapDesc,blocks,Trap,,,"Unlock at level 3 Advanced Engineering.\n\Must be utilized in a container or moat of cube blocks of your choice."

 

So with the things mentioned above, I would conclude that this should be your final Localization.txt that should work as expected:

Spoiler

Key,File,Type,UsedInMainMenu,NoTranslate,english
ElectricEelTrap,blocks,Trap,,,Electric Eel Trap
ElectricEelTrapDesc,blocks,Trap,,,"Unlock at level 3 Advanced Engineering.\n\Must be utilized in a container or moat of cube blocks of your choice."

 

Of course, don't forget to edit your xml to match these changed references, otherwise it will not work again lol.

Link to comment
Share on other sites

Thank you very much mr.devolver! The description is working! Here is what the finished product looks like:
 

Key,File,Type,UsedInMainMenu,NoTranslate,english
ElectricEelTrap,blocks,Block,,,ElectricEelTrap
ElectricEelTrapDesc,blocks,Block,,,"Unlock crafting at level 3 Advanced Engineering.\nMust be utilized in a container or moat of cube blocks of your choice."

 

eeltrap.jpg

Link to comment
Share on other sites

16 minutes ago, Noisy Pants said:

Thank you very much mr.devolver! The description is working! Here is what the finished product looks like:
 


Key,File,Type,UsedInMainMenu,NoTranslate,english
ElectricEelTrap,blocks,Block,,,ElectricEelTrap
ElectricEelTrapDesc,blocks,Block,,,"Unlock crafting at level 3 Advanced Engineering.\nMust be utilized in a container or moat of cube blocks of your choice."

 

eeltrap.jpg

I'm glad you got it working, but there's still something that caught my attention here. Yes, it looks correctly in game, but check out this entry I marked with a red square:

 

spacer.png

The entry in that red square is what will be shown in the game as the name of that item. That part is where you want to put the spaces between the words, so that it's well readable in game.

 

However, despite this little oversight, your screenshot shows the name correctly with spaces which makes me believe that something didn't go right and it could possibly give you some more headaches in the future. I believe that you either used a different Localization.txt in game versus what you quoted in your post, OR you used the same Localization.txt in game, but you accidentally left the old block name (the one with spaces you showed in your code before) in your xml and forgot to replace it with the Key reference that would point to this new entry in Localization.txt file.

Link to comment
Share on other sites

10 hours ago, mr.devolver said:

I'm glad you got it working, but there's still something that caught my attention here. Yes, it looks correctly in game, but check out this entry I marked with a red square:

 

spacer.png

The entry in that red square is what will be shown in the game as the name of that item. That part is where you want to put the spaces between the words, so that it's well readable in game.

 

However, despite this little oversight, your screenshot shows the name correctly with spaces which makes me believe that something didn't go right and it could possibly give you some more headaches in the future. I believe that you either used a different Localization.txt in game versus what you quoted in your post, OR you used the same Localization.txt in game, but you accidentally left the old block name (the one with spaces you showed in your code before) in your xml and forgot to replace it with the Key reference that would point to this new entry in Localization.txt file.

Understood, I corrected that. I will keep that in mind.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...