Example usage for org.apache.wicket.core.util.resource.locator IResourceNameIterator getLocale

List of usage examples for org.apache.wicket.core.util.resource.locator IResourceNameIterator getLocale

Introduction

In this page you can find the example usage for org.apache.wicket.core.util.resource.locator IResourceNameIterator getLocale.

Prototype

Locale getLocale();

Source Link

Document

Get the exact Locale which has been used for the latest resource path.

Usage

From source file:com.evolveum.midpoint.web.util.MidPointResourceStreamLocator.java

License:Apache License

@Override
public IResourceStream locate(Class<?> clazz, String path, String style, String variation, Locale locale,
        String extension, boolean strict) {
    IResourceStream stream = null;//from  w w  w  .  j  a  va  2  s  .  c o  m

    // If path contains a locale, then it'll replace the locale provided to this method
    ResourceUtils.PathLocale data = ResourceUtils.getLocaleFromFilename(path);
    if ((data != null) && (data.locale != null)) {
        path = data.path;
        locale = data.locale;
    }

    // Try the various combinations of style, locale and extension to find the resource.
    IResourceNameIterator iter = newResourceNameIterator(path, locale, style, variation, extension, strict);
    while (iter.hasNext()) {
        String newPath = iter.next();

        stream = locate(clazz, newPath);

        if (stream != null) {
            stream.setLocale(iter.getLocale());
            stream.setStyle(iter.getStyle());
            stream.setVariation(iter.getVariation());
            break;
        }
    }

    return stream;
}