2013-06-09 00:39:12 +00:00
package biomesoplenty.helpers ;
2013-06-14 13:17:48 +00:00
import java.util.logging.Level ;
2013-07-09 03:55:12 +00:00
import net.minecraft.util.ResourceLocation ;
2013-06-14 13:17:48 +00:00
import cpw.mods.fml.common.FMLCommonHandler ;
2013-06-09 00:39:12 +00:00
import cpw.mods.fml.common.registry.LanguageRegistry ;
public class Localizations
{
2013-07-03 06:07:31 +00:00
private static final String localizationLocation = " /assets/biomesoplenty/lang/ " ;
2013-06-09 00:39:12 +00:00
2013-08-04 04:16:44 +00:00
public static ResourceLocation [ ] localeFiles = { new ResourceLocation ( localizationLocation + " en_US.xml " ) , new ResourceLocation ( localizationLocation + " de_DE.xml " ) ,
new ResourceLocation ( localizationLocation + " nl_NL.xml " ) , new ResourceLocation ( localizationLocation + " ru_RU.xml " ) , new ResourceLocation ( localizationLocation + " zh_CN.xml " ) ,
new ResourceLocation ( localizationLocation + " pl_PL.xml " ) , new ResourceLocation ( localizationLocation + " fr_FR.xml " ) , new ResourceLocation ( localizationLocation + " fr_CA.xml " ) } ;
2013-06-21 05:36:29 +00:00
2013-07-02 23:56:11 +00:00
public static boolean isXMLLanguageFile ( ResourceLocation fileName )
2013-06-21 05:36:29 +00:00
{
2013-07-02 23:56:11 +00:00
return fileName . func_110623_a ( ) . endsWith ( " .xml " ) ;
2013-06-21 05:36:29 +00:00
}
2013-07-02 23:56:11 +00:00
public static String getLocaleFromFileName ( ResourceLocation fileName )
2013-06-21 05:36:29 +00:00
{
2013-07-02 23:56:11 +00:00
FMLCommonHandler . instance ( ) . getFMLLogger ( ) . log ( Level . INFO , " [BiomesOPlenty] Localizations loaded for " + fileName . func_110623_a ( ) . substring ( fileName . func_110623_a ( ) . lastIndexOf ( '/' ) + 1 , fileName . func_110623_a ( ) . lastIndexOf ( '.' ) ) ) ;
return fileName . func_110623_a ( ) . substring ( fileName . func_110623_a ( ) . lastIndexOf ( '/' ) + 1 , fileName . func_110623_a ( ) . lastIndexOf ( '.' ) ) ;
2013-06-21 05:36:29 +00:00
}
public String getLocalizedString ( String key )
{
return LanguageRegistry . instance ( ) . getStringLocalization ( key ) ;
}
public static void loadLanguages ( )
{
2013-07-02 23:56:11 +00:00
for ( ResourceLocation localizationFile : localeFiles )
2013-06-21 05:36:29 +00:00
{
2013-07-02 23:56:11 +00:00
LanguageRegistry . instance ( ) . loadLocalization ( localizationFile . func_110623_a ( ) , getLocaleFromFileName ( localizationFile ) , isXMLLanguageFile ( localizationFile ) ) ;
2013-06-21 05:36:29 +00:00
}
for ( int mat = 0 ; mat < materialTypes . length ; mat + + )
{
for ( int type = 0 ; type < toolMaterialNames . length ; type + + )
{
String internalName = new StringBuilder ( ) . append ( " item.bop.tc. " ) . append ( materialTypes [ mat ] ) . append ( " . " ) . append ( toolMaterialNames [ type ] ) . append ( " .name " ) . toString ( ) ;
String visibleName = new StringBuilder ( ) . append ( toolMaterialNames [ type ] ) . append ( materialNames [ mat ] ) . toString ( ) ;
LanguageRegistry . instance ( ) . addStringLocalization ( internalName , " en_US " , visibleName ) ;
}
}
for ( int i = 0 ; i < shardNames . length ; i + + )
2013-06-09 00:39:12 +00:00
{
2013-06-21 05:36:29 +00:00
String internalName = " item.bop.tc.ToolShard. " + toolMaterialNames [ i ] + " .name " ;
String visibleName = shardNames [ i ] ;
LanguageRegistry . instance ( ) . addStringLocalization ( internalName , " en_US " , visibleName ) ;
2013-06-09 00:39:12 +00:00
}
2013-06-21 05:36:29 +00:00
}
public static final String [ ] shardNames = new String [ ] { " Amethyst " } ;
public static final String [ ] toolMaterialNames = new String [ ] { " Amethyst " } ;
public static final String [ ] materialTypes = new String [ ] { " ToolRod " , " PickaxeHead " , " ShovelHead " , " AxeHead " , " SwordBlade " , " LargeGuard " , " MediumGuard " , " Crossbar " , " Binding " , " FrypanHead " , " SignHead " , " LumberHead " , " KnifeBlade " , " ChiselHead " , " ScytheBlade " , " LumberHead " , " ThickRod " , " ThickBinding " , " LargeSwordBlade " , " LargePlate " , " ExcavatorHead " , " HammerHead " , " FullGuard " } ;
public static final String [ ] materialNames = new String [ ] { " Rod " , " Pickaxe Head " , " Shovel Head " , " Axe Head " , " Sword Blade " , " Wide Guard " , " Hand Guard " , " Crossbar " , " Binding " , " Pan " , " Board " , " Broad Axe Head " , " Knife Blade " , " Chisel Head " , " Scythe Blade " , " Broad Axe Head " , " Tough Tool Rod " , " Tough Binding " , " Large Sword Blade " , " Large Plate " , " Excavator Head " , " Hammer Head " , " Full Guard " } ;
2013-06-09 00:39:12 +00:00
}