Skip to content

Commit f85e3bc

Browse files
authored
Load supported locales from locales.txt file (processing#1360)
Refactors Language.listSupported() to read supported language codes from a new locales.txt resource file instead of scanning available locales.
1 parent f8e1d97 commit f85e3bc

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ar
2+
ca
3+
de
4+
el
5+
en
6+
es
7+
fr
8+
it
9+
ja
10+
ko
11+
nl
12+
pt
13+
ru
14+
tr
15+
uk
16+
zh-CN
17+
zh-TW

app/src/processing/app/Language.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
package processing.app;
2323

2424
import processing.core.PApplet;
25-
import processing.data.StringList;
2625

2726
import java.io.File;
2827
import java.io.IOException;
@@ -114,19 +113,13 @@ private Language() {
114113

115114

116115
static private String[] listSupported() {
117-
StringList supported = new StringList();
118-
var locales = Locale.getAvailableLocales();
119116
var loader = Language.class.getClassLoader();
120-
for (var locale : locales) {
121-
var language = locale.toLanguageTag();
122-
var baseFilename = "languages/PDE_" + language + ".properties";
123-
var file = loader.getResource(baseFilename);
124-
if (file == null) {
125-
continue;
126-
}
127-
supported.append(language);
117+
try (var localeFile = loader.getResourceAsStream("languages/locales.txt")) {
118+
return PApplet.loadStrings(localeFile);
119+
} catch (IOException e) {
120+
e.printStackTrace();
128121
}
129-
return supported.toArray();
122+
return new String[]{"en"};
130123
}
131124

132125

0 commit comments

Comments
 (0)