Skip to content

Commit ab12aaf

Browse files
committed
fix[i18n]: 修复部分错误的命名
1 parent 367a2c8 commit ab12aaf

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

processor/annotation/src/main/java/org/polaris2023/annotation/language/I18n.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
String en_us();
1212
String zh_cn();
1313
String zh_tw();
14+
String descriptionId() default "";
1415
Other[] other() default {};
1516
@interface Other {
1617
String value();

processor/src/main/java/org/polaris2023/processor/clazz/datagen/I18nProcessor.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ public void classDef(TypeElement typeElement) {
3131
VariableElement variableElement = (VariableElement) element;
3232
I18n i18n = variableElement.getAnnotation(I18n.class);
3333
if (i18n != null) {
34-
add("en_us", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.en_us()));
35-
add("zh_cn", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.zh_cn()));
36-
add("zh_tw", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.zh_tw()));
34+
String name;
35+
if(i18n.descriptionId().isEmpty()) {
36+
name = typeElement.getQualifiedName() + "." + variableElement.getSimpleName();
37+
} else {
38+
name = "\"" + i18n.descriptionId() + "\"";
39+
}
40+
add("en_us", ".add(%s, \"%s\")".formatted(name, i18n.en_us()));
41+
add("zh_cn", ".add(%s, \"%s\")".formatted(name, i18n.zh_cn()));
42+
add("zh_tw", ".add(%s, \"%s\")".formatted(name, i18n.zh_tw()));
3743
for (I18n.Other other : i18n.other()) {
38-
add(other.value(), ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), other.translate()));
44+
add(other.value(), ".add(%s, \"%s\")".formatted(name, other.translate()));
3945
}
4046
}
4147
}

