Skip to content

Commit

Permalink
clean: translation class more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Aug 1, 2023
1 parent 14b27ab commit 59479fc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
public class TranslationUtil {

// unlocked-cosmetic -> true -> True
private static HashMap<String, List<TranslationPair>> keys = new HashMap<>();
private static final HashMap<String, List<TranslationPair>> keys = new HashMap<>();

public static void setup(ConfigurationNode config) {
keys.clear();
for (ConfigurationNode node : config.childrenMap().values()) {
ArrayList<TranslationPair> pairs = new ArrayList<>();
for (ConfigurationNode translatableMessage : node.childrenMap().values()) {
String key = translatableMessage.key().toString();
key.replaceAll("'", ""); // Autoupdater adds ' to it? Removes it from the key
key = key.replaceAll("'", ""); // Autoupdater adds ' to it? Removes it from the key
TranslationPair pair = new TranslationPair(key, translatableMessage.getString());
pairs.add(pair);
MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node);
Expand All @@ -31,7 +32,7 @@ public static void setup(ConfigurationNode config) {
public static String getTranslation(String key, String message) {
List<TranslationPair> pairs = keys.get(key);
for (TranslationPair pair : pairs) {
if (pair.key() == message) return StringUtils.parseStringToString(pair.value());
if (pair.key().equals(message)) return StringUtils.parseStringToString(pair.value());
}

return message;
Expand Down

0 comments on commit 59479fc

Please sign in to comment.