Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the infamous Turkish locale bug. #270

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void handle(FMLInterModComms.IMCMessage message) {
public static void addMachine(NBTTagCompound tag, ModContainer modContainer) {
String machine = tag.getString("machine");

String energy_mode = tag.getString(tag.getString("energy_mode")).toUpperCase();
String energy_mode = tag.getString(tag.getString("energy_mode")).toUpperCase(Locale.ENGLISH);
Machine.EnergyMode energyMode = Machine.EnergyMode.valueOf(energy_mode);

int energyBufferSize = tag.getInteger("energy_buffer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public PropertyEnumSimple(Class<T> valueClass, String name) {
Collections.sort(allowedValues);
propertyNames = new EnumMap<>(valueClass);
for (T t : allowedValues) {
String key = t.toString().toLowerCase();
String key = t.toString().toLowerCase(Locale.ENGLISH);
nameToValue.put(key, t);
propertyNames.put(t, key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected XUBlockStateCreator(XUBlock block, @Nonnull IProperty<? extends Compar
builder.append(".");
} else
flag = true;
builder.append(validState.getValue(dropProperty).toString().toLowerCase());
builder.append(validState.getValue(dropProperty).toString().toLowerCase(Locale.ENGLISH));
}

for (IMetaProperty<? extends Comparable> metaProperty : hiddenProperties) {
Expand All @@ -145,7 +145,7 @@ protected XUBlockStateCreator(XUBlock block, @Nonnull IProperty<? extends Compar
builder.append(".");
} else
flag = true;
builder.append(validState.getValue(metaProperty).toString().toLowerCase());
builder.append(validState.getValue(metaProperty).toString().toLowerCase(Locale.ENGLISH));
}


Expand Down Expand Up @@ -182,7 +182,7 @@ public static <T extends IProperty<Boolean>> EnumMap<EnumFacing, T> createDirect
MapPopulator.createMap(
Lists.newArrayList(EnumFacing.values()),
Lists.newArrayList(EnumFacing.values()).stream().map(input -> {
String dirName = input.getName().toLowerCase();
String dirName = input.getName().toLowerCase(Locale.ENGLISH);
if (name != null) dirName = name + "_" + dirName;
return function.apply(dirName, input);
}).collect(Collectors.toList())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EntryHandler {
public static void loadConfig(Configuration config) {
HashMap<String, Boolean> configEntries = Maps.newHashMap();
for (Entry entry : entries) {
entryHashMap.put(entry.name.toLowerCase(), entry);
entryHashMap.put(entry.name.toLowerCase(Locale.ENGLISH), entry);
configEntries.put(entry.name, config.get("Enabled", entry.getConfigLabel(), entry.isEnabledByDefault()).getBoolean());
entry.loadAdditionalConfig(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void addRecipes() {
public static ItemEntry<ItemDestructionWand> creativeDestructionWand = new ItemEntry<ItemDestructionWand>("ItemCreativeDestructionWand") {
@Override
public ItemDestructionWand initValue() {
return new ItemDestructionWand(name.toLowerCase().substring(4), name, new float[]{191 / 255F, 75 / 255F, 244 / 255F}, 49);
return new ItemDestructionWand(name.toLowerCase(Locale.ENGLISH).substring(4), name, new float[]{191 / 255F, 75 / 255F, 244 / 255F}, 49);
}
};
public static ItemEntry<ItemUnstableIngots> unstableIngots = new ItemClassEntry<ItemUnstableIngots>(ItemUnstableIngots.class) {
Expand Down Expand Up @@ -161,7 +161,7 @@ public void addRecipes() {
public static ItemEntry<ItemBuildersWand> buildersWand = new ItemEntry<ItemBuildersWand>("ItemBuildersWand") {
@Override
public ItemBuildersWand initValue() {
return new ItemBuildersWand(name, 9, name.toLowerCase().substring(4), new float[]{244 / 255F, 230 / 255F, 78 / 255F});
return new ItemBuildersWand(name, 9, name.toLowerCase(Locale.ENGLISH).substring(4), new float[]{244 / 255F, 230 / 255F, 78 / 255F});
}

@Override
Expand All @@ -177,7 +177,7 @@ public void addAchievements() {
public static ItemEntry<ItemDestructionWand> destructionWand = new ItemEntry<ItemDestructionWand>("ItemDestructionWand") {
@Override
public ItemDestructionWand initValue() {
return new ItemDestructionWand(name.toLowerCase().substring(4), name, new float[]{244 / 255F, 230 / 255F, 78 / 255F}, 9);
return new ItemDestructionWand(name.toLowerCase(Locale.ENGLISH).substring(4), name, new float[]{244 / 255F, 230 / 255F, 78 / 255F}, 9);
}

@Override
Expand Down Expand Up @@ -1590,7 +1590,7 @@ public void addRecipes() {
}

public void addClimographRecipe(BlockTerraformer.Type heater, Object lavaBucket) {
addShapeless("terraformer_" + heater.toString().toLowerCase(), getStack(heater), getBase(), lavaBucket, lavaBucket);
addShapeless("terraformer_" + heater.toString().toLowerCase(Locale.ENGLISH), getStack(heater), getBase(), lavaBucket, lavaBucket);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public BlockCompressed(IBlockState baseState, String texture, int max_n) {
this.max_n = max_n;
this.setHardness(2);
this.setResistance(10.0F);
property_compression = PropertyInteger.create("compression_level_" + texture.toLowerCase(), 1, max_n);
property_compression = PropertyInteger.create("compression_level_" + texture.toLowerCase(Locale.ENGLISH), 1, max_n);
setBlockState(new XUBlockStateCreator(this, false, property_compression));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Entry.class, new EntryDeserializer()
IResource resource = null;
try {
try {
resource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(ExtraUtils2.RESOURCE_FOLDER, "lang/book/" + currentLanguage.getLanguageCode().toLowerCase() + ".json"));
resource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(ExtraUtils2.RESOURCE_FOLDER, "lang/book/" + currentLanguage.getLanguageCode().toLowerCase(Locale.ENGLISH) + ".json"));
} catch (IOException | NullPointerException err) {
resource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(ExtraUtils2.RESOURCE_FOLDER, "lang/book/en_us.json"));
}
Expand Down Expand Up @@ -189,13 +189,13 @@ public static class EntryDeserializer implements JsonDeserializer<Entry> {

@Override
public Entry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String asString = json.getAsString().toLowerCase();
String asString = json.getAsString().toLowerCase(Locale.ENGLISH);
Entry entry = EntryHandler.entryHashMap.get(asString);
if (entry != null)
return entry;

for (Map.Entry<String, Entry> e : EntryHandler.entryHashMap.entrySet()) {
String key = e.getKey().toLowerCase();
String key = e.getKey().toLowerCase(Locale.ENGLISH);
if (key.contains(asString) || asString.contains(key)) {
return e.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void run() {
}

private static void registerEntity(Class<? extends Entity> clazz, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) {
String name = clazz.getSimpleName().toLowerCase();
String name = clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
if (name.startsWith("entity")) name = name.replace("entity", "");
CompatHelper.registerEntity(clazz, trackingRange, updateFrequency, sendsVelocityUpdates, name, id);
id++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Type getType(ItemStack stack) {
@Nonnull
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + "." + getType(stack).name().toLowerCase();
return super.getUnlocalizedName(stack) + "." + getType(stack).name().toLowerCase(Locale.ENGLISH);
}

@Override
Expand Down Expand Up @@ -730,7 +730,7 @@ public void addRecipes() {
Type(int meta, String oreName) {
this.meta = meta;
this.oreName = oreName;
texture = name().toLowerCase();
texture = name().toLowerCase(Locale.ENGLISH);
metaMap.put(meta, this);
if (meta < 0)
metaMap.put(meta + Short.MAX_VALUE, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int getEnergyOutput(@Nonnull ItemStack stack) {
}
}
for (String s : OreDictionary.getOreNames()) {
if (s.toLowerCase(Locale.ROOT).contains("pink")) {
if (s.toLowerCase(Locale.ENGLISH).contains("pink")) {
for (ItemStack itemStack : OreDictionary.getOres(s)) {
pinkThings.add(ItemRef.wrapCrafting(itemStack));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RedirectResourcePack implements IResourcePack {
IResourcePack xuPack;

public RedirectResourcePack(String name, HashSet<String> domains, String folderPrefix) {
this.name = name.toLowerCase();
this.name = name.toLowerCase(Locale.ENGLISH);
this.xuPack = FMLClientHandler.instance().getResourcePackFor(ExtraUtils2.MODID);
this.domains = domains;
this.prefix = folderPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public ItemRef getRef() {
if (j < 0) return ItemRef.NULL;
List<ItemRef> list = ContainerIndexer.this.list;

String filterText = widgetTextInput.getText().toLowerCase();
String filterText = widgetTextInput.getText().toLowerCase(Locale.ENGLISH);
if (!prevFilter.equals(filterText) || filteredList == null) {
prevFilter = filterText;
if (filterText.equals("")) {
Expand All @@ -657,7 +657,7 @@ public ItemRef getRef() {
mainLoop:
for (String s1 : split) {
for (String s2 : tooltip) {
if (s2.toLowerCase().contains(s1)) continue mainLoop;
if (s2.toLowerCase(Locale.ENGLISH).contains(s1)) continue mainLoop;
}

return false;
Expand Down
6 changes: 3 additions & 3 deletions 1.10.2/src/main/java/com/rwtema/extrautils2/utils/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static String makeKey(String text) {
@Nonnull
public static String stripText(String text) {
String t = text.replaceAll("([^A-Za-z\\s])", "").trim();
t = t.replaceAll("\\s+", ".").toLowerCase();
t = t.replaceAll("\\s+", ".").toLowerCase(Locale.ENGLISH);
if (t.length() > MAX_KEY_LEN) {
int n = t.indexOf('.', MAX_KEY_LEN);
if (n != -1)
Expand All @@ -141,7 +141,7 @@ public static String stripText(String text) {

public static String translate(String key, String _default) {
if (ExtraUtils2.deobf_folder && FMLLaunchHandler.side() == Side.CLIENT) {
if (!key.equals(key.toLowerCase())) {
if (!key.equals(key.toLowerCase(Locale.ENGLISH))) {
LogHelper.oneTimeInfo("Lang: " + key + " is not lowercased");
}

Expand Down Expand Up @@ -237,7 +237,7 @@ public static void createMissedFile() {
}
t = s;

out.println(key.toLowerCase() + "=" + value);
out.println(key.toLowerCase(Locale.ENGLISH) + "=" + value);
}
} finally {
if (out != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public static String capFirst(String s, boolean lowerCaseRest) {
if (s == null) return null;
int n = s.length();
if (n == 0) return s;
if (n == 1) return s.toUpperCase();
if (n == 1) return s.toUpperCase(Locale.ENGLISH);

return s.substring(0, 1).toUpperCase() + (lowerCaseRest ? s.substring(1).toLowerCase() : s.substring(1));
return s.substring(0, 1).toUpperCase(Locale.ENGLISH) + (lowerCaseRest ? s.substring(1).toLowerCase(Locale.ENGLISH) : s.substring(1));
}


Expand Down
2 changes: 1 addition & 1 deletion 1.10.2/src/test/java/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class Test {
// for (int i = 0; i < 3000; i++) {
// String input = "Nineteen";
// while (input.length() < 31999){
// input = input.toLowerCase(Locale.ENGLISH) + "#" + new String(salt(StringUtils.getBytesUtf8(input.toUpperCase()), new byte[]{1,2,4,8,16,32,64, -128, -1}));
// input = input.toLowerCase(Locale.ENGLISH) + "#" + new String(salt(StringUtils.getBytesUtf8(input.toUpperCase(Locale.ENGLISH)), new byte[]{1,2,4,8,16,32,64, -128, -1}));
// }
//
// byte[] s = StringUtils.getBytesUtf8(input + "#211");
Expand Down