Skip to main content
The project's repository is archived as part of the GitHub Archive Program. RogueLibs' code and the documentation will no longer be updated.

Custom Names

Custom localization in RogueLibs is implemented using instances of the CustomName class, which contain all languages' translations at the same time (which isn't really efficient, but whatever). You can integrate your custom names into the game using the RogueLibs.CreateCustomName(...) method.

CustomNameInfo structure

CustomNameInfo structure is used to create custom names and transfer localization data.

CustomNameInfo emptyInfo = new CustomNameInfo();
CustomNameInfo nameInfo = new CustomNameInfo("english text");

You can add more translations to the custom names too:

nameInfo = new CustomNameInfo
{
[LanguageCode.French] = "texte français",
[LanguageCode.Spanish] = "texto en español",
};
// or
nameInfo[LanguageCode.French] = "texte français";
nameInfo[LanguageCode.Spanish] = "texto en español";

You can also use your own language codes:

nameInfo[(LanguageCode)123] = "日本語テキスト";
info

See more info in Custom Languages.


Unlike dictionaries, both CustomName and CustomNameInfo return null, if they don't contain the specified LanguageCode:

string translation = nameInfo[(LanguageCode)123];
// returns null, if that language is not specified
string display = translation ?? nameInfo.English;

CustomName class

Usually, CustomNames are created automatically, when you add names and descriptions to your items, traits, abilities and etc.:

RogueLibs.CreateCustomItem<MyCustomItem>()
.WithName(new CustomNameInfo("English name")
{
French = "nom français",
Spanish = "nombre español",
})
.WithDescription(new CustomNameInfo("English description")
{
French = "description française",
Spanish = "descripción en español",
});

You can initialize them yourself too, although you have to provide the name and type of the CustomName yourself:

CustomName name = RogueLibs.CreateCustomName("Name", "Type", new CustomNameInfo("Info"));

If you're going to use the second method, here's the list of types used in the game:

  • Item - item and special ability names;
  • Description - item, special ability, trait, status effect and agent descriptions;
  • StatusEffect - trait and status effect names;
  • Interface - interface buttons, labels and stuff;
  • Unlock - mutator and Big Quest names and descriptions;
  • Object - object and chunk type names;
  • Agent - agent names;
  • Dialogue - agent dialogue lines;
Pro-tip: Name type const strings

Use string consts in the NameTypes static class to avoid typos.

Usage

If you want to use your custom names in the game, use NameDB.GetName() or any other methods that use it:

string dialogue = gc.nameDB.GetName("CryForHelp", NameTypes.Dialogue);
Owner.SayDialogue("CryForHelp");

CustomNames and CustomNameInfos also can be implicitly converted into CustomTooltip:

public class Recycler : CustomItem, IItemCombinable
{
[RLSetup]
public static void Setup()
{
recycleTooltip = RogueLibs.CreateCustomName("Recycle", NameTypes.Interface, new CustomNameInfo
{
English = "Recycle",
Russian = "Переработать",
});
}
private static CustomName recycleTooltip;

/* ... */
public CustomTooltip CombineTooltip(InvItem _) => recycleTooltip;
}
The project's repository is archived as part of the GitHub Archive Program. RogueLibs' code and the documentation will no longer be updated.