()
| 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() { |
no test coverage detected