Question How to create translation keys for a mod's i18n?

I have created the Pack Collection mod (Nexus link) and I have been pulling my hair to figure out how to translate different items in my mod when they all share the same translation key because they all edit the same item?

According to this page: SDV Wiki | Modding: Translations, a default.json contains text that looks like this:
Code:
{
   "translation-key": "simple translatable text",
   "translation-key-2": "translatable text with a {{token}} value"
}
However, my mod's content.json lacks distinct translation keys for each item for me to give them their proper translations:
Code:
{

    "Format": "2.0.0",

    "Changes": [

        {

            "Action": "EditData",

            "Target": "platinummyr.CustomBackpackFramework/dictionary",

            "Entries": {

                "24": {

                    "name": "Large Pack",

                    "cost": 2000,

                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",

                    "textureRect":

                    {

                        "X":0,

                        "Y":0,

                        "Width": 12,

                        "Height":14

                    }

                },

                "36": {

                    "name": "Deluxe Pack",

                    "cost": 10000,

                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",

                    "textureRect":

                    {

                        "X":12,

                        "Y":0,

                        "Width": 12,

                        "Height":14

                    }

                },

            }

        },

        {

            "Action": "Load",

            "Target": "platinummyr.CPMoreBackpacks/backpacks",

            "FromFile": "assets/packcollection.png"

        }

    ]

}
Note how there are two items. As you can see in this example here, the Large Pack and the Deluxe Pack, both share the key: "name", instead of having their own translation key each, that would otherwise enable translation of these names.

Does anyone to advice me know how add translation keys to these items in my contents.json?
 
Last edited:

Torsang

Newcomer
Hello! To answer your question: Pathoschild has a wonderful write-up here at their GitHub about how to set-up translations here.

But to answer directly, you would add a folder (at the same level as your manifest.json file) titled simply i18n, then add a json file inside there that matches the agreed-upon language keys (english is usually default if not specified as EN-US or EN-GB, german is DE, etc).

Structure the i18n json file like you have in the first code block: "key": "value". Be sure to include the comma after each line (except the final line). In the content.json or any delegate jsons you include, use this format to include the translation keys from your i18n file: {{key}}. Two open curly braces, followed by the key name, followed by two close curly braces.

Content Patcher handles the back-end of this process, so you can focus more on the content itself.
 
Thats very useful. Thank you so much!

May I ask how I can incorporate these translation keys into my mod properly?

the format used in my mod in content.json is:
Code:
            "Entries": {
                "24": {
                    "name": "Large Pack",
                    "cost": 2000,
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":0,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                }
                "36": {
                    "name": "Deluxe Pack",
                    "cost": 10000,
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":12,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                },
                "48": {
                    "name": "Traveler's Backpack",
                    "cost": 50000,
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":36,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                },
            }

The format Pathoschild tells us in his guide to use, however, is:
Code:
            "Entries": {
                "{{ModId}}_Pufferchick": {
                    "DisplayName": "{{i18n: item.name}}",
                    "Price": 1200,
                    ...
            }
        }
Since in my mod is about one item that changes multiple names. I guess I have just to add a "DisplayName": "{{i18n: item.name}}", plus a number at the end of it? i.e. "DisplayName": "{{i18n: item.name1}}", "DisplayName": "{{i18n: item.name2}}", "DisplayName": "{{i18n: item.name3}}",

Perhaps something like that suffices?
Code:
            "Entries": {
                "24": {
                   "name": "Large Pack",
                    "cost": 2000,
                    "DisplayName": "{{i18n: item.name1}}",
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":0,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                }
                "36": {
                    "name": "Deluxe Pack",
                    "cost": 10000,
                    "DisplayName": "{{i18n: item.name2}}",
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":12,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                },
                "48": {
                    "name": "Traveler's Backpack",
                    "cost": 50000,
                    "DisplayName": "{{i18n: item.name3}}",
                    "texturePath": "platinummyr.CPMoreBackpacks/backpacks",
                    "textureRect":
                    {
                        "X":36,
                        "Y":0,
                        "Width": 12,
                        "Height":14
                    }
                },
            }
 
Top