MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / loadLocales

Method loadLocales

The 5zig Mod/src/eu/the5zig/mod/I18n.java:262–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260 }
261
262 public static boolean loadLocales() {
263 File languageDir = new File(The5zigMod.getModDirectory(), PRE);
264 File[] languages = languageDir.listFiles();
265 if (languages == null)
266 return !I18n.languages.isEmpty();
267
268 boolean changed = false;
269 List<Locale> folderLocales = Lists.newArrayList();
270 for (File file : languages) {
271 if (file.isDirectory())
272 continue;
273 String name = file.getName();
274 if (name.length() <= END.length())
275 continue;
276 name = name.substring(0, name.length() - END.length());
277 Locale locale = deserialize(name);
278 if (locale == null)
279 continue;
280 folderLocales.add(locale);
281 if (!I18n.languages.contains(locale)) {
282 changed = true;
283 I18n.languages.add(locale);
284 if (locale.equals(currentLanguage))
285 loadPropertyBundle();
286 }
287 }
288 List<Locale> currentLanguages = Lists.newArrayList(I18n.languages);
289 currentLanguages.removeAll(folderLocales);
290 if (!currentLanguages.isEmpty()) {
291 I18n.languages.removeAll(currentLanguages);
292 changed = true;
293 }
294
295 if (currentLanguage != null && !I18n.languages.contains(currentLanguage)) {
296 currentLanguage = I18n.languages.get(0);
297 loadPropertyBundle();
298 }
299 return changed;
300 }
301
302 private static void checkUpdates() {
303 Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Update language thread").build()).execute(new Runnable() {

Callers 3

I18nClass · 0.95
runMethod · 0.95
tickMethod · 0.95

Calls 10

getModDirectoryMethod · 0.95
deserializeMethod · 0.95
loadPropertyBundleMethod · 0.95
isEmptyMethod · 0.80
getMethod · 0.65
getNameMethod · 0.45
lengthMethod · 0.45
addMethod · 0.45
containsMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected