mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-09-29 23:17:30 +02:00
Try and fix I18n
This commit is contained in:
parent
1a0b1d585d
commit
1975ffef0c
@ -49,27 +49,16 @@ public class I18n {
|
|||||||
finalKeys.add(jarObject);
|
finalKeys.add(jarObject);
|
||||||
} else {
|
} else {
|
||||||
String currentKey = String.valueOf(equivalentOnDisk.get("message"));
|
String currentKey = String.valueOf(equivalentOnDisk.get("message"));
|
||||||
String convertedKey = convertOldTranslations(currentKey);
|
String currentTranslation = String.valueOf(equivalentOnDisk.get("translation"));
|
||||||
|
convertKey(finalKeys, currentKey, currentTranslation);
|
||||||
if (!currentKey.equals(convertedKey)) { // Key needs conversion
|
|
||||||
String convertedValue = convertOldTranslations(String.valueOf(equivalentOnDisk.get("translation")));
|
|
||||||
|
|
||||||
// Remove current key from map of things to go to the disk
|
|
||||||
Iterator<Map<?, ?>> iter = finalKeys.iterator();
|
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
if (String.valueOf(iter.next().get("message")).equals(equivalentOnDisk.get("message"))) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the converted one.
|
|
||||||
finalKeys.add(ImmutableMap.of("message", convertedKey, "translation", convertedValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Map diskObject : configDisk.getMapList("messages")) {
|
||||||
|
convertKey(finalKeys, String.valueOf(diskObject.get("message")), String.valueOf(diskObject.get("translation")));
|
||||||
|
}
|
||||||
|
|
||||||
configDisk.set("messages", finalKeys);
|
configDisk.set("messages", finalKeys);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -91,6 +80,30 @@ public class I18n {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void convertKey(List<Map<?, ?>> finalKeys, String currentKey, String currentTranslation) {
|
||||||
|
String convertedKey = convertOldTranslations(currentKey);
|
||||||
|
|
||||||
|
if (!currentKey.equals(convertedKey)) { // Key needs conversion
|
||||||
|
String convertedValue = convertOldTranslations(String.valueOf(currentTranslation));
|
||||||
|
|
||||||
|
// Remove current key from map of things to go to the disk
|
||||||
|
Iterator<Map<?, ?>> iter = finalKeys.iterator();
|
||||||
|
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
if (String.valueOf(iter.next().get("message")).equals(currentKey)) {
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the converted one.
|
||||||
|
if (convertedValue.equals("null")) {
|
||||||
|
finalKeys.add(ImmutableMap.of("message", convertedKey));
|
||||||
|
} else {
|
||||||
|
finalKeys.add(ImmutableMap.of("message", convertedKey, "translation", convertedValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String convertOldTranslations(String input) {
|
private String convertOldTranslations(String input) {
|
||||||
Matcher m = Pattern.compile("(%s)").matcher(input);
|
Matcher m = Pattern.compile("(%s)").matcher(input);
|
||||||
StringBuffer converted = new StringBuffer();
|
StringBuffer converted = new StringBuffer();
|
||||||
|
Loading…
Reference in New Issue
Block a user