Added the ability to have non-country-specific localizations

This allows us to have, e.g. 'fr', while being able to also distinguish 'fr-FR' and 'fr-CA', or in the case the language is mostly spoken in a single country (e.g. latvian) to only have 'lv' as the name of the file.
As the filename filter has been made drastically laxer than it previously was, it will also allow to create localizations "variants" which will probably be of no use to us, but it's allowed by the terms of the various ISO standards and therefore it's good to at least have the possibility to support that kind of thing.
This commit is contained in:
Florian CUNY 2019-08-27 13:19:00 +02:00
parent ead0b02454
commit bcb2f70eca

View File

@ -156,8 +156,8 @@ public class LocalesManager {
* @param localeFolder - locale folder location relative to the plugin's data folder
*/
public void loadLocalesFromFile(String localeFolder) {
// Filter for files of length 9 and ending with .yml
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml") && name.length() == 9;
// Filter for files ending with .yml with a name whose length is >= 6 (xx.yml)
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml") && name.length() >= 6;
// Get the folder
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + localeFolder);
@ -182,8 +182,7 @@ public class LocalesManager {
} catch (Exception e) {
BentoBox.getInstance().logError("Could not load '" + language.getName() + "' : " + e.getMessage()
+ " with the following cause '" + e.getCause() + "'." +
" The file has likely an invalid YML format or has been made unreadable during the process."
);
" The file has likely an invalid YML format or has been made unreadable during the process.");
}
}
}