class PropertiesExtensionManager {

    static List<TypeLocale> createTypeLocales(final URL url) {
        final String fullPath = url.getFile();
        if (!fullPath.endsWith(MessagesProvider.EXT)) {
            return Collections.emptyList();
        }
        int pathIndex = fullPath.lastIndexOf('/');
        if (-1 == pathIndex) {
            pathIndex = fullPath.lastIndexOf('\\');
        }
        String fullname = fullPath;
        if (-1 != pathIndex) { // remove path
            fullname = fullPath.substring(pathIndex + 1);
        }
        String name = fullname.substring(0, fullname.lastIndexOf(MessagesProvider.EXT));

        if (name.contains(UL)) {

            int _first = name.indexOf(UL);
            int _last = name.lastIndexOf(UL);

            if (Objects.equals(_first, _last)) { // only one lang, like XXX_zh
                String type = name.substring(0, _first);
                String lang = name.substring(_last + 1);
                if (!lang.isEmpty()) {
                    return Arrays.asList(new TypeLocale(type, new Locale(lang, "")));
                }
            } else { // more underline
                List<TypeLocale> tls = new ArrayList<>(2);

                // like for versioning, XXX_v10_en or XXX_0_11_en
                String type = name.substring(0, _last);
                String lang = name.substring(_last + 1);
                tls.add(new TypeLocale(type, new Locale(lang, "")));

                // FIXME, let it after versioning, because don't provide it with country normally.
                String part = name.substring(_first + 1, _last);
                int _partLast = part.lastIndexOf('_');

                String country = name.substring(_last + 1);
                if (-1 == _partLast) { // only 2
                    // like XXX_en_US
                    type = name.substring(0, _first);
                    lang = part;

                } else { // >2
                    // like XXX_0_11_en_US
                    type = name.substring(0, _first) + UL + part.substring(0, _partLast);
                    lang = part.substring(_partLast + 1);
                }
                tls.add(new TypeLocale(type, new Locale(lang, country)));
                return tls;

            }

        } else {
            // return Arrays.asList(new TypeLocale(name, Locale.ROOT));
        }
        return Collections.emptyList();

    }

}