Example usage for org.apache.wicket Localizer Localizer

List of usage examples for org.apache.wicket Localizer Localizer

Introduction

In this page you can find the example usage for org.apache.wicket Localizer Localizer.

Prototype

public Localizer() 

Source Link

Document

Create the utils instance class backed by the configuration information contained within the supplied application object.

Usage

From source file:de.inren.frontend.application.InRenApplication.java

License:Apache License

/**
 * I'm lazy some times. Don't throw exceptions when properties are missing,
 * just remind me with a default value (the key+locale).
 *///  w ww .j  a va 2s .  c o  m
private void initializeFailSafeLocalize() {
    Localizer localizer = new Localizer() {

        @Override
        public String getString(String key, Component component, IModel<?> model, Locale locale, String style,
                String defaultValue) throws MissingResourceException {
            try {
                return super.getString(key, component, model, locale, style, defaultValue);
            } catch (MissingResourceException e) {
                String variation = (component != null ? component.getVariation() : null);
                String cacheKey = getCacheKey(key, component, locale, style, variation);
                log.info("######### Missing: cacheKey=[" + cacheKey + "] " + e.getMessage());
                final String text = key + (locale == null ? "" : locale.getLanguage());
                return "[" + text + "]";
            }
        }

    };
    this.getResourceSettings().setLocalizer(localizer);
}