@Test public void testCreateTypeLocale_onlyLang() throws IOException { final File file = createTestFile(workingFolder, "en"); List<TypeLocale> tls = PropertiesExtensionManager.createTypeLocales(file.toURI().toURL()); assertNotNull(tls); assertEquals(1, tls.size()); assertEquals(TYPE, tls.get(0).type); assertEquals(new Locale("en"), tls.get(0).locale); }
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) { 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)) { 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 { List<TypeLocale> tls = new ArrayList<>(2); String type = name.substring(0, _last); String lang = name.substring(_last + 1); tls.add(new TypeLocale(type, new Locale(lang, ""))); String part = name.substring(_first + 1, _last); int _partLast = part.lastIndexOf('_'); String country = name.substring(_last + 1); if (-1 == _partLast) { type = name.substring(0, _first); lang = part; } else { 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 Collections.emptyList(); }
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) { 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)) { 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 { List<TypeLocale> tls = new ArrayList<>(2); String type = name.substring(0, _last); String lang = name.substring(_last + 1); tls.add(new TypeLocale(type, new Locale(lang, ""))); String part = name.substring(_first + 1, _last); int _partLast = part.lastIndexOf('_'); String country = name.substring(_last + 1); if (-1 == _partLast) { type = name.substring(0, _first); lang = part; } else { 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 Collections.emptyList(); } }
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) { 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)) { 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 { List<TypeLocale> tls = new ArrayList<>(2); String type = name.substring(0, _last); String lang = name.substring(_last + 1); tls.add(new TypeLocale(type, new Locale(lang, ""))); String part = name.substring(_first + 1, _last); int _partLast = part.lastIndexOf('_'); String country = name.substring(_last + 1); if (-1 == _partLast) { type = name.substring(0, _first); lang = part; } else { 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 Collections.emptyList(); }  }
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) { 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)) { 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 { List<TypeLocale> tls = new ArrayList<>(2); String type = name.substring(0, _last); String lang = name.substring(_last + 1); tls.add(new TypeLocale(type, new Locale(lang, ""))); String part = name.substring(_first + 1, _last); int _partLast = part.lastIndexOf('_'); String country = name.substring(_last + 1); if (-1 == _partLast) { type = name.substring(0, _first); lang = part; } else { 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 Collections.emptyList(); }   }
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) { 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)) { 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 { List<TypeLocale> tls = new ArrayList<>(2); String type = name.substring(0, _last); String lang = name.substring(_last + 1); tls.add(new TypeLocale(type, new Locale(lang, ""))); String part = name.substring(_first + 1, _last); int _partLast = part.lastIndexOf('_'); String country = name.substring(_last + 1); if (-1 == _partLast) { type = name.substring(0, _first); lang = part; } else { 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 Collections.emptyList(); }    }