[1.7.10] Added some localization (#106)

* Some refactoring

* Some refactoring
Added some localization

* Added some localization
Fix wrong branch localization in page branch overview
Simplify some localization

* Simplify some localization

* Removed unused localize method

* Simplify some localization

* Removed proxy.localise method

* Simplify localization

* Added some localization

* Added some localization

* Added some localization

* Some refactoring
This commit is contained in:
Alexander Kornilov authored and mezz committed 2017-06-07 19:47:12 -07:00
1 parent 1ffaad9fcd
commit bd0dbc3e14
54 files changed
+394 -520

No files matched your search

@@ -94,13 +94,12 @@ public class ControlClimateBar extends Control implements ITooltip {
int main;
EnumTolerance tolerance;
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
if (!isHumidity) {
main = species.getTemperature().ordinal() - 1;
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceTemp();
} else {
main = species.getHumidity().ordinal();
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(Binnie.Genetics.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceHumid();
}
@@ -4,6 +4,7 @@ import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageSpecies;
import binnie.core.util.I18N;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.genetics.IAlleleSpecies;
@@ -14,10 +15,10 @@ public class PageSpeciesClimate extends PageSpecies {
public PageSpeciesClimate(IWidget parent, DatabaseTab tab) {
super(parent, tab);
new ControlTextCentered(this, 8.0f, "Climate");
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.climate"));
tempBar = new ControlClimateBar(this, 8, 24, 128, 12);
humidBar = new ControlClimateBar(this, 8, 42, 128, 12, true);
new ControlTextCentered(this, 70.0f, "Biomes");
new ControlTextCentered(this, 70.0f, I18N.localise("extrabees.gui.database.tab.species.biomes"));
biomes = new ControlBiomes(this, 8, 90, 8, 4);
}
@@ -8,9 +8,13 @@ import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageSpecies;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.TextJustification;
import binnie.core.util.I18N;
import binnie.genetics.genetics.AlleleHelper;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.core.genetics.alleles.EnumAllele;
public class PageSpeciesGenome extends PageSpecies {
protected ControlText title;
@@ -27,17 +31,17 @@ public class PageSpeciesGenome extends PageSpecies {
public PageSpeciesGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, "Genome");
new ControlText(this, new IArea(0.0f, 32.0f, 68.0f, 30.0f), "Speed:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 44.0f, 68.0f, 30.0f), "Lifespan:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 56.0f, 68.0f, 30.0f), "Fertility:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 68.0f, 68.0f, 30.0f), "Flowering:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 80.0f, 68.0f, 30.0f), "Territory:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 97.0f, 68.0f, 30.0f), "Behavior:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 109.0f, 68.0f, 30.0f), "Sunlight:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 121.0f, 68.0f, 30.0f), "Rain:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 138.0f, 68.0f, 30.0f), "Flower:", TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 155.0f, 68.0f, 30.0f), "Effect:", TextJustification.TOP_RIGHT);
title = new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.genome"));
new ControlText(this, new IArea(0.0f, 32.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.speed"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 44.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.lifespan"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 56.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.fertility"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 68.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.flowering"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 80.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.territory"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 97.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.behavior"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 109.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.sunlight"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 121.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.rain"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 138.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.flower"), TextJustification.TOP_RIGHT);
new ControlText(this, new IArea(0.0f, 155.0f, 68.0f, 30.0f), I18N.localise("extrabees.gui.database.tab.species.genome.effect"), TextJustification.TOP_RIGHT);
int x = 72;
speedText = new ControlText(this, new IArea(x, 32.0f, 72.0f, 30.0f), "", TextJustification.TOP_LEFT);
@@ -54,84 +58,84 @@ public class PageSpeciesGenome extends PageSpecies {
public static String rateFlowering(int flowering) {
if (flowering >= 99) {
return "Maximum";
return AlleleHelper.toDisplay(EnumAllele.Flowering.MAXIMUM);
}
if (flowering >= 35) {
return "Fastest";
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTEST);
}
if (flowering >= 30) {
return "Faster";
return AlleleHelper.toDisplay(EnumAllele.Flowering.FASTER);
}
if (flowering >= 25) {
return "Fast";
return AlleleHelper.toDisplay(EnumAllele.Flowering.FAST);
}
if (flowering >= 20) {
return "Normal";
return AlleleHelper.toDisplay(EnumAllele.Flowering.AVERAGE);
}
if (flowering >= 15) {
return "Slow";
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOW);
}
if (flowering >= 10) {
return "Slower";
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWER);
}
return "Slowest";
return AlleleHelper.toDisplay(EnumAllele.Flowering.SLOWEST);
}
public static String rateSpeed(float speed) {
if (speed >= 1.7f) {
return "Fastest";
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTEST);
}
if (speed >= 1.4f) {
return "Faster";
return AlleleHelper.toDisplay(EnumAllele.Speed.FASTER);
}
if (speed >= 1.2f) {
return "Fast";
return AlleleHelper.toDisplay(EnumAllele.Speed.FAST);
}
if (speed >= 1.0f) {
return "Normal";
return AlleleHelper.toDisplay(EnumAllele.Speed.NORMAL);
}
if (speed >= 0.8f) {
return "Slow";
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOW);
}
if (speed >= 0.6f) {
return "Slower";
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWER);
}
return "Slowest";
return AlleleHelper.toDisplay(EnumAllele.Speed.SLOWEST);
}
public static String rateLifespan(int life) {
if (life >= 70) {
return "Longest";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGEST);
}
if (life >= 60) {
return "Longer";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONGER);
}
if (life >= 50) {
return "Long";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.LONG);
}
if (life >= 45) {
return "Elongated";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.ELONGATED);
}
if (life >= 40) {
return "Normal";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.NORMAL);
}
if (life >= 35) {
return "Shortened";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTENED);
}
if (life >= 30) {
return "Short";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORT);
}
if (life >= 20) {
return "Shorter";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTER);
}
return "Shortest";
return AlleleHelper.toDisplay(EnumAllele.Lifespan.SHORTEST);
}
public static String tolerated(boolean t) {
if (t) {
return "Tolerated";
return I18N.localise("extrabees.gui.database.tab.species.genome.tolerated");
}
return "Not Tolerated";
return AlleleHelper.toDisplay(EnumTolerance.NONE);
}
@Override
@@ -144,31 +148,32 @@ public class PageSpeciesGenome extends PageSpecies {
IBeeGenome genome = Binnie.Genetics.getBeeRoot().templateAsGenome(template);
speedText.setValue(rateSpeed(genome.getSpeed()));
lifespanText.setValue(rateLifespan(genome.getLifespan()));
fertilityText.setValue(genome.getFertility() + " children");
fertilityText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.children", genome.getFertility()));
floweringText.setValue(rateFlowering(genome.getFlowering()));
int[] area = genome.getTerritory();
territoryText.setValue(area[0] + "x" + area[1] + "x" + area[2]);
String behavior = "Daytime";
if (genome.getPrimary().isNocturnal()) {
behavior = "Nighttime";
}
String behavior;
if (genome.getNocturnal()) {
behavior = "All Day";
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.allDay");
} else if (genome.getPrimary().isNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.nighttime");
} else {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.daytime");
}
nocturnalText.setValue(behavior);
if (genome.getCaveDwelling()) {
caveDwellingText.setValue("Not Needed");
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.notNeeded"));
} else {
caveDwellingText.setValue("Required");
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.required"));
}
tolerantFlyerText.setValue(tolerated(genome.getTolerantFlyer()));
if (genome.getFlowerProvider() != null) {
flowerText.setValue(genome.getFlowerProvider().getDescription());
} else {
flowerText.setValue("None");
flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
}
effectText.setValue(genome.getEffect().getName());
}
@@ -12,7 +12,9 @@ import binnie.core.craftgui.database.PageSpeciesOverview;
import binnie.core.craftgui.database.PageSpeciesResultant;
import binnie.core.craftgui.database.WindowAbstractDatabase;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.util.I18N;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.gui.database.product.PageSpeciesProducts;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
@@ -46,6 +48,6 @@ public class WindowApiaristDatabase extends WindowAbstractDatabase {
@Override
public String getName() {
return "Database";
return I18N.localise("extrabees.gui.database");
}
}
@@ -1,4 +1,4 @@
package binnie.extrabees.gui.database;
package binnie.extrabees.gui.database.product;
import binnie.Binnie;
import binnie.core.BinnieCore;
@@ -12,16 +12,17 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class ControlProductsBox extends ControlListBox<ControlProductsBox.Product> {
public class ControlProductsBox extends ControlListBox<Product> {
protected IAlleleBeeSpecies species;
private Type type;
private ProductType type;
public ControlProductsBox(IWidget parent, int x, int y, int width, int height, Type type) {
public ControlProductsBox(IWidget parent, int x, int y, int width, int height, ProductType type) {
super(parent, x, y, width, height, 12.0f);
species = null;
this.type = type;
species = null;
}
@Override
@@ -44,31 +45,17 @@ public class ControlProductsBox extends ControlListBox<ControlProductsBox.Produc
.getProductionModifier(genome, 1.0f);
List<Product> strings = new ArrayList<>();
if (type == Type.Products) {
for (Map.Entry<ItemStack, Float> entry : species.getProductChances().entrySet()) {
strings.add(new Product(entry.getKey(), speed * modeSpeed * entry.getValue()));
}
Set<Map.Entry<ItemStack, Float>> chances;
if (type == ProductType.PRODUCTS) {
chances = species.getProductChances().entrySet();
} else {
for (Map.Entry<ItemStack, Float> entry : species.getSpecialtyChances().entrySet()) {
strings.add(new Product(entry.getKey(), speed * modeSpeed * entry.getValue()));
}
chances = species.getSpecialtyChances().entrySet();
}
for (Map.Entry<ItemStack, Float> entry : chances) {
strings.add(new Product(entry.getKey(), speed * modeSpeed * entry.getValue()));
}
setOptions(strings);
}
}
enum Type {
Products,
Specialties
}
class Product {
protected ItemStack item;
protected float chance;
public Product(ItemStack item, float chance) {
this.item = item;
this.chance = chance;
}
}
}
@@ -1,4 +1,4 @@
package binnie.extrabees.gui.database;
package binnie.extrabees.gui.database.product;
import binnie.core.craftgui.controls.ControlText;
import binnie.core.craftgui.controls.ControlTextCentered;
@@ -11,10 +11,10 @@ import binnie.core.util.I18N;
import java.text.DecimalFormat;
public class ControlProductsItem extends ControlOption<ControlProductsBox.Product> {
public class ControlProductsItem extends ControlOption<Product> {
protected ControlItemDisplay item;
public ControlProductsItem(ControlList<ControlProductsBox.Product> controlList, ControlProductsBox.Product value, int y) {
public ControlProductsItem(ControlList<Product> controlList, Product value, int y) {
super(controlList, value, y);
(item = new ControlItemDisplay(this, 4.0f, 4.0f)).setTooltip();
ControlText textWidget = new ControlTextCentered(this, 2.0f, "");
@@ -1,25 +1,24 @@
package binnie.extrabees.gui.database;
package binnie.extrabees.gui.database.product;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.ControlText;
import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.database.DatabaseTab;
import binnie.core.craftgui.database.PageSpecies;
import binnie.core.util.I18N;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.genetics.IAlleleSpecies;
public class PageSpeciesProducts extends PageSpecies {
protected ControlText title;
protected ControlProductsBox products;
protected ControlText title2;
protected ControlProductsBox specialties;
public PageSpeciesProducts(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8.0f, "Products");
products = new ControlProductsBox(this, 4, 20, 136, 48, ControlProductsBox.Type.Products);
title2 = new ControlTextCentered(this, 68.0f, "Specialties");
specialties = new ControlProductsBox(this, 4, 80, 136, 48, ControlProductsBox.Type.Specialties);
new ControlTextCentered(this, 8.0f, I18N.localise("extrabees.gui.database.tab.species.products"));
products = new ControlProductsBox(this, 4, 20, 136, 48, ProductType.PRODUCTS);
new ControlTextCentered(this, 68.0f, I18N.localise("extrabees.gui.database.tab.species.specialties"));
specialties = new ControlProductsBox(this, 4, 80, 136, 48, ProductType.SPECIALTIES);
}
@Override
@@ -0,0 +1,13 @@
package binnie.extrabees.gui.database.product;
import net.minecraft.item.ItemStack;
public class Product {
protected ItemStack item;
protected float chance;
public Product(ItemStack item, float chance) {
this.item = item;
this.chance = chance;
}
}
@@ -0,0 +1,6 @@
package binnie.extrabees.gui.database.product;
public enum ProductType {
PRODUCTS,
SPECIALTIES
}