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 " ) ,
2013-08-16 10:00:45 +00:00
new ResourceLocation ( localizationLocation + " pl_PL.xml " ) , new ResourceLocation ( localizationLocation + " fr_FR.xml " ) , new ResourceLocation ( localizationLocation + " fr_CA.xml " ) //,
/*new ResourceLocation(localizationLocation + "ja_JP.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-09-13 08:17:21 +00:00
return fileName . getResourcePath ( ) . 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-09-13 08:17:21 +00:00
FMLCommonHandler . instance ( ) . getFMLLogger ( ) . log ( Level . INFO , " [BiomesOPlenty] Localizations loaded for " + fileName . getResourcePath ( ) . substring ( fileName . getResourcePath ( ) . lastIndexOf ( '/' ) + 1 , fileName . getResourcePath ( ) . lastIndexOf ( '.' ) ) ) ;
return fileName . getResourcePath ( ) . substring ( fileName . getResourcePath ( ) . lastIndexOf ( '/' ) + 1 , fileName . getResourcePath ( ) . 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-09-13 08:17:21 +00:00
LanguageRegistry . instance ( ) . loadLocalization ( localizationFile . getResourcePath ( ) , getLocaleFromFileName ( localizationFile ) , isXMLLanguageFile ( localizationFile ) ) ;
2013-06-21 05:36:29 +00:00
}
}
2013-06-09 00:39:12 +00:00
}