Translations - MarkusBordihn/BOs-Easy-NPC GitHub Wiki
Easy NPC makes it simple to translate names, dialog texts, and buttons, helping you create NPCs that speak the playerβs languageβliterally! This feature allows for seamless internationalization of your dialogs and NPC interactions.
Translations are stored in JSON files within the lang
folder in the mod's configuration
directory.
Each file corresponds to a specific language and contains the translations for dialog texts,
buttons, and NPC names. You can easily share your translations with others by packaging these JSON
files into resource packs.
Your resource pack should follow this structure:
resourcepack/
|ββ pack.mcmeta
|ββ pack.png
βββ assets/
β βββ <namespace e.g. easy_npc_example>/
β βββ lang/
β βββ en_us.json
β βββ de_de.json
Translation files use a simple JSON format:
{
"text.<namespace>.<key>": "Translation text",
"text.<namespace>.<key>.<subkey>": "Translation text"
}
For example, hereβs a snippet from assets/easy_npc_example/lang/en_us.json
:
{
"text.easy_npc_example.hello.text": "Hello @initiator, my name is @npc. Nice to meet you!\n\nDo you want to know more about me?",
"text.easy_npc_example.hello.yes_button": "Yes, of course.",
"text.easy_npc_example.hello.no_button": "No, thanks.",
"text.easy_npc_example.hello.yes_answer": "I'm a translator, here to help you understand the languages of the world.",
"text.easy_npc_example.hello.no_answer": "Okay, have a great day!",
"text.easy_npc_example.hello.name": "Translator"
}
Each key, like text.easy_npc_example.hello.text
, identifies the translation entry, followed by the
actual translation text in the corresponding language.
Translation keys are used in the NPC name field, dialog editor, or button editor to link text to the appropriate translations. The system automatically detects and replaces matching keys (in lowercase and without special characters) with their translated versions. Any other text is displayed as is.
You can insert translation keys in the NPC editorβs name field to display the NPCβs name in the playerβs language.
In the dialog editor, you can use translation keys to show dialog text in the playerβs language.
You can also apply translation keys in the button editor to translate button text for the player.
Imagine you have a translator NPC that helps players understand different languages.
This NPCβs name and dialog texts can be translated into multiple languages, like English and German.
To see this in action, spawn a Humanoid
NPC and import the preset default_translator
. This NPC
will use the translations from the example resource pack.
You can technically use translation files from other mods, but you must ensure that the translation keys are unique and properly formatted to avoid conflicts.