当前位置: 首页>>代码示例>>Java>>正文


Java StringTranslate类代码示例

本文整理汇总了Java中net.minecraft.util.StringTranslate的典型用法代码示例。如果您正苦于以下问题:Java StringTranslate类的具体用法?Java StringTranslate怎么用?Java StringTranslate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringTranslate类属于net.minecraft.util包,在下文中一共展示了StringTranslate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchZipForLanguages

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchZipForLanguages(File source, Side side) throws IOException
{
    ZipFile zf = new ZipFile(source);
    List<String> added = Lists.newArrayList();
    for (ZipEntry ze : Collections.list(zf.entries()))
    {
        Matcher matcher = assetENUSLang.matcher(ze.getName());
        if (matcher.matches())
        {
            String lang = matcher.group(2);
            //FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
            added.add(lang);
            LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
            // Ensure en_US is available to StringTranslate on the server
            if ("en_US".equals(lang) && side == Side.SERVER)
            {
                StringTranslate.inject(zf.getInputStream(ze));
            }
        }
    }
    if (added.size() > 0)
        FMLLog.fine("Found translations in %s [%s]", source.getName(), Joiner.on(", ").join(added));
    zf.close();
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:25,代码来源:LanguageRegistry.java

示例2: searchDirForLanguages

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchDirForLanguages(File source, String path, Side side) throws IOException
{
    for (File file : source.listFiles())
    {
        String currPath = path+file.getName();
        if (file.isDirectory())
        {
            searchDirForLanguages(file, currPath+'/', side);
        }
        Matcher matcher = assetENUSLang.matcher(currPath);
        if (matcher.matches())
        {
            String lang = matcher.group(2);
            FMLLog.fine("Injecting found translation assets for lang %s at %s into language system", lang, currPath);
            LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(new FileInputStream(file)));
            // Ensure en_US is available to StringTranslate on the server
            if ("en_US".equals(lang) && side == Side.SERVER)
            {
                StringTranslate.inject(new FileInputStream(file));
            }
        }
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:24,代码来源:LanguageRegistry.java

示例3: searchZipForLanguages

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchZipForLanguages(File source, Side side) throws IOException
{
    ZipFile zf = new ZipFile(source);
    for (ZipEntry ze : Collections.list(zf.entries()))
    {
        Matcher matcher = assetENUSLang.matcher(ze.getName());
        if (matcher.matches())
        {
            String lang = matcher.group(2);
            FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
            LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
            // Ensure en_US is available to StringTranslate on the server
            if ("en_US".equals(lang) && side == Side.SERVER)
            {
                StringTranslate.inject(zf.getInputStream(ze));
            }
        }
    }
    zf.close();
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:21,代码来源:LanguageRegistry.java

示例4: postInit

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void postInit()
{
    ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new IResourceManagerReloadListener() {
        private boolean ranOnce = false;

        public void onResourceManagerReload(IResourceManager resourcemanager) {
            if (!this.ranOnce) {
                this.ranOnce = true;
                return;
            }
            StructuralLevelClientData.loadBaseTextureData();
            if (StructuralLevel.LEVELS != null) {
                for (StructuralLevel level : StructuralLevel.LEVELS) {
                    if (level.levelNum != 0) {
                        level.clientData.generateIcons();
                        StringTranslate.inject(new ByteArrayInputStream(("item.upgrade.structural." + String.valueOf(level.levelNum) + ".name=" + StatCollector.translateToLocal("item.upgrade.structural") + " " + Utils.romanNumeral(level.levelNum) + " (" + level.clientData.getMaterialName() + ")").getBytes()));
                    }
                }
            }
            StructuralLevelClientData.unloadBaseTextureData();
        }
    });
}
 
开发者ID:Dennisbonke,项目名称:JABBA,代码行数:24,代码来源:ClientProxy.java

示例5: injectLanguage

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static void injectLanguage(File source, Side side) {
    try {
        ZipFile zf = new ZipFile(source);
        for (ZipEntry ze : Collections.list(zf.entries())) {
            Matcher matcher = Pattern.compile("(?:.+/|)([\\w_-]+).lang").matcher(ze.getName());
            if (matcher.matches()) {
                String lang = matcher.group(1);
                FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
                LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
                // Ensure en_US is available to StringTranslate on the server
                if ("en_US".equals(lang) && side == Side.SERVER)
                    StringTranslate.inject(zf.getInputStream(ze));
            }
        }
        zf.close();
    } catch (Exception e) {
        Logger.logError("Could not inject language file!");
        e.printStackTrace();
    }
}
 
开发者ID:Lomeli12,项目名称:AchieveSON,代码行数:21,代码来源:AchievementHandler.java

示例6: searchDirForENUSLanguage

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchDirForENUSLanguage(File source, String path) throws IOException
{
    for (File file : source.listFiles())
    {
        String currPath = path+file.getName();
        if (file.isDirectory())
        {
            searchDirForENUSLanguage(file, currPath+'/');
        }
        Matcher matcher = assetENUSLang.matcher(currPath);
        if (matcher.matches())
        {
            FMLLog.fine("Injecting found translation data at %s into language system", currPath);
            StringTranslate.inject(new FileInputStream(file));
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:18,代码来源:FMLServerHandler.java

示例7: onResourceManagerReload

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager resourceManager)
{
    List<String> list = Lists.newArrayList(new String[] {"en_US"});

    if (!"en_US".equals(this.currentLanguage))
    {
        list.add(this.currentLanguage);
    }

    currentLocale.loadLocaleDataFiles(resourceManager, list);
    StringTranslate.replaceWith(currentLocale.properties);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:LanguageManager.java

示例8: getFallback

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private static StringTranslate getFallback() throws IllegalAccessException, NoSuchFieldException {
	if (fallback == null) {
		fallback = StatCollector.class.getDeclaredField("fallbackTranslator");
		fallback.setAccessible(true);
	}
	return (StringTranslate) fallback.get(null);
}
 
开发者ID:austinv11,项目名称:CollectiveFramework,代码行数:8,代码来源:MinecraftTranslator.java

示例9: getStringTranslateInstance

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static StringTranslate getStringTranslateInstance() {
	try {
		Field field = getField(StringTranslate.class, ObfuscationConstants.STRINGTRANSLATE_INSTANCE);
		return (StringTranslate) field.get(null);
	} catch (IllegalAccessException ex) {
		Game.logger().error("could not get string translator");
		return null;
	}
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:10,代码来源:ReflectionUtil.java

示例10: onResourceManagerReload

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager par1ResourceManager)
{
    ArrayList var2 = Lists.newArrayList(new String[] {"en_US"});

    if (!"en_US".equals(this.currentLanguage))
    {
        var2.add(this.currentLanguage);
    }

    currentLocale.loadLocaleDataFiles(par1ResourceManager, var2);
    StringTranslate.replaceWith(currentLocale.field_135032_a);
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:13,代码来源:LanguageManager.java

示例11: initializeThread

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void initializeThread(Configuration configuration) {
        optout = configuration.get("optout", "localization_update", false, "Opt-out of localization updates, and only use lang files packaged with the JAR").getBoolean(false);
        if (!optout) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        URL url = new URL(langUrl);
                        InputStream con = url.openStream();
                        String data = new String(ByteStreams.toByteArray(con));
                        con.close();

                        Map<String, Object>[] json = new Gson().fromJson(data, Map[].class);

                        for (Map<String, Object> aJson : json) {
                            String name = ((String) aJson.get("name"));
                            if (name.endsWith(".lang")) {
                                LOGGER.info("Discovered remote " + name + ". Downloading...");
                                URL url1 = new URL(String.format(rawUrl, aJson.get("path")));
                                InputStream con1 = url1.openStream();
                                Map<String, String> map = StringTranslate.parseLangFile(con1);
                                LocalizationUpdater.this.loadedLangFiles.put(name.substring(0, name.lastIndexOf(".lang")), map);
                                con1.close();
                            }
                        }
                    } catch (Exception ex) {
// Most likely due to the lack of an internet connection. No need to print
                        if (ex instanceof UnknownHostException)
                            optout = true;
                        else
                            LOGGER.warn("Failed to update localization!", ex);
                    }
                }
            });
            thread.start();
        }
    }
 
开发者ID:tm1990,项目名称:MiscUtils,代码行数:38,代码来源:LocalizationUpdater.java

示例12: inject

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static void inject(HashMap<String, String> map) {
    try {
        Map<String, String> languageMap = ObfuscationReflectionHelper.getPrivateValue(StringTranslate.class, getInstance(), LANGUAGE_MAP);
        languageMap.putAll(map);
        ObfuscationReflectionHelper.setPrivateValue(StringTranslate.class, getInstance(), System.currentTimeMillis(), LAST_UPDATE);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:tm1990,项目名称:MiscUtils,代码行数:10,代码来源:LocalizationUpdater.java

示例13: initializeThread

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void initializeThread(Configuration configuration) {
    optout = configuration.get("optout", "localization_update", false, "Opt-out of localization updates, and only use lang files packaged with the JAR").getBoolean(false);
    if (!optout) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL url = new URL(langUrl);
                    InputStream con = url.openStream();
                    String data = new String(ByteStreams.toByteArray(con));
                    con.close();

                    Map<String, Object>[] json = new Gson().fromJson(data, Map[].class);

                    for (Map<String, Object> aJson : json) {
                        String name = ((String) aJson.get("name"));
                        if (name.endsWith(".lang")) {
                            LOGGER.info("Discovered " + name + ". Downloading...");
                            URL url1 = new URL(String.format(rawUrl, aJson.get("path")));
                            InputStream con1 = url1.openStream();
                            Map<String, String> map = StringTranslate.parseLangFile(con1);
                            LocalizationUpdater.this.loadedLangFiles.put(name.substring(0, name.lastIndexOf(".lang")), map);
                            con1.close();
                        }
                    }
                } catch (Exception ex) {
                    // Most likely due to the lack of an internet connection. No need to print
                    if (ex instanceof UnknownHostException)
                        optout = true;
                    else
                        LOGGER.warn("Failed to update localization!", ex);
                }
            }
        });
        thread.start();
    }
}
 
