tutorial:datagen_language
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:datagen_language [2022/09/18 13:32] – created nexus-dino | tutorial:datagen_language [2024/09/11 22:07] (current) – Update to 1.21.1 skycatminepokie | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **TODO**: Will be done as soon as '' | + | ====== Language Generation ====== |
+ | |||
+ | You can generate translation entries from existing language files and classes that support translation keys. | ||
+ | |||
+ | Firstly, create a class that extends | ||
+ | |||
+ | < | ||
+ | private static class MyModEnglishLangProvider extends FabricLanguageProvider { | ||
+ | private MyModEnglishLangProvider(FabricDataOutput dataGenerator, | ||
+ | | ||
+ | super(dataGenerator, | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void generateTranslations(class_7225.class_7874 registryLookup, | ||
+ | |||
+ | } | ||
+ | } | ||
+ | </yarncode> | ||
+ | |||
+ | Lets add some translation entries: | ||
+ | |||
+ | < | ||
+ | @Override | ||
+ | public void generateTranslations(class_7225.class_7874 registryLookup, | ||
+ | translationBuilder.add(SIMPLE_ITEM, | ||
+ | translationBuilder.add(SIMPLE_BLOCK, | ||
+ | translationBuilder.add(SIMPLE_ITEM_GROUP, | ||
+ | |||
+ | // Load an existing language file. | ||
+ | try { | ||
+ | Path existingFilePath = dataGenerator.getModContainer().findPath(" | ||
+ | translationBuilder.add(existingFilePath); | ||
+ | } catch (Exception e) { | ||
+ | throw new RuntimeException(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Now, we will need to add the provider to our data generator in the '' | ||
+ | |||
+ | <code java> | ||
+ | public class DataGeneration implements DataGeneratorEntrypoint { | ||
+ | @Override | ||
+ | public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | ||
+ | Pack pack = fabricDataGenerator.createPack(); | ||
+ | pack.addProvider(MyModEnglishLangProvider:: | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====== Supported Classes ====== | ||
+ | |||
+ | These are the game objects that have a translation key for you to translate: | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ |
tutorial/datagen_language.1663507979.txt.gz · Last modified: 2022/09/18 13:32 by nexus-dino