Skip to content

Localization

Fran Kelava edited this page Oct 5, 2026 · 20 revisions

Localization API

To localize a string for the current game language or a specific one, use FhApi.Localization.localize. For example:

public class TemplateModule : FhModule {
    public void fn() {
        // To get your module's string with a given ID for the current game language
        string loc = FhApi.Localization.localize("backup_message.doom", this);

        // To get another module's string with a given ID for the current game language
        string loc = FhApi.Localization.localize("Fahrenheit.TemplateModule.string_b");

        // To get your module's string with a given ID for a specific language
        string loc = FhApi.Localization.localize("backup_message.doom", this, "de-DE");

        // To get another module's string with a given ID for a specific language
        string loc = FhApi.Localization.localize("Fahrenheit.TemplateModule.string_b", null, "de-DE");
        // or...
        string loc = FhApi.Localization.localize("Fahrenheit.TemplateModule.string_b", lang_id: "de-DE");
    }
}

For this to work, you must provide the necessary localization data. See below.

Localization folder

The designated location for localization file storage is your mod's lang folder.

In that folder:

  • Create one folder per module, named after the module's full type name.
  • Place localization data files within, one for each supported locale.

For example:

  • lang/Fahrenheit.Mods.Template.TemplateModule/en_US.json
  • lang/Fahrenheit.Mods.Template.TemplateModule/zh_Hant.json
  • lang/Fahrenheit.Mods.Template.OtherModule/en_US.json

Important

The folder must be named precisely after the module's full type name. In the following example:

namespace Fahrenheit.Mods.Template;

public class TemplateModule : FhModule {

the full type name is Fahrenheit.Mods.Template.TemplateModule.

Tip

By creating a folder for another mod's module, you can modify or even add localization to other mods, as long as you follow them in the load order.

Localization file format

A Fahrenheit localization file is a JSON file containing a single dictionary with string keys and values.

An example is given here:

{
    "received_backup_message.doom": "Your friend's death dooms you.",
    "received_backup_message.grave_hp": "You feel inclined to follow in your friend's footsteps.",
    "received_backup_message.bad_breath": "Your friend's death leaves a bad taste in your mouth.",
    "received_backup_message.random": "Your friend's death twists your fate.",
    "received_backup_message.generic": "You are touched by your friend's death."
}

Important

A localization data file must be named exactly {LANG_ID}.json, where {LANG_ID} is a ISO 639 language ID.

For example:

  • en-US.json
  • zh-Hant.json
  • ko-KR.json
  • de-DE.json

For the list of recognized language IDs, see src/core/i18n_cctor.cs.

For the list of what language IDs map to the game's selection of languages, see src/core/i18n.cs:37-46

Clone this wiki locally