src/main/java/org/polaris2023/wild_wind/client/ModTranslateKey.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ public enum ModTranslateKey implements Supplier<TranslatableContents> {
5353

5454
ModTranslateKey(String... keys) {
5555
StringBuilder key = new StringBuilder();
56-
for (int i = 0; i < keys.length; i++) {
57-
String k = keys[i];
58-
if (i == 1) {
59-
key.append(k);
60-
} else {
61-
key.append(".").append(k);
56+
if(keys.length != 0) {
57+
key.append(keys[0]);
58+
for (int i = 1; i < keys.length; i++) {
59+
key.append(".").append(keys[i]);
6260
}
6361
}
6462
translatable = Component.translatable(key.toString());

src/main/java/org/polaris2023/wild_wind/common/init/ModBlocks.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ public class ModBlocks {
215215
@I18n(en_us = "Azalea Sign", zh_cn = "杜鹃木告示牌", zh_tw = "杜鵑木告示牌")
216216
public static final DeferredBlock<StandingSignBlock> AZALEA_SIGN =
217217
register("azalea_sign", props -> new StandingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_SIGN));
218-
@I18n(en_us = "Azalea Wall Sign", zh_cn = "墙上的杜鹃木告示牌", zh_tw = "牆上的杜鵑木告示牌")
218+
@I18n(en_us = "Azalea Wall Sign", zh_cn = "墙上的杜鹃木告示牌", zh_tw = "牆上的杜鵑木告示牌", descriptionId = "block.wild_wind.azalea_wall_sign")
219219
public static final DeferredBlock<WallSignBlock> AZALEA_WALL_SIGN =
220220
register("azalea_wall_sign", props -> new WallSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_WALL_SIGN).lootFrom(AZALEA_SIGN));
221221
@I18n(en_us = "Azalea Hanging Sign", zh_cn = "悬挂式杜鹃木告示牌", zh_tw = "懸挂式杜鵑木告示牌")
222222
public static final DeferredBlock<CeilingHangingSignBlock> AZALEA_HANGING_SIGN =
223223
register("azalea_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_HANGING_SIGN));
224-
@I18n(en_us = "Azalea Wall Hanging Sign", zh_cn = "墙上的杜鹃木悬挂式告示牌", zh_tw = "牆上的杜鵑木懸挂式告示牌")
224+
@I18n(en_us = "Azalea Wall Hanging Sign", zh_cn = "墙上的杜鹃木悬挂式告示牌", zh_tw = "牆上的杜鵑木懸挂式告示牌", descriptionId = "block.wild_wind.azalea_wall_hanging_sign")
225225
public static final DeferredBlock<WallHangingSignBlock> AZALEA_WALL_HANGING_SIGN =
226226
register("azalea_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_WALL_HANGING_SIGN).lootFrom(AZALEA_HANGING_SIGN));
227227
public static final DeferredItem<BlockItem> AZALEA_LOG_ITEM =
@@ -298,13 +298,13 @@ public class ModBlocks {
298298
@I18n(en_us = "Palm Sign", zh_cn = "棕榈木告示牌", zh_tw = "棕櫚木告示牌")
299299
public static final DeferredBlock<StandingSignBlock> PALM_SIGN =
300300
register("palm_sign", props -> new StandingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_SIGN));
301-
@I18n(en_us = "Palm Wall Sign", zh_cn = "墙上的棕榈木告示牌", zh_tw = "牆上的棕櫚木告示牌")
301+
@I18n(en_us = "Palm Wall Sign", zh_cn = "墙上的棕榈木告示牌", zh_tw = "牆上的棕櫚木告示牌", descriptionId = "block.wild_wind.palm_wall_sign")
302302
public static final DeferredBlock<WallSignBlock> PALM_WALL_SIGN =
303303
register("palm_wall_sign", props -> new WallSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_WALL_SIGN).lootFrom(PALM_SIGN));
304304
@I18n(en_us = "Palm Hanging Sign", zh_cn = "棕榈木悬挂式告示牌", zh_tw = "棕櫚木懸挂式告示牌")
305305
public static final DeferredBlock<CeilingHangingSignBlock> PALM_HANGING_SIGN =
306306
register("palm_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_HANGING_SIGN));
307-
@I18n(en_us = "Palm Wall Hanging Sign", zh_cn = "墙上的棕榈木悬挂式告示牌", zh_tw = "牆上的棕櫚木懸挂式告示牌")
307+
@I18n(en_us = "Palm Wall Hanging Sign", zh_cn = "墙上的棕榈木悬挂式告示牌", zh_tw = "牆上的棕櫚木懸挂式告示牌", descriptionId = "block.wild_wind.palm_wall_hanging_sign")
308308
public static final DeferredBlock<WallHangingSignBlock> PALM_WALL_HANGING_SIGN =
309309
register("palm_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_WALL_HANGING_SIGN).lootFrom(PALM_HANGING_SIGN));
310310
public static final DeferredItem<BlockItem> PALM_LOG_ITEM =
@@ -388,13 +388,13 @@ public class ModBlocks {
388388
@I18n(en_us = "Baobab Sign", zh_cn = "猴面包木告示牌", zh_tw = "猴麵包木告示牌")
389389
public static final DeferredBlock<StandingSignBlock> BAOBAB_SIGN =
390390
register("baobab_sign", props -> new StandingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_SIGN));
391-
@I18n(en_us = "Baobab Wall Sign", zh_cn = "墙上的猴面包木告示牌", zh_tw = "牆上的猴麵包木告示牌")
391+
@I18n(en_us = "Baobab Wall Sign", zh_cn = "墙上的猴面包木告示牌", zh_tw = "牆上的猴麵包木告示牌", descriptionId = "block.wild_wind.baobab_wall_sign")
392392
public static final DeferredBlock<WallSignBlock> BAOBAB_WALL_SIGN =
393393
register("baobab_wall_sign", props -> new WallSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_SIGN).lootFrom(BAOBAB_SIGN));
394394
@I18n(en_us = "Baobab Hanging Sign", zh_cn = "猴面包木悬挂式告示牌", zh_tw = "猴麵包木懸挂式告示牌")
395395
public static final DeferredBlock<CeilingHangingSignBlock> BAOBAB_HANGING_SIGN =
396396
register("baobab_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_HANGING_SIGN));
397-
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的猴面包木悬挂式告示牌", zh_tw = "牆上的猴麵包木懸挂式告示牌")
397+
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的猴面包木悬挂式告示牌", zh_tw = "牆上的猴麵包木懸挂式告示牌", descriptionId = "block.wild_wind.baobab_wall_hanging_sign")
398398
public static final DeferredBlock<WallHangingSignBlock> BAOBAB_WALL_HANGING_SIGN =
399399
register("baobab_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_HANGING_SIGN).lootFrom(BAOBAB_HANGING_SIGN));
400400
public static final DeferredItem<BlockItem> BAOBAB_LOG_ITEM =

0 commit comments

Comments
 (0)