-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from HiedaCamellia/feat/data-generator
本地化文本的自动生成
- Loading branch information
Showing
8 changed files
with
156 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/gensokyo/nucleardelight/datagenerator/Lang.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gensokyo.nucleardelight.datagenerator; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Repeatable(Langs.class) | ||
public @interface Lang { | ||
LangName lang(); | ||
String name(); | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
src/main/java/com/gensokyo/nucleardelight/datagenerator/LangGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.gensokyo.nucleardelight.datagenerator; | ||
|
||
import com.gensokyo.nucleardelight.NuclearDelight; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraftforge.common.data.LanguageProvider; | ||
|
||
public class LangGenerator extends LanguageProvider { | ||
public LangGenerator(PackOutput output, String locale) { | ||
super(output, NuclearDelight.MODID, locale); | ||
this.locale = locale; | ||
} | ||
|
||
private final String locale; | ||
|
||
@Override | ||
protected void addTranslations() { | ||
NuclearDelight.LangKeyValuePairs.get(locale).forEach((key, value) -> add(key.get(), value)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/gensokyo/nucleardelight/datagenerator/LangName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.gensokyo.nucleardelight.datagenerator; | ||
|
||
public enum LangName { | ||
EN_US("en_us"), | ||
ZH_CN("zh_cn"); | ||
|
||
private final String value; | ||
|
||
LangName(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/gensokyo/nucleardelight/datagenerator/Langs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gensokyo.nucleardelight.datagenerator; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Langs { | ||
Lang[] value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters