Java Code Examples for net.minecraft.util.text.translation.I18n#translateToLocal()
The following examples show how to use
net.minecraft.util.text.translation.I18n#translateToLocal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFluidContainer.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Override @Nonnull public String getItemStackDisplayName(@Nonnull ItemStack stack) { FluidStack fluidStack = getFluid(stack); if (fluidStack == null) { return super.getItemStackDisplayName(stack); } String unloc = this.getUnlocalizedNameInefficiently(stack); if (I18n.canTranslate(unloc + "." + fluidStack.getFluid().getName())) { return I18n.translateToLocal(unloc + "." + fluidStack.getFluid().getName()); } return I18n.translateToLocalFormatted(unloc + ".filled.name", fluidStack.getLocalizedName()); }
Example 2
Source File: Tooltips.java From TinkersToolLeveling with MIT License | 6 votes |
private static String getRawLevelString(int level) { if(level <= 0) { return ""; } // try a basic translated string if(I18n.canTranslate("tooltip.level." + level)) { return I18n.translateToLocal("tooltip.level." + level); } // ok. try to find a modulo int i = 1; while(I18n.canTranslate("tooltip.level." + i)) { i++; } // get the modulo'd string String str = I18n.translateToLocal("tooltip.level." + (level % i)); // and add +s! for(int j = level / i; j > 0; j--) { str += '+'; } return str; }
Example 3
Source File: GuiUpdates.java From VersionChecker with GNU Lesser General Public License v3.0 | 6 votes |
public void openInfoScreen(Update update) { openUpdate = update; updateButton.visible = true; closeButton.visible = true; changeLogList.disableInput = false; updateList.disableInput = true; buttonDownloaded.setUpdate(update); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ui_button_click, 1.0F)); if (update.isDirectLink) { updateButton.displayString = I18n.translateToLocal(Strings.UPDATE); updateButton.enabled = update.updateURL != null && !update.isDownloaded(); } else { updateButton.displayString = I18n.translateToLocal(Strings.OPEN_WEBPAGE); updateButton.enabled = update.updateURL != null; } if (openUpdate.changeLog != null) { changeLogList.setText(openUpdate.changeLog); } tempDisableButtonPress = 5; }
Example 4
Source File: BlockPackager.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public GuiBlueprint getGuiBlueprint(TileRoutiduct tile) { GuiBlueprint blueprint = new GuiBlueprint(tile).setSize(176, 241).setPlayerInvPos(7, 158); blueprint.addSlot(SlotType.NORMAL, 7, 30); blueprint.addSlot(SlotType.NORMAL, 25, 30); blueprint.addSlot(SlotType.NORMAL, 43, 30); blueprint.addSlot(SlotType.NORMAL, 7, 48); // blueprint.addSlot(SlotType.NORMAL, 25, 48); blueprint.elements.add(new TextElement("Input", 4210752, 9, 21)); blueprint.elements.add(new TextElement("Inventory", 4210752, 9, 149)); blueprint.elements.add(new ElementBase(new Sprite(GuiAssemblerS.ROUTIDUCT_ELEMENTS, protocol.badgeX, protocol.badgeY, 15, 10), 154, 7)); for (int i = 0; i < protocol.ports; i++) blueprint.elements.add(new ElementBase(Sprites.PACKAGE_BAR, 69, 21 + i * 11)); blueprint.elements.add(new TextElement("Input", 4210752, 9, 21)); blueprint.elements.add(new TextElement("100%", 0xFF000000, 25, 72, true)); blueprint.elements.add(new ElementBase(Sprites.PROGRESS_BAR_BACKGROUND, 11, 81)); for (Package.EnumColor color : Package.EnumColor.values()) { if (color.ordinal() < protocol.ports) { String text = I18n.translateToLocal(color.unlocalisedName) + " Package"; String number = (color.ordinal() + 1) + "."; blueprint.elements.add(new TextElement(number, 0xFFC4C4C4, 78, 23 + color.ordinal() * 11, true)); blueprint.elements.add(new TextElement(I18n.translateToLocal(color.unlocalisedName) + " Package", color.colour, 86, 23 + color.ordinal() * 11, 74)); blueprint.elements.add(new ElementBase(new Sprite(GuiAssemblerS.ROUTIDUCT_ELEMENTS, 26, color.textureY, 8, 6), 159, 24 + color.ordinal() * 11)); } } blueprint.elements.add(new ElementBase(new Sprite(GuiAssemblerS.ROUTIDUCT_ELEMENTS, 0, Package.EnumColor.values()[protocol.ports].textureY, 26, 6), 12, 82)); return blueprint; }
Example 5
Source File: JEICrusherRecipeCategory.java From BaseMetals with GNU Lesser General Public License v2.1 | 5 votes |
@Override public String getTitle() { String key = "nei."+BaseMetals.MODID+".recipehandler.crusher.name"; if(I18n.canTranslate(key)){ return I18n.translateToLocal(key); } else { return "Crusher"; } }
Example 6
Source File: CrusherRecipeHandler.java From BaseMetals with GNU Lesser General Public License v2.1 | 5 votes |
@Override public String getRecipeName() { String key = "nei."+BaseMetals.MODID+".recipehandler.crusher.name"; if(I18n.canTranslate(key)){ return I18n.translateToLocal(key); } else { return "Crusher"; } }
Example 7
Source File: ItemSorter.java From NotEnoughItems with MIT License | 4 votes |
public String getLocalisedName() { return I18n.translateToLocal(name); }
Example 8
Source File: ItemSorter.java From NotEnoughItems with MIT License | 4 votes |
public String getTooltip() { String tipname = name + ".tip"; String tip = I18n.translateToLocal(tipname); return !tip.equals(tipname) ? tip : null; }
Example 9
Source File: LocalizationHelper.java From Moo-Fluids with GNU General Public License v3.0 | 4 votes |
public static String localize(final String unlocalizedString, final boolean prependPrefix) { return prependPrefix ? I18n.translateToLocal(PREFIX + unlocalizedString) : I18n.translateToLocal(unlocalizedString); }
Example 10
Source File: CommonProxy.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public String translate(String unlocalized) { return I18n.translateToLocal(unlocalized); }
Example 11
Source File: LocalizedException.java From LunatriusCore with MIT License | 4 votes |
public LocalizedException(final String format) { super(I18n.translateToLocal(format)); }
Example 12
Source File: IMCHandler.java From VersionChecker with GNU Lesser General Public License v3.0 | 4 votes |
public static void processCurseCheckMessage(String sender, NBTTagCompound tag) { if (tag.hasKey(IMCOperations.CURSE_PROJECT_NAME) && tag.hasKey(IMCOperations.CURSE_FILENAME_PARSER)) { String curseProjectName = tag.getString(IMCOperations.CURSE_PROJECT_NAME); String latestFilename = WebHelper.getLatestFilenameFromCurse("http://minecraft.curseforge.com/projects/" + curseProjectName + "/files/latest"); if (latestFilename != null) { String fileNameParser = tag.getString(IMCOperations.CURSE_FILENAME_PARSER); int i = fileNameParser.indexOf('['); int o = fileNameParser.indexOf(']'); if (i != -1 && o != -1) { String version = latestFilename.replace(fileNameParser.substring(0, i), "").replace(fileNameParser.substring(o + 1, fileNameParser.length()), ""); if (version.equals(tag.hasKey(IMCOperations.OLD_VERSION) ? tag.getString(IMCOperations.OLD_VERSION) : ModHelper.getModContainer(sender).getVersion())) return; Update update = new Update(sender); update.newVersion = version; update.updateURL = "http://minecraft.curseforge.com/projects/" + curseProjectName + "/files/latest"; update.isDirectLink = true; update.newFileName = latestFilename; update.changeLog = I18n.translateToLocal(Strings.CURSE_UPDATE); if (tag.hasKey(IMCOperations.MOD_DISPLAY_NAME)) { update.displayName = tag.getString(IMCOperations.MOD_DISPLAY_NAME); } else { update.displayName = ModHelper.getModContainer(sender).getName(); } if (tag.hasKey(IMCOperations.OLD_VERSION)) { update.oldVersion = tag.getString(IMCOperations.OLD_VERSION); } else { update.oldVersion = ModHelper.getModContainer(sender).getVersion(); } update.updateType = Update.UpdateType.CURSE; UpdateHandler.addUpdate(update); return; } } } LogHandler.error(String.format("An error was encountered when fetching latest version from Curse for %s!", sender)); }
Example 13
Source File: GuiUpdateList.java From VersionChecker with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void drawSlot(int slotIndex, int minX, int maxX, int minY, int maxY, Tessellator tesselator) { Update update = updateList.get(slotIndex); if (update != null && !update.oldVersion.matches(update.newVersion)) { this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(update.displayName, listWidth - 10), minX + 5, minY + 4, 0xFFFFFF); if (this.parent.getFontRenderer().getStringWidth(update.newVersion) >= (listWidth - 125)){ this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(update.oldVersion + " -> ", listWidth - 10), minX + 5, minY + 15, 0xCCCCCC); this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(" " + update.newVersion, listWidth - 10), minX + 5, minY + 25, 0xCCCCCC); } else { this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(update.oldVersion + " -> " + update.newVersion, listWidth - 10), minX + 5, minY + 15, 0xCCCCCC); } String info; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().renderEngine.bindTexture(Resources.GUI_ICONS); if (DownloadThread.isUpdating(update)) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 0, 0, 16, 16, 64, 32); info = I18n.translateToLocal(Strings.UPDATING); } else if (update.isDownloaded()) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 16, 0, 16, 16, 64, 32); if (!update.MOD_ID.equalsIgnoreCase(Reference.MOD_ID)) { info = I18n.translateToLocal(Strings.IS_DOWNLOADED); } else { info = I18n.translateToLocal(Strings.UNABLE_TO_REMOVE_SELF); } } else if (update.isErrored()) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 32, 0, 16, 16, 64, 32); info = I18n.translateToLocal(Strings.ERRORED); } else if (update.isDirectLink) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 16, 16, 16, 16, 64, 32); info = I18n.translateToLocal(Strings.DL_AVAILABLE); } else if (update.updateURL != null) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 0, 16, 16, 16, 64, 32); info = I18n.translateToLocal(Strings.LINK_TO_DL); } else { info = I18n.translateToLocal(Strings.CANNOT_UPDATE); } if (update.updateType == Update.UpdateType.NOT_ENOUGH_MODS) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 32, 16, 16, 16, 64, 32); } else if (update.updateType == Update.UpdateType.CURSE) { Gui.drawModalRectWithCustomSizedTexture(maxX - 30, minY + 8, 48, 0, 16, 16, 64, 32); } this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(info, listWidth - 10), minX + 5, minY + 35, 0xCCCCCC); } }
Example 14
Source File: TranslationUtils.java From OpenModsLib with MIT License | 4 votes |
public static String translateToLocal(String key) { return I18n.translateToLocal(key); }