@SuppressWarnings("deprecation") public static boolean canTranslateToLocal(String key) { return I18n.canTranslate(key); }
public static boolean canTranslate(String key) { return I18n.canTranslate(key); } }
@SuppressWarnings("deprecation") private static boolean canTranslate(String key) { return I18n.canTranslate(key); } }
public static boolean canLocalize(String key) { return I18n.canTranslate(key); }
public boolean canLocalise(String key) { return I18n.canTranslate(key); }
/** * Checks if the passed string has a localization mapped. Does not use the prefix. * * @param unloc * The unlocalized string * @return True if there is a localization mapped, false otherwise. */ public boolean canLocalizeExact(@Nonnull String unloc) { return I18n.canTranslate(unloc); } }
public static String translate(String langKey, Object... args) { return net.minecraft.util.text.translation.I18n.canTranslate(langKey) ? net.minecraft.util.text.translation.I18n.translateToLocalFormatted(langKey, args) : langKey; }
/** * Translate any variant of a string * * @param def The fallback string * @param strings The strings to try to translate * @return The first translateable string or the default */ @SuppressWarnings("deprecation") public static String translateOrDefault(String def, String... strings) { for (String string : strings) { if (net.minecraft.util.text.translation.I18n.canTranslate(string)) { return net.minecraft.util.text.translation.I18n.translateToLocal(string); } } return def; }
public static String translateOrDefault(String langKey, String defaultVal) { return net.minecraft.util.text.translation.I18n.canTranslate(langKey) ? translate(langKey) : defaultVal; }
@Nonnull @SuppressWarnings("deprecation") static String format(String key, Object... params) { return I18n.canTranslate(key) ? I18n.translateToLocalFormatted(key, params) : String.format(Locale.US, I18n.translateToFallback(key), params); } }
@SuppressWarnings("deprecation") public static String translateToLocal(String key) { if (I18n.canTranslate(key)) { return I18n.translateToLocal(key); } else { return I18n.translateToFallback(key); } }
@SuppressWarnings("deprecation") @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) { try { // Skip first line if this config is deactivated, as it will be part of display name int line = Configurations.blockDescriptions ? 1 : 2; String desc = getTooltipUnloc(stack); while (I18n.canTranslate(desc + line) || line == 1) { tooltip.add(net.minecraft.client.resources.I18n.format(desc + line)); desc.replaceAll(line++ + "$", "." + line); } } catch (Exception ignored) { tooltip.add(Chisel.MOD_ID + ".tooltip.invalid"); } }
public static String translateToLocal(String key) { if (I18n.canTranslate(key)) { return I18n.translateToLocal(key); } else { return I18n.translateToFallback(key); } }
public String localise(String key) { if (I18n.canTranslate(key)) { return I18n.translateToLocal(key); } else { return I18n.translateToFallback(key); } }
public static String translate(String key) { if (I18n.canTranslate(key)) { return I18n.translateToLocal(key); } else { return I18n.translateToFallback(key); } }
@Override public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn) { EntityLivingBase entitylivingbase = entityLivingBaseIn.getAttackingEntity(); String s = "death.attack." + this.damageType + String.valueOf(entityLivingBaseIn.getRNG().nextInt(totalAmount)); String s1 = s + ".player"; return entitylivingbase != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), entitylivingbase.getDisplayName()}): new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName()}); } }
@Override public ITextComponent getDeathMessage(EntityLivingBase defender) { String s = "death.attack." + this.damageType; String s1 = s + ".player"; return attacker != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {defender.getDisplayName(), attacker.getDisplayName()}) : new TextComponentTranslation(s, new Object[] {defender.getDisplayName()}); } };
@SuppressWarnings("deprecation") @Override public String getItemStackDisplayName(final ItemStack stack) { final FluidStack fluidStack = getFluid(stack); final String unlocalisedName = this.getUnlocalizedNameInefficiently(stack); if (fluidStack == null) return I18n.translateToLocal(unlocalisedName + ".name").trim(); final String fluidUnlocalisedName = unlocalisedName + ".filled." + fluidStack.getFluid().getName() + ".name"; if (I18n.canTranslate(fluidUnlocalisedName)) return I18n.translateToLocal(fluidUnlocalisedName); return I18n.translateToLocalFormatted(unlocalisedName + ".filled.name", fluidStack.getLocalizedName()); }
@Override public ITextComponent getDeathMessage(EntityLivingBase par1EntityLivingBase) { EntityLivingBase entitylivingbase1 = par1EntityLivingBase.getAttackingEntity(); String s = "death.attack." + this.damageType; String s1 = s + ".player"; return entitylivingbase1 != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, par1EntityLivingBase.getDisplayName(), entitylivingbase1.getDisplayName()) : new TextComponentTranslation(s, par1EntityLivingBase.getDisplayName()); } }
@Override public ITextComponent processStack(ItemStack stack) { ITextComponent component = new TextComponentString(""); component.appendSibling(stack.getTextComponent()); if (stack.hasDisplayName()) { String s = stack.getItem().getUnlocalizedName(stack); if (!I18n.canTranslate(s)) { s += ".name"; } ITextComponent component2 = new TextComponentTranslation(s); component2.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(s))); component.appendText(" (").appendSibling(component2).appendText(")"); } return component; } }, Id {