mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-11-26 12:05:46 +01:00
Try and fix I18n
This commit is contained in:
parent
1a0b1d585d
commit
1975ffef0c
@ -49,25 +49,14 @@ public class I18n {
|
||||
finalKeys.add(jarObject);
|
||||
} else {
|
||||
String currentKey = String.valueOf(equivalentOnDisk.get("message"));
|
||||
String convertedKey = convertOldTranslations(currentKey);
|
||||
|
||||
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();
|
||||
}
|
||||
String currentTranslation = String.valueOf(equivalentOnDisk.get("translation"));
|
||||
convertKey(finalKeys, currentKey, currentTranslation);
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -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) {
|
||||
Matcher m = Pattern.compile("(%s)").matcher(input);
|
||||
StringBuffer converted = new StringBuffer();
|
||||
|
Loading…
Reference in New Issue
Block a user