Example usage for org.apache.wicket.util.resource ResourceUtils getLocaleFromFilename

List of usage examples for org.apache.wicket.util.resource ResourceUtils getLocaleFromFilename

Introduction

In this page you can find the example usage for org.apache.wicket.util.resource ResourceUtils getLocaleFromFilename.

Prototype

public static PathLocale getLocaleFromFilename(String path) 

Source Link

Document

Extract the locale from the filename taking into account possible minimized resource name.

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;/*ww w  .j  a va2s.com*/

    // 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;
}