Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java
r15427 r15661 16 16 import org.openstreetmap.josm.data.preferences.StringProperty; 17 17 import org.openstreetmap.josm.spi.preferences.Config; 18 import org.openstreetmap.josm.tools.LanguageInfo; 18 19 19 20 /** … … 289 290 */ 290 291 public static SystemOfMeasurement getDefault() { 291 switch (Locale.getDefault().getCountry()) { 292 final String country = Optional.ofNullable(System.getenv("LC_MEASUREMENT")) 293 .map(LanguageInfo::getLocale) 294 .orElse(Locale.getDefault()) 295 .getCountry(); 296 switch (country) { 292 297 case "US": 293 298 // https://en.wikipedia.org/wiki/Metrication_in_the_United_States#Current_use -
trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java
r15547 r15661 203 203 * Replies the locale used by Java for a given language code. 204 204 * 205 * Accepts JOSM and Javacodes as input.205 * Accepts JOSM, Java and POSIX codes as input. 206 206 * 207 207 * @param localeName the locale code. … … 211 211 */ 212 212 public static Locale getLocale(String localeName, boolean useDefaultCountry) { 213 final int encoding = localeName.indexOf('.'); 214 if (encoding > 0) { 215 localeName = localeName.substring(0, encoding); 216 } 213 217 int country = localeName.indexOf('_'); 214 218 int variant = localeName.indexOf('@'); -
trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java
r14811 r15661 63 63 64 64 /** 65 * Unit test of {@link LanguageInfo#getLocale}. 66 */ 67 @Test 68 public void testGetLocale() { 69 Assert.assertEquals(RU, LanguageInfo.getLocale("ru")); 70 Assert.assertEquals(EN_GB, LanguageInfo.getLocale("en_GB")); 71 Assert.assertEquals(CA_ES_VALENCIA, LanguageInfo.getLocale("ca_ES@valencia")); 72 Assert.assertEquals(DE_DE, LanguageInfo.getLocale("de_DE")); 73 Assert.assertEquals(DE_DE, LanguageInfo.getLocale("de_DE.UTF-8")); // LANG, LC_MEASUREMENT 74 Assert.assertEquals(PT_BR, LanguageInfo.getLocale("pt_BR.UTF-8")); // LANG, LC_MEASUREMENT 75 } 76 77 /** 65 78 * Unit test of {@link LanguageInfo#getJOSMLocaleCode}. 66 79 */
Note:
See TracChangeset
for help on using the changeset viewer.