Internationalization (i18n)
Auto UI and entry text depend on language files. You need to provide config.<modid>.* keys in your mod's resource pack.
Key Naming Conventions
- Title:
config.{modid}.title - Category:
config.{modid}.category.{section}(sectionis top-level field name) - Entry:
config.{modid}.{section}.{path}and... .tooltip- Top-level entry:
config.{modid}.{section}.{field} - Subcategory entry:
config.{modid}.{section}.{sub.path}(dot-separated path)
- Top-level entry:
Example (top-level + subcategory):
json
{
"config.my_mod.title": "My Mod Settings",
"config.my_mod.category.general": "General",
"config.my_mod.general.enabled": "Enabled",
"config.my_mod.general.enabled.tooltip": "Whether to enable the main feature",
"config.my_mod.category.client": "Client",
"config.my_mod.client.ui.whitelist": "Whitelist",
"config.my_mod.client.ui.whitelist.tooltip": "List of allowed entity IDs"
}Tips:
- Any missing keys will display as default English key or placeholder; recommend complete coverage
- tooltip is optional; UI still displays normally without it
Language File Location
- Fabric:
resources/assets/<modid>/lang/zh_cn.json,en_us.json, etc. - NeoForge: Same path convention
UI Generation and Key Mapping (Implementation Details)
- Top-level category uses
builder.getOrCreateCategory( translatable("config.{modid}.category.{section}") ) - Entry text:
- Top-level field:
config.{modid}.{section}.{field} - Subcategory field:
config.{modid}.{section}.{sub.path}
- Top-level field:
- All entries by default append
... .tooltipas tooltip text key
Note: For top-level non-subcategory fields, internal implementation does defensive fieldName.replace('.', '_') processing; generally won't affect actual usage since field names typically don't contain dots.