开发者ID:dmillerw,项目名称:CosmeticArmor,代码行数:38,代码来源:LocalizationUpdater.java

示例14: onResourceManagerReload

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager p_110549_1_)
{
    ArrayList arraylist = Lists.newArrayList(new String[] {"en_US"});

    if (!"en_US".equals(this.currentLanguage))
    {
        arraylist.add(this.currentLanguage);
    }

    currentLocale.loadLocaleDataFiles(p_110549_1_, arraylist);
    LanguageRegistry.instance().mergeLanguageTable(currentLocale.field_135032_a, this.currentLanguage);
    StringTranslate.replaceWith(currentLocale.field_135032_a);
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:14,代码来源:LanguageManager.java

示例15: searchZipForENUSLanguage

import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchZipForENUSLanguage(File source) throws IOException
{
    ZipFile zf = new ZipFile(source);
    for (ZipEntry ze : Collections.list(zf.entries()))
    {
        Matcher matcher = assetENUSLang.matcher(ze.getName());
        if (matcher.matches())
        {
            FMLLog.fine("Injecting found translation data in zip file %s at %s into language system", source.getName(), ze.getName());
            StringTranslate.inject(zf.getInputStream(ze));
        }
    }
    zf.close();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:15,代码来源:FMLServerHandler.java


注:本文中的net.minecraft.util.StringTranslate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。