How to make your mod compatible with other languages

From The Stardew Modding Wiki
Jump to navigation Jump to search

Stardew Valley is played in many languages, and mods come in just as many. In order to make your mod available to as many players as possible, it's a good idea to allow to follow these tips and good practices to make your mod as accessible to translators as possible.


CP Translation Keys[edit | edit source | hide | hide all]

A missing i18n field has prompted this Korean game to display the text in the default English instead.

When editing crafting/cooking recipe or animal data in Content Patcher or BFAV, the final field is often a translation key. This is important for allowing compatibility with other languages (TODO: explain why). For example, a recipe adding a craftable battery might look like this:

"Battery": "335 1 338 1 767 5/Home/9/true/Mining 6/でんち"

If the last field is left blank:

"Battery": "335 1 338 1 767 5/Home/9/true/Mining 6"

Content Patcher will still accept the code, but the game will read the item as null in non-English languages, which can cause errors and crashes, as well as not displaying correctly in-game.

For best support, an i18n token (see below for i18n information should be used to ensure multi-language compatibility:

"Battery": "335 1 338 1 767 5/Home/9/true/Mining 6/Template:I18n:Battery"

Translations in JSON Assets[edit | edit source | hide]

  1. If you'd like to make your mod compatible with translations (recommended!), add the following to your object.json file:
    	  "NameLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
        // "ja": "",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      },
      "DescriptionLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
        // "ja": "",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      }
    
  2. The languages are:
    1. ES: Spanish (Español)
    2. KO: Korean (한국어)
    3. DE: German (Deutsch)
    4. FR: French (Français)
    5. HU: Hungarian (Magyar)
    6. IT: Italian (Italiano)
    7. JA: Japanese (日本語)
    8. PT: Portuguese (Português)
    9. RU: Russian (русский)
    10. TR: Turkish (Türkçe)
    11. ZH: Chinese
  3. You can use hyphenated codes to distinguish between different dialects: for example, pt-BR refers to Brazilian Portuguese and zh-CN refers to Simplified Chinese.
  4. Remove the // for any languages you want to add and put the name and description inside the quotes. For example, here is a JA item that adds a Japanese translation:
    "NameLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
         "ja": "スズキ",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      },
      "DescriptionLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
         "ja": "スズキを 釣り上げた! 鈴木…じゃなくて、鱸なのね!",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      }
    

Example[edit | edit source | hide]

Kaya's mod Craftable Curiosity Lure] demonstates multi-language compatibility for CP, JA, and Producer Framework Mod.

How to ask for or offer a translation[edit | edit source | hide]

TODO

What is i18n?[edit | edit source | hide]

i18n, which is short for 'internationalization' is a generalized process for separating the coding aspect of a program from its textual one, making translations and localizations easier and quicker. In Stardew terms, i18n is a separate JSON, with one or more contained in a separate folder, which uses tokens to insert the right language's text at the proper areas. i18n is supported by frameworks that can utilize tokens, such as Content Patcher and Quest Framework.

As an example, here is a default.json (English language) which adds text to a Clint event in CP (from the mod Strange Machines):

{

//Event Text

"events-39270001.01": "Hello, @! *puff puff* It's, uh... it's a bit of a walk out this way, huh?$2",
"events-39270001.02": "I'm still working through my grandfather's notes on Blackstone. It's pretty difficult to work with, honestly...$2 you have to use a lot of it, but once you get it melted down and dense, it's very resistant to fire and pressure.",
"events-39270001.03": "Anyway, I was thinking about those blueprints I gave you all that time ago... the furnace and the charcoal kiln... What I'm trying to say is...$2 I came up with this blueprint that combines them and thought you might like to try it.$1 It's difficult, but I think you can handle it.",
"events-39270001.04": "Because of the Blackstone, this Brazier Furnace is more efficient, so it can make more bars with the same ores. Heh... Who would've thought that I would come up with something like this? I think my grandfather would be proud.$2",
"events-39270001.05": "Anyway, I guess I'll make the hike back into town and keep looking at those notes. And, uh... thanks for being a friend.$2 I'm in my shop all day and it's out of the way, so I don't get a lot of chances to talk to people, so thanks for always coming by.$2 Take it easy, @.",
}

And here's what the event looks like in Content Patcher with the i18n tokens:

      {
	"LogName": "Clint Event",
	"Action": "EditData",
	"Target": "Data/Events/Farm",
	"Entries": {
	"39270001/n Brazier.Furnace":"continue/64 15/farmer 64 16 2 Clint 64 18 0/pause 1500/speak Clint \"{{i18n:events-39270001.01}}\"/pause 500/speak Clint \"{{i18n:events-39270001.02}}\"/pause 500/speak Clint \"{{i18n:events-39270001.03}}\"/pause 800/itemAboveHead/playSound getNewSpecialItem/addCraftingRecipe Brazier Furnace/pause 1000/speak Clint \"{{i18n:events-39270001.04}}\"/pause 500/faceDirection Clint 1/pause 500/faceDirection Clint 0/speak Clint \"{{i18n:events-39270001.05}}\"/pause 200/end"
		}
	},