@@ -130,6 +130,7 @@ public void load() {
130
130
languageFilesManager .deploy ("en_us" , loadBuiltInFallback ());
131
131
// second, load the bundled language files
132
132
loadBundled ().forEach (languageFilesManager ::deploy );
133
+ loadBundledCrowdin ().forEach (languageFilesManager ::deploy );
133
134
// then, load the translations from Crowdin
134
135
// and don't forget fix missing
135
136
languageFilesManager .fillMissing (loadBuiltInFallback ());
@@ -230,6 +231,34 @@ private Map<String, YamlConfiguration> loadBundled() {
230
231
return availableLang ;
231
232
}
232
233
234
+ /**
235
+ * Loading translations from bundled resources
236
+ *
237
+ * @return The bundled translations, empty hash map if nothing can be load.
238
+ */
239
+ @ NotNull
240
+ @ SneakyThrows
241
+ private Map <String , YamlConfiguration > loadBundledCrowdin () {
242
+ Map <String , YamlConfiguration > availableLang = new HashMap <>();
243
+ URL url = Main .class .getClassLoader ().getResource ("" );
244
+ if (url == null ) {
245
+ return availableLang ;
246
+ }
247
+ PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver (Main .class .getClassLoader ());
248
+ var res = resourcePatternResolver .getResources ("classpath:crowdin/**/*.yml" );
249
+ for (Resource re : res ) {
250
+ String langName = URLUtil .getParentName (re .getURI ());
251
+ try {
252
+ YamlConfiguration configuration = new YamlConfiguration ();
253
+ configuration .loadFromString (new String (re .getContentAsByteArray (), StandardCharsets .UTF_8 ));
254
+ availableLang .put (langName .toLowerCase (Locale .ROOT ).replace ("-" , "_" ), configuration );
255
+ } catch (IOException | InvalidConfigurationException e ) {
256
+ log .warn ("Failed to load bundled Crowdin translation." , e );
257
+ }
258
+ }
259
+ return availableLang ;
260
+ }
261
+
233
262
/**
234
263
* Generate the override files storage path
235
264
*
0 commit comments