User Tools

Site Tools


Language Generation

You can generate translation entries from existing language files and classes that support translation keys.

Firstly, create a class that extends FabricLanguageProvider and implement the base methods like so:

private static class MyModEnglishLangProvider extends FabricLanguageProvider {
	private MyModEnglishLangProvider(FabricDataOutput dataGenerator) {
                // Specifying en_us is optional, by default is is en_us.
		super(dataGenerator, "en_us");
	public void generateTranslations(TranslationBuilder translationBuilder) {

Lets add some translation entries:

public void generateTranslations(TranslationBuilder translationBuilder) {
	translationBuilder.add(SIMPLE_ITEM, "Simple Item");
	translationBuilder.add(SIMPLE_BLOCK, "Simple Block");
	translationBuilder.add(SIMPLE_ITEM_GROUP, "Simple Item Group");
	// Load an existing language file.
	try {
		Path existingFilePath = dataGenerator.getModContainer().findPath("assets/mymod/lang/en_us.existing.json").get();
	} catch (Exception e) {
		throw new RuntimeException("Failed to add existing language file!", e);

Now, we will need to add the provider to our data generator in the onInitializeDataGenerator in your entrypoint class like so:

public class DataGeneration implements DataGeneratorEntrypoint {
    public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
        Pack pack = fabricDataGenerator.createPack();

Supported Classes

These are the game objects that have a translation key for you to translate:

  • Item
  • Block
  • ItemGroup
  • EntityType<T>
  • Enchantment
  • EntityAttribute
  • StatType<T>
  • StatusEffect
  • Identifier
tutorial/datagen_language.txt · Last modified: 2023/06/20 11:13 by mattidragon