diff options
| author | ilotterytea <iltsu@alright.party> | 2024-10-25 12:16:44 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-10-25 12:16:44 +0500 |
| commit | 354e2876e93bf45ca6b748e9eb23093fe9bffaa6 (patch) | |
| tree | 8637b646a6176b4808695d714443839c2624a961 /core/src/kz/ilotterytea/maxon/utils | |
| parent | f416c899aa619b21fad2f96f5f5a4475024557db (diff) | |
feat: LocalizationManager + removed unused lines and classes
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/utils')
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/utils/I18N.java | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/core/src/kz/ilotterytea/maxon/utils/I18N.java b/core/src/kz/ilotterytea/maxon/utils/I18N.java deleted file mode 100644 index 7d4013e..0000000 --- a/core/src/kz/ilotterytea/maxon/utils/I18N.java +++ /dev/null @@ -1,53 +0,0 @@ -package kz.ilotterytea.maxon.utils; - -import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.utils.JsonReader; -import com.badlogic.gdx.utils.JsonValue; - -import java.lang.StringBuilder; -import java.util.*; - -public class I18N { - private Map<String, String> language = new HashMap<>(); - private FileHandle fileHandle; - - public I18N(FileHandle fh) { - fileHandle = fh; - - JsonValue json = new JsonReader().parse(fileHandle); - - for (JsonValue val : json.iterator()) { - this.language.put(val.name, json.getString(val.name)); - } - } - - public FileHandle getFileHandle() { return fileHandle; } - public Map<String, String> getLanguage() { return language; } - - public String TranslatableText(String id) { - if (language.containsKey(id)) { - return language.get(id); - } - return null; - } - - public String FormattedText(String id, CharSequence... params) { - if (!language.containsKey(id)) { return null; } - Scanner scan = new Scanner(language.get(id)); - StringBuilder result = new StringBuilder(); - int index = 0; - - while (scan.hasNext()) { - String next = scan.next(); - - if (next.contains("%s")) { - next = next.replace("%s", params[index]); - if (index + 1 < params.length) { index++; } - } - - result.append(next).append(' '); - } - - return result.toString(); - } -} |
