1. Overriding
The default i18n strings can be overridden by implementing Resources and registering the implementation with the ServiceLoader.
package is.codion.demos.chinook.i18n;
import is.codion.common.resource.Resources;
import is.codion.framework.i18n.FrameworkMessages;
import java.util.Locale;
/**
* Replace the english modified warning text and title.
*/
public final class ChinookResources implements Resources {
private static final String FRAMEWORK_MESSAGES =
FrameworkMessages.class.getName();
private final boolean english = Locale.getDefault()
.equals(new Locale("en", "EN"));
@Override
public String getString(String baseBundleName, String key, String defaultString) {
if (english && baseBundleName.equals(FRAMEWORK_MESSAGES)) {
return switch (key) {
case "modified_warning" -> "Unsaved changes will be lost, continue?";
case "modified_warning_title" -> "Unsaved changes";
default -> defaultString;
};
}
return defaultString;
}
}
module is.codion.demos.chinook {
...
provides is.codion.common.resource.Resources
with is.codion.demos.chinook.domain.impl.ChinookResources;
}
See Chinook demo.
2. i18n Property Values
For a complete reference of all available i18n property keys and their default values, see i18n Property Values Reference.