Merge branch 'Development' into Widgets

This commit is contained in:
tichohidding
2025-11-27 17:19:17 +01:00
committed by GitHub
36 changed files with 551 additions and 364 deletions

View File

@@ -1,5 +1,10 @@
package org.toop.local;
import java.util.Locale;
import java.util.MissingResourceException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.toop.framework.resource.ResourceManager;
import org.toop.framework.resource.resources.LocalizationAsset;
@@ -15,6 +20,7 @@ public class AppContext {
private static Locale locale = Locale.forLanguageTag("en");
private static final ObjectProperty<Locale> localeProperty = new SimpleObjectProperty<>(locale);
private static final Logger logger = LogManager.getLogger(AppContext.class);
public static LocalizationAsset getLocalization() {
return localization;
@@ -30,7 +36,26 @@ public class AppContext {
}
public static String getString(String key) {
return localization.getString(key, locale);
assert localization != null;
// TODO: Gebruik ResourceBundle.getBundle() zodat de fallback automatisch gaat.
// Hiervoor zou de assetManager aangepast moeten worden.
try{ // Main return
return localization.getString(key, locale);
}
catch (MissingResourceException e) {
logger.error("Missing resource key: {}, in bundle: {}. ", key, locale, e);
}
try{ // Fallback return
return localization.getString(key, localization.getFallback());
}
catch (MissingResourceException e) {
logger.error("Missing resource key: {}, in default bundle!", key, e);
}
// Default return
return "MISSING RESOURCE";
}
public static StringBinding bindToKey(String key) {