Move to assets lang system

This commit is contained in:
robin4002 2014-02-16 00:48:23 +01:00
parent 42c98f757a
commit 754857dbb6
32 changed files with 139 additions and 361 deletions

Binary file not shown.

View file

@ -104,100 +104,100 @@ gui.pipes.emzuli.title=Extraction Presets
gui.pipes.emzuli.paint=Paint Items %s
gui.pipes.emzuli.nopaint=Don't Paint Items
item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear
item.stoneGearItem=Stone Gear
item.ironGearItem=Iron Gear
item.goldGearItem=Gold Gear
item.diamondGearItem=Diamond Gear
item.templateItem=Template
item.wrenchItem=Wrench
item.pipeWaterproof=Pipe Sealant
item.redPipeWire=Red Pipe Wire
item.bluePipeWire=Blue Pipe Wire
item.greenPipeWire=Green Pipe Wire
item.yellowPipeWire=Yellow Pipe Wire
item.redstone_red_chipset=Redstone Chipset
item.redstone_iron_chipset=Iron Chipset
item.redstone_gold_chipset=Golden Chipset
item.redstone_diamond_chipset=Diamond Chipset
item.redstone_pulsating_chipset=Pulsating Chipset
item.redstone_quartz_chipset=Quartz Chipset
item.redstone_comp_chipset=Redstone Comp Chipset
item.blueprintItem=Blueprint
item.PipeItemsWood=Wooden Transport Pipe
item.PipeItemsCobblestone=Cobblestone Transport Pipe
item.PipeItemsStone=Stone Transport Pipe
item.PipeItemsQuartz=Quartz Transport Pipe
item.PipeItemsIron=Iron Transport Pipe
item.PipeItemsGold=Golden Transport Pipe
item.PipeItemsDiamond=Diamond Transport Pipe
item.PipeItemsObsidian=Obsidian Transport Pipe
item.PipeItemsEmerald=Emerald Transport Pipe
item.PipeItemsLapis=Lazuli Transport Pipe
item.PipeItemsDaizuli=Daizuli Transport Pipe
item.PipeItemsEmzuli=Emzuli Transport Pipe
item.PipeFluidsWood=Wooden Fluid Pipe
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
item.PipeFluidsStone=Stone Fluid Pipe
item.PipeFluidsIron=Iron Fluid Pipe
item.PipeFluidsGold=Golden Fluid Pipe
item.PipeFluidsEmerald=Emerald Fluid Pipe
item.PipePowerWood=Wooden Kinesis Pipe
item.PipePowerCobblestone=Cobblestone Kinesis Pipe
item.PipePowerStone=Stone Kinesis Pipe
item.PipePowerQuartz=Quartz Kinesis Pipe
item.PipePowerIron=Iron Kinesis Pipe
item.PipePowerGold=Golden Kinesis Pipe
item.PipePowerDiamond=Diamond Kinesis Pipe
item.PipeItemsStripes=Stripes Transport Pipe
item.PipeStructureCobblestone=Cobblestone Structure Pipe
item.PipeItemsVoid=Void Transport Pipe
item.PipeFluidsVoid=Void Fluid Pipe
item.PipeItemsSandstone=Sandstone Transport Pipe
item.PipeFluidsSandstone=Sandstone Fluid Pipe
item.Facade=Facade
item.PipePlug=Pipe Plug
item.bucketFuel.name=Fuel Bucket
item.bucketOil.name=Oil Bucket
item.woodenGearItem.name=Wood Gear
item.stoneGearItem.name=Stone Gear
item.ironGearItem.name=Iron Gear
item.goldGearItem.name=Gold Gear
item.diamondGearItem.name=Diamond Gear
item.templateItem.name=Template
item.wrenchItem.name=Wrench
item.pipeWaterproof.name=Pipe Sealant
item.redPipeWire.name=Red Pipe Wire
item.bluePipeWire.name=Blue Pipe Wire
item.greenPipeWire.name=Green Pipe Wire
item.yellowPipeWire.name=Yellow Pipe Wire
item.redstone_red_chipset.name=Redstone Chipset
item.redstone_iron_chipset.name=Iron Chipset
item.redstone_gold_chipset.name=Golden Chipset
item.redstone_diamond_chipset.name=Diamond Chipset
item.redstone_pulsating_chipset.name=Pulsating Chipset
item.redstone_quartz_chipset.name=Quartz Chipset
item.redstone_comp_chipset.name=Redstone Comp Chipset
item.blueprintItem.name=Blueprint
item.PipeItemsWood.name=Wooden Transport Pipe
item.PipeItemsCobblestone.name=Cobblestone Transport Pipe
item.PipeItemsStone.name=Stone Transport Pipe
item.PipeItemsQuartz.name=Quartz Transport Pipe
item.PipeItemsIron.name=Iron Transport Pipe
item.PipeItemsGold.name=Golden Transport Pipe
item.PipeItemsDiamond.name=Diamond Transport Pipe
item.PipeItemsObsidian.name=Obsidian Transport Pipe
item.PipeItemsEmerald.name=Emerald Transport Pipe
item.PipeItemsLapis.name=Lazuli Transport Pipe
item.PipeItemsDaizuli.name=Daizuli Transport Pipe
item.PipeItemsEmzuli.name=Emzuli Transport Pipe
item.PipeFluidsWood.name=Wooden Fluid Pipe
item.PipeFluidsCobblestone.name=Cobblestone Fluid Pipe
item.PipeFluidsStone.name=Stone Fluid Pipe
item.PipeFluidsIron.name=Iron Fluid Pipe
item.PipeFluidsGold.name=Golden Fluid Pipe
item.PipeFluidsEmerald.name=Emerald Fluid Pipe
item.PipePowerWood.name=Wooden Kinesis Pipe
item.PipePowerCobblestone.name=Cobblestone Kinesis Pipe
item.PipePowerStone.name=Stone Kinesis Pipe
item.PipePowerQuartz.name=Quartz Kinesis Pipe
item.PipePowerIron.name=Iron Kinesis Pipe
item.PipePowerGold.name=Golden Kinesis Pipe
item.PipePowerDiamond.name=Diamond Kinesis Pipe
item.PipeItemsStripes.name=Stripes Transport Pipe
item.PipeStructureCobblestone.name=Cobblestone Structure Pipe
item.PipeItemsVoid.name=Void Transport Pipe
item.PipeFluidsVoid.name=Void Fluid Pipe
item.PipeItemsSandstone.name=Sandstone Transport Pipe
item.PipeFluidsSandstone.name=Sandstone Fluid Pipe
item.Facade.name=Facade
item.PipePlug.name=Pipe Plug
tab.machines=Buildcraft Machines
tab.facades=Buildcraft Facades
itemGroup.buildcraft.machines=Buildcraft Machines
itemGroup.buildcraft.facades=Buildcraft Facades
tile.architectBlock=Architect Table
tile.assemblyTableBlock=Assembly Table
tile.assemblyWorkbenchBlock=Advanced Crafting Table
tile.autoWorkbenchBlock=Auto Workbench
tile.blockFuel=Fuel
tile.blockHopper=Chute
tile.blockOil=Oil
tile.builderBlock=Builder
tile.engineIron=Combustion Engine
tile.engineStone=Stirling Engine
tile.engineWood=Redstone Engine
tile.fillerBlock=Filler
tile.filteredBufferBlock=Filtered Buffer
tile.floodGateBlock=Flood Gate
tile.frameBlock=Frame
tile.integrationTableBlock=Integration Table
tile.laserBlock=Laser
tile.libraryBlock=Blueprint Library
tile.machineBlock=Quarry
tile.markerBlock=Land Mark
tile.miningWellBlock=Mining Well
tile.pathMarkerBlock=Path Marker
tile.plainPipeBlock=Mining Pipe
tile.pumpBlock=Pump
tile.refineryBlock=Refinery
tile.spring.oil=Oil Spring
tile.spring.water=Water Spring
tile.tankBlock=Tank
tile.architectBlock.name=Architect Table
tile.assemblyTableBlock.name=Assembly Table
tile.assemblyWorkbenchBlock.name=Advanced Crafting Table
tile.autoWorkbenchBlock.name=Auto Workbench
tile.blockFuel.name=Fuel
tile.blockHopper.name=Chute
tile.blockOil.name=Oil
tile.builderBlock.name=Builder
tile.engineIron.name=Combustion Engine
tile.engineStone.name=Stirling Engine
tile.engineWood.name=Redstone Engine
tile.fillerBlock.name=Filler
tile.filteredBufferBlock.name=Filtered Buffer
tile.floodGateBlock.name=Flood Gate
tile.frameBlock.name=Frame
tile.integrationTableBlock.name=Integration Table
tile.laserBlock.name=Laser
tile.libraryBlock.name=Blueprint Library
tile.machineBlock.name=Quarry
tile.markerBlock.name=Land Mark
tile.miningWellBlock.name=Mining Well
tile.pathMarkerBlock.name=Path Marker
tile.plainPipeBlock.name=Mining Pipe
tile.pumpBlock.name=Pump
tile.refineryBlock.name=Refinery
tile.spring.oil.name=Oil Spring
tile.spring.water.name=Water Spring
tile.tankBlock.name=Tank
tip.gate.wires=Compatible Wires:
tip.gate.wires=§9§oCompatible Wires:
tip.gate.wires.redstone=Red
tip.gate.wires.iron=Red, Blue
tip.gate.wires.gold=Red, Blue, Yellow
tip.gate.wires.diamond=Red, Blue, Yellow, Green
tip.gate.expansions=Installed Expansions:
tip.gate.expansions=§9§oInstalled Expansions:
tip.PipeFluidsCobblestone=Basic pipe, 10 mB/t\nWon't connect to Stone
tip.PipeFluidsEmerald=Extraction pipe, 40 mB/t

