Skip to content

Commit

Permalink
feat: add Indonesian translation (PR #2018)
Browse files Browse the repository at this point in the history
* Add Indonesian translation

* fix load i18n resources with deprecated language codes

---------

Co-authored-by: Skylot <[email protected]>
  • Loading branch information
abazure and skylot authored Sep 20, 2023
1 parent c39a696 commit 8f0d0e4
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jadx-gui/src/main/java/jadx/gui/utils/NLS.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jadx.gui.utils;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
Expand Down Expand Up @@ -39,6 +38,7 @@ public class NLS {
LANG_LOCALES.add(new LangLocale("ko", "KR"));
LANG_LOCALES.add(new LangLocale("pt", "BR"));
LANG_LOCALES.add(new LangLocale("ru", "RU"));
LANG_LOCALES.add(new LangLocale("id", "ID"));

LANG_LOCALES.forEach(NLS::load);

Expand All @@ -50,20 +50,20 @@ public class NLS {
private NLS() {
}

private static void load(LangLocale locale) {
ResourceBundle bundle;
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
String resName = String.format("i18n/Messages_%s.properties", locale.get());
URL bundleUrl = classLoader.getResource(resName);
private static void load(LangLocale lang) {
Locale locale = lang.get();
String resName = String.format("i18n/Messages_%s.properties", locale.toLanguageTag().replace('-', '_'));
URL bundleUrl = NLS.class.getClassLoader().getResource(resName);
if (bundleUrl == null) {
throw new JadxRuntimeException("Locale resource not found: " + resName);
}
ResourceBundle bundle;
try (Reader reader = new InputStreamReader(bundleUrl.openStream(), StandardCharsets.UTF_8)) {
bundle = new PropertyResourceBundle(reader);
} catch (IOException e) {
} catch (Exception e) {
throw new JadxRuntimeException("Failed to load " + resName, e);
}
LANG_LOCALES_MAP.put(locale, bundle);
LANG_LOCALES_MAP.put(lang, bundle);
}

public static String str(String key) {
Expand Down
Loading

0 comments on commit 8f0d0e4

Please sign in to comment.