diff options
author | iouter <62897714+iouter@users.noreply.github.com> | 2022-10-17 01:50:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-16 19:50:22 +0200 |
commit | 00d80de1e20af03f36e881fe6d9ba2ba2c8a9bb0 (patch) | |
tree | eac09e281ac92c5a7c64ffa07f7c6b35892dfcc7 | |
parent | 0db00590a1b6b51937b76ece976fade011d82d10 (diff) | |
download | GT5-Unofficial-00d80de1e20af03f36e881fe6d9ba2ba2c8a9bb0.tar.gz GT5-Unofficial-00d80de1e20af03f36e881fe6d9ba2ba2c8a9bb0.tar.bz2 GT5-Unofficial-00d80de1e20af03f36e881fe6d9ba2ba2c8a9bb0.zip |
fix frame box and block cant localized (#404)
-rw-r--r-- | src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java | 29 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java | 13 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java index 14e4fb6067..4a9b81a1d9 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -28,6 +28,7 @@ public class BlockBaseModular extends BasicBlock { protected int blockColour; public BlockTypes thisBlock; protected String thisBlockMaterial; + protected String thisBlockMaterialTranslatedName; protected final String thisBlockType; private static HashMap<String, Block> sBlockCache = new HashMap<String, Block>(); @@ -52,6 +53,8 @@ public class BlockBaseModular extends BasicBlock { registerComponent(); if (material != null) { sBlockCache.put(material.getUnlocalizedName() + "." + blockType.name(), this); + thisBlockMaterialTranslatedName = material.getTranslatedName(); + GT_LanguageManager.addStringLocalization("gtplusplus." + getUnlocalizedName() + ".name", getProperName()); } } @@ -69,7 +72,7 @@ public class BlockBaseModular extends BasicBlock { this.thisBlock = blockType; this.thisBlockMaterial = blockMaterialString; this.thisBlockType = blockType.name().toUpperCase(); - this.setBlockName(this.GetProperName()); + this.setBlockName(this.getUnlocalizedProperName()); int fx = getBlockTypeMeta(); // ItemBlockGtBlock.sNameCache.put("block."+blockMaterial.getUnlocalizedName()+"."+this.thisBlock.name().toLowerCase(), GetProperName()); GameRegistry.registerBlock( @@ -142,25 +145,31 @@ public class BlockBaseModular extends BasicBlock { return 0; } - public String GetProperName() { + public String getProperName() { String tempIngot = null; if (this.thisBlock == BlockTypes.STANDARD) { - tempIngot = "Block of " + this.thisBlockMaterial; + tempIngot = "Block of %material"; } else if (this.thisBlock == BlockTypes.FRAME) { - tempIngot = this.thisBlockMaterial + " Frame Box"; + tempIngot = "%material Frame Box"; } else if (this.thisBlock == BlockTypes.ORE) { - tempIngot = this.thisBlockMaterial + " Ore [Old]"; + tempIngot = "%material Ore [Old]"; } return tempIngot; } + public String getUnlocalizedProperName() { + return getProperName() + .replace("%s", "%temp") + .replace("%material", this.thisBlockMaterial) + .replace("%temp", "%s"); + } + @Override public String getLocalizedName() { - String aFormattedLangName = GetProperName(); - return GT_LanguageManager.addStringLocalization( - "block." + blockMaterial.getUnlocalizedName() + "." - + this.thisBlock.name().toLowerCase() + ".name", - aFormattedLangName); + return GT_LanguageManager.getTranslation("gtplusplus." + getUnlocalizedName() + ".name") + .replace("%s", "%temp") + .replace("%material", this.thisBlockMaterialTranslatedName) + .replace("%temp", "%s"); } @Override diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java index 36f53640aa..361d1bb066 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -108,7 +108,7 @@ public class BaseItemComponent extends Item { this.unlocalName = "itemCell" + aFormattedNameForFluids; this.materialName = localName; this.translatedMaterialName = - GT_LanguageManager.addStringLocalization("gtplusplus.fluid." + this.unlocalName, this.materialName); + getFluidName("fluid." + this.materialName.toLowerCase().replace(" ", "")); this.componentType = ComponentTypes.CELL; this.setCreativeTab(AddToCreativeTab.tabMisc); this.setUnlocalizedName(aFormattedNameForFluids); @@ -207,6 +207,17 @@ public class BaseItemComponent extends Item { return this.materialName; } + public String getFluidName(String aKey) { + String trans; + trans = GT_LanguageManager.getTranslation(aKey); + if (!trans.equals(aKey)) return trans; + aKey = "fluid." + aKey; + trans = GT_LanguageManager.getTranslation(aKey); + if (!trans.equals(aKey)) return trans; + return GT_LanguageManager.addStringLocalization( + "gtplusplus.fluid." + this.materialName.toLowerCase().replace(" ", ""), this.materialName); + } + @Override public String getItemStackDisplayName(ItemStack stack) { return GT_LanguageManager.getTranslation("gtplusplus.item." + unlocalName + ".name") |