View file

@ -251,27 +251,21 @@ public class BuildCraftBuilders extends BuildCraftMod {
markerBlock = new BlockMarker();
CoreProxy.proxy.registerBlock(markerBlock.setBlockName("markerBlock"));
CoreProxy.proxy.addName(markerBlock, "Land Mark");
pathMarkerBlock = new BlockPathMarker();
CoreProxy.proxy.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock"));
CoreProxy.proxy.addName(pathMarkerBlock, "Path Mark");
fillerBlock = new BlockFiller();
CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock"));
CoreProxy.proxy.addName(fillerBlock, "Filler");
builderBlock = new BlockBuilder();
CoreProxy.proxy.registerBlock(builderBlock.setBlockName("builderBlock"));
CoreProxy.proxy.addName(builderBlock, "Builder");
architectBlock = new BlockArchitect();
CoreProxy.proxy.registerBlock(architectBlock.setBlockName("architectBlock"));
CoreProxy.proxy.addName(architectBlock, "Architect Table");
libraryBlock = new BlockBlueprintLibrary();
CoreProxy.proxy.registerBlock(libraryBlock.setBlockName("libraryBlock"));
CoreProxy.proxy.addName(libraryBlock, "Blueprint Library");
GameRegistry.registerTileEntity(TileMarker.class, "Marker");
GameRegistry.registerTileEntity(TileFiller.class, "Filler");

View file

@ -74,7 +74,6 @@ import buildcraft.core.triggers.TriggerInventory;
import buildcraft.core.triggers.TriggerInventoryLevel;
import buildcraft.core.triggers.TriggerMachine;
import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.Localization;
import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.core.recipes.IntegrationRecipeManager;
import buildcraft.core.triggers.TriggerRedstoneInput;
@ -294,9 +293,6 @@ public class BuildCraftCore extends BuildCraftMod {
CoreProxy.proxy.initializeRendering();
CoreProxy.proxy.initializeEntityRendering();
Localization.addLocalization("/lang/buildcraft/", DefaultProps.DEFAULT_LANGUAGE);
}
@EventHandler

View file

@ -17,7 +17,6 @@ import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.fluids.BCFluid;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.energy.BlockBuildcraftFluid;
@ -136,19 +135,18 @@ public class BuildCraftEnergy extends BuildCraftMod {
// Oil and fuel
buildcraftFluidOil = new BCFluid("oil").setDensity(800).setViscosity(1500);
buildcraftFluidOil = new Fluid("oil").setDensity(800).setViscosity(1500);
FluidRegistry.registerFluid(buildcraftFluidOil);
fluidOil = FluidRegistry.getFluid("oil");
buildcraftFluidFuel = new BCFluid("fuel");
buildcraftFluidFuel = new Fluid("fuel");
FluidRegistry.registerFluid(buildcraftFluidFuel);
fluidFuel = FluidRegistry.getFluid("fuel");
if (fluidOil.getBlock() == null) {
blockOil = new BlockBuildcraftFluid(fluidOil, Material.water).setFlammable(canOilBurn).setFlammability(0);
blockOil.setBlockName("blockOil");
CoreProxy.proxy.addName(blockOil, "Oil");
CoreProxy.proxy.registerBlock(blockOil);
fluidOil.setBlock(blockOil);
} else {
@ -164,7 +162,6 @@ public class BuildCraftEnergy extends BuildCraftMod {
if (fluidFuel.getBlock() == null) {
blockFuel = new BlockBuildcraftFluid(fluidFuel, Material.water).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F);
blockFuel.setBlockName("blockFuel");
CoreProxy.proxy.addName(blockFuel, "Fuel");
CoreProxy.proxy.registerBlock(blockFuel);
fluidFuel.setBlock(blockFuel);
} else {

View file

@ -184,43 +184,33 @@ public class BuildCraftFactory extends BuildCraftMod {
miningWellBlock = new BlockMiningWell();
CoreProxy.proxy.registerBlock(miningWellBlock.setBlockName("miningWellBlock"));
CoreProxy.proxy.addName(miningWellBlock, "Mining Well");
plainPipeBlock = new BlockPlainPipe();
CoreProxy.proxy.registerBlock(plainPipeBlock.setBlockName("plainPipeBlock"));
CoreProxy.proxy.addName(plainPipeBlock, "Mining Pipe");
autoWorkbenchBlock = new BlockAutoWorkbench();
CoreProxy.proxy.registerBlock(autoWorkbenchBlock.setBlockName("autoWorkbenchBlock"));
CoreProxy.proxy.addName(autoWorkbenchBlock, "Automatic Crafting Table");
frameBlock = new BlockFrame();
CoreProxy.proxy.registerBlock(frameBlock.setBlockName("frameBlock"));
CoreProxy.proxy.addName(frameBlock, "Frame");
quarryBlock = new BlockQuarry();
CoreProxy.proxy.registerBlock(quarryBlock.setBlockName("machineBlock"));
CoreProxy.proxy.addName(quarryBlock, "Quarry");
tankBlock = new BlockTank();
CoreProxy.proxy.registerBlock(tankBlock.setBlockName("tankBlock"));
CoreProxy.proxy.addName(tankBlock, "Tank");
pumpBlock = new BlockPump();
CoreProxy.proxy.registerBlock(pumpBlock.setBlockName("pumpBlock"));
CoreProxy.proxy.addName(pumpBlock, "Pump");
floodGateBlock = new BlockFloodGate();
CoreProxy.proxy.registerBlock(floodGateBlock.setBlockName("floodGateBlock"));
CoreProxy.proxy.addName(floodGateBlock, "Flood Gate");
refineryBlock = new BlockRefinery();
CoreProxy.proxy.registerBlock(refineryBlock.setBlockName("refineryBlock"));
CoreProxy.proxy.addName(refineryBlock, "Refinery");
hopperBlock = new BlockHopper();
CoreProxy.proxy.registerBlock(hopperBlock.setBlockName("blockHopper"));
CoreProxy.proxy.addName(hopperBlock, "Hopper");
FactoryProxy.proxy.initializeEntityRenders();

View file

@ -71,7 +71,6 @@ public class BuildCraftSilicon extends BuildCraftMod {
BuildCraftCore.mainConfiguration.save();
laserBlock = new BlockLaser();
CoreProxy.proxy.addName(laserBlock.setBlockName("laserBlock"), "Laser");
CoreProxy.proxy.registerBlock(laserBlock);
assemblyTableBlock = new BlockLaserTable();

View file

@ -332,7 +332,6 @@ public class BuildCraftTransport extends BuildCraftMod {
filteredBufferBlock = new BlockFilteredBuffer();
CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock"));
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
for (PipeContents kind : PipeContents.values()) {
triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind);

View file

@ -79,7 +79,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
// fontRenderer.drawString(library.owner + "'s Library", 6, 6,
// 0x404040);
String title = StringUtils.localize("tile.libraryBlock");
String title = StringUtils.localize("tile.libraryBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
int c = 0;

View file

@ -45,7 +45,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtils.localize("tile.builderBlock");
String title = StringUtils.localize("tile.builderBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 12, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.building.resources"), 8, 60, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);

View file

@ -61,7 +61,7 @@ public class GuiFiller extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.fillerBlock");
String title = StringUtils.localize("tile.fillerBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040);

View file

@ -43,7 +43,7 @@ public class GuiTemplate extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.architectBlock");
String title = StringUtils.localize("tile.architectBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 152, 0x404040);

View file

@ -1,16 +1,13 @@
package buildcraft.core;
import buildcraft.BuildCraftCore;
import buildcraft.core.utils.Localization;
import buildcraft.transport.ItemFacade;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.BuildCraftCore;
import buildcraft.transport.ItemFacade;
public enum CreativeTabBuildCraft {
@ -30,10 +27,6 @@ public enum CreativeTabBuildCraft {
return "buildcraft." + name().toLowerCase(Locale.ENGLISH);
}
private String translate() {
return Localization.get("tab." + name().toLowerCase(Locale.ENGLISH));
}
private ItemStack getItem() {
switch (this) {
case FACADES:
@ -55,11 +48,6 @@ public enum CreativeTabBuildCraft {
return getItem();
}
@Override
public String getTranslatedTabLabel() {
return translate();
}
@Override
public Item getTabIconItem() {
return getItem().getItem();

View file

@ -23,9 +23,4 @@ public class ItemBlockBuildCraft extends ItemBlock {
public int getMetadata(int i) {
return i;
}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
return StringUtils.localize(getUnlocalizedName(itemstack));
}
}

View file

@ -27,11 +27,6 @@ public class ItemBuildCraft extends Item {
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
return StringUtils.localize(getUnlocalizedName(itemstack));
}
@Override
public Item setUnlocalizedName(String par1Str) {
iconName = par1Str;

View file

@ -1,24 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.fluids;
import buildcraft.core.utils.StringUtils;
import net.minecraftforge.fluids.Fluid;
public class BCFluid extends Fluid {
public BCFluid(String name) {
super(name);
}
@Override
public String getLocalizedName() {
return StringUtils.localize("fluid." + fluidName);
}
}

View file

@ -65,10 +65,6 @@ public class CoreProxy {
return null;
}
public String getCurrentLanguage() {
return null;
}
/* ENTITY HANDLING */
public void removeEntity(Entity entity) {
entity.worldObj.removeEntity(entity);
@ -79,13 +75,6 @@ public class CoreProxy {
public void feedSubBlocks(Block block, CreativeTabs tab, List itemList) {
}
/* LOCALIZATION */
public void addName(Object obj, String s) {
}
public void addLocalization(String s1, String string) {
}
public String getItemDisplayName(ItemStack newStack) {
return "";
}

View file

@ -81,22 +81,6 @@ public class CoreProxyClient extends CoreProxy {
block.getSubBlocks(Item.getItemFromBlock(block), tab, itemList);
}
/* LOCALIZATION */
@Override
public String getCurrentLanguage() {
return Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
}
@Override
public void addName(Object obj, String s) {
LanguageRegistry.addName(obj, s);
}
@Override
public void addLocalization(String s1, String string) {
LanguageRegistry.instance().addStringLocalization(s1, string);
}
@Override
public String getItemDisplayName(ItemStack stack) {
if (stack.getItem() == null)

View file

@ -1,140 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.utils;
import buildcraft.core.proxy.CoreProxy;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.Properties;
/**
* Simple mod localization class.
*/
public class Localization {
private static class modInfo {
final String modName, defaultLanguage;
public modInfo(String modName, String defaultLanguage) {
this.modName = modName;
this.defaultLanguage = defaultLanguage;
}
}
private static String loadedLanguage = getCurrentLanguage();
private static Properties defaultMappings = new Properties();
private static Properties mappings = new Properties();
private static LinkedList<modInfo> mods = new LinkedList<modInfo>();
/**
* Adds localization from a given directory. The files must have the same name as the corresponding language file in minecraft and a ".properties" file
* extention e.g "en_US.properties"
*
* @param path
* The path to the localization files
* @param defaultLanguage
* The default localization to be used when there is no localization for the selected language or if a string is missing (e.g. "en_US")
*/
public static void addLocalization(String path, String defaultLanguage) {
mods.add(new modInfo(path, defaultLanguage));
load(path, defaultLanguage);
}
/**
* Get a string for the given key, in the currently active translation.
*
* @param key
* @return
*/
public static synchronized String get(String key) {
if (getCurrentLanguage() == null) {
return key;
}
if (!getCurrentLanguage().equals(loadedLanguage)) {
defaultMappings.clear();
mappings.clear();
for (modInfo mInfo : mods) {
load(mInfo.modName, mInfo.defaultLanguage);
}
loadedLanguage = getCurrentLanguage();
}
return mappings.getProperty(key, defaultMappings.getProperty(key, key));
}
public static synchronized boolean hasKey(String key) {
if (getCurrentLanguage() == null) {
return false;
}
if (!getCurrentLanguage().equals(loadedLanguage)) {
defaultMappings.clear();
mappings.clear();
for (modInfo mInfo : mods) {
load(mInfo.modName, mInfo.defaultLanguage);
}
loadedLanguage = getCurrentLanguage();
}
return mappings.getProperty(key, defaultMappings.getProperty(key)) != null;
}
private static void load(String path, String default_language) {
InputStream langStream = null;
Properties modMappings = new Properties();
try {
// Load the default language mappings
langStream = Localization.class.getResourceAsStream(path + default_language + ".properties");
modMappings.load(langStream);
defaultMappings.putAll(modMappings);
langStream.close();
// Try to load the current language mappings.
// If the file doesn't exist use the default mappings.
langStream = Localization.class.getResourceAsStream(path + getCurrentLanguage() + ".properties");
if (langStream != null) {
modMappings.clear();
modMappings.load(langStream);
}
// If the selected language inherits mappings from another language
// we use those first and then we overwrite the common ones with
// those in the selected language
if (modMappings.containsKey("language.parent")) {
langStream = Localization.class.getResourceAsStream(path + modMappings.get("language.parent") + ".properties");
if (langStream != null) {
Properties parentModMappings = new Properties();
parentModMappings.load(langStream);
mappings.putAll(parentModMappings);
}
}
mappings.putAll(modMappings);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (langStream != null) {
langStream.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
private static String getCurrentLanguage() {
return CoreProxy.proxy.getCurrentLanguage();
}
}

View file

@ -8,9 +8,19 @@
*/
package buildcraft.core.utils;
import com.google.common.base.Splitter;
import net.minecraft.util.StatCollector;
public class StringUtils {
public static String localize(String key) {
return Localization.get(key);
}
}
public static final Splitter newLineSplitter = Splitter.on("\\n");
public static String localize(String key) {
return StatCollector.translateToLocal(key);
}
public static boolean canLocalize(String key) {
return StatCollector.canTranslate(key);
}
}

View file

@ -29,11 +29,6 @@ public class ItemBucketBuildcraft extends ItemBucket {
setContainerItem(Items.bucket);
}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
return StringUtils.localize(getUnlocalizedName(itemstack));
}
@Override
public Item setUnlocalizedName(String par1Str) {
iconName = par1Str;

View file

@ -35,7 +35,7 @@ public class GuiCombustionEngine extends GuiEngine {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtils.localize("tile.engineIron");
String title = StringUtils.localize("tile.engineIron.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}

View file

@ -29,7 +29,7 @@ public class GuiStoneEngine extends GuiEngine {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtils.localize("tile.engineStone");
String title = StringUtils.localize("tile.engineStone.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}

View file

@ -37,7 +37,7 @@ public class GuiAutoCrafting extends GuiBuildCraft {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.autoWorkbenchBlock");
String title = StringUtils.localize("tile.autoWorkbenchBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}

View file

@ -43,7 +43,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.refineryBlock");
String title = StringUtils.localize("tile.refineryBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRendererObj.drawString("->", 63, 59, 0x404040);
fontRendererObj.drawString("<-", 106, 59, 0x404040);

View file

@ -218,7 +218,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
@Override
public String getInventoryName() {
return StringUtils.localize("tile.assemblyWorkbenchBlock");
return StringUtils.localize("tile.assemblyWorkbenchBlock.name");
}
@Override

View file

@ -130,7 +130,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
@Override
public String getInventoryName() {
return StringUtils.localize("tile.assemblyTableBlock");
return StringUtils.localize("tile.assemblyTableBlock.name");
}
@Override

View file

@ -164,7 +164,7 @@ public class TileIntegrationTable extends TileLaserTableBase implements ISidedIn
@Override
public String getInventoryName() {
return StringUtils.localize("tile.integrationTableBlock");
return StringUtils.localize("tile.integrationTableBlock.name");
}
@Override

View file

@ -138,7 +138,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtils.localize("tile.assemblyTableBlock");
String title = StringUtils.localize("tile.assemblyTableBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 15, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);

View file

@ -8,15 +8,19 @@
*/
package buildcraft.transport;
import buildcraft.core.utils.Localization;
import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
@SideOnly(Side.CLIENT)
public class PipeToolTipManager {
@ -35,13 +39,13 @@ public class PipeToolTipManager {
public static List<String> getToolTip(Class<? extends Pipe> pipe) {
List<String> tips = new ArrayList<String>();
String tipTag = "tip." + pipe.getSimpleName();
if (Localization.hasKey(tipTag)) {
String localized = Localization.get(tipTag);
if (localized != null) {
String[] lines = localized.split("\\n");
if (StringUtils.canLocalize(tipTag)) {
String localized = StringUtils.localize(tipTag);
if (localized != null) {
String[] lines = (String[])Iterables.toArray(StringUtils.newLineSplitter.split(localized), String.class);
tips.addAll(Arrays.asList(lines));
}
}
}
String tip = toolTips.get(pipe);
if (tip != null)
tips.add(tip);

View file

@ -16,7 +16,7 @@ import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.utils.Localization;
import buildcraft.core.utils.StringUtils;
import buildcraft.core.utils.Utils;
import buildcraft.transport.Gate;
import buildcraft.transport.gates.GateDefinition.GateLogic;
@ -39,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
public class ItemGate extends ItemBuildCraft {
@ -174,6 +175,12 @@ public class ItemGate extends ItemBuildCraft {
public String getUnlocalizedName(ItemStack stack) {
return GateDefinition.getLocalizedName(getMaterial(stack), getLogic(stack));
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack))).trim();
}
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
@ -216,12 +223,12 @@ public class ItemGate extends ItemBuildCraft {
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
super.addInformation(stack, player, list, adv);
list.add("§9§o" + Localization.get("tip.gate.wires"));
list.add(Localization.get("tip.gate.wires." + getMaterial(stack).getTag()));
list.add(StringUtils.localize("tip.gate.wires"));
list.add(StringUtils.localize("tip.gate.wires." + getMaterial(stack).getTag()));
Set<IGateExpansion> expansions = getInstalledExpansions(stack);
if (!expansions.isEmpty()) {
list.add("§9§o" + Localization.get("tip.gate.expansions"));
list.add(StringUtils.localize("tip.gate.expansions"));
for (IGateExpansion expansion : expansions) {
list.add(expansion.getDisplayName());

View file

@ -53,7 +53,7 @@ public class GuiFilteredBuffer extends GuiContainer {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.filteredBufferBlock");
String title = StringUtils.localize("tile.filteredBufferBlock.name");
int xPos = (xSize - fontRendererObj.getStringWidth(title)) / 2;
fontRendererObj.drawString(title, xPos, 10, 0x404040);
}