mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Merge branch 'Development' into Widgets
This commit is contained in:
@@ -63,6 +63,9 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
/** Returns the fallback locale used when locale is missing argument*/
|
||||
public Locale getFallback() {return this.fallback;}
|
||||
|
||||
/**
|
||||
* Checks whether this asset has been loaded.
|
||||
*
|
||||
@@ -126,7 +129,7 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
||||
public void loadFile(File file) {
|
||||
try (InputStreamReader reader =
|
||||
new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
||||
Locale locale = extractLocale(file.getName(), baseName);
|
||||
Locale locale = extractLocale(file.getName());
|
||||
bundles.put(locale, new PropertyResourceBundle(reader));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load localization file: " + file, e);
|
||||
@@ -166,10 +169,9 @@ public class LocalizationAsset extends BaseResource implements LoadableResource,
|
||||
* Extracts a locale from a file name based on the pattern "base_LOCALE.properties".
|
||||
*
|
||||
* @param fileName the file name
|
||||
* @param baseName the base name
|
||||
* @return extracted locale, or fallback if none found
|
||||
*/
|
||||
private Locale extractLocale(String fileName, String baseName) {
|
||||
private Locale extractLocale(String fileName) {
|
||||
int underscoreIndex = fileName.indexOf('_');
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
if (underscoreIndex > 0 && dotIndex > underscoreIndex) {
|
||||
|
||||
Reference in New Issue
Block a user