[ 
https://issues.apache.org/jira/browse/SLING-877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678709#action_12678709
 ] 

Jukka Zitting commented on SLING-877:
-------------------------------------

I would even question the need for the Locale.getISOLanguages() and 
Locale.getISOCountries() calls in the method. A Locale instance is just an 
identifier of the desired locale, so I'd argue that we should use the 
user-specified value as-is without trying to filter or map it according to what 
values the system may know about.

The method could well be something as simple as this:

    String[] parts = localeString.split("_");
    switch (parts.length) {
    case 0: // empty locale string, use the default
        return Locale.getDefault();
    case 1: // only language
        return new Locale(parts[0]);
    case 2: // country is also available
        return new Locale(parts[0], parts[1]);
    case 3: // language, country and variant
    default: // ... and skip everything after that
        return new Locale(parts[0], parts[1], parts[2]);
    }


> Avoid calling Locale.getAvailableLocales() because it is very slow
> ------------------------------------------------------------------
>
>                 Key: SLING-877
>                 URL: https://issues.apache.org/jira/browse/SLING-877
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Thomas Mueller
>         Attachments: JcrResourceBundleProvider.patch
>
>
> Currently, JcrResourceBundleProvider.toLocale calls 
> Locale.getAvailableLocales().
> The first call to this method is very slow (3.4 seconds on my machine) because
> it scans many jar files.
> http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?view=markup
> It looks like calling this method is not required.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to