Changeset 8232 in josm
- Timestamp:
- 2015-04-19T13:12:20+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java
r8207 r8232 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trc;6 5 7 6 import java.awt.Component; … … 28 27 import org.openstreetmap.josm.tools.GBC; 29 28 import org.openstreetmap.josm.tools.I18n; 29 import org.openstreetmap.josm.tools.LanguageInfo; 30 30 31 31 /** … … 73 73 else 74 74 return Main.pref.put("language", 75 ((Locale)langCombo.getSelectedItem() ).toString());75 LanguageInfo.getJOSMLocaleCode((Locale)langCombo.getSelectedItem())); 76 76 } 77 77 … … 87 87 setSelectedItem(null); 88 88 if (language != null) { 89 language = LanguageInfo.getJavaLocaleCode(language); 89 90 for (Locale locale: data) { 90 91 if (locale == null) { … … 121 122 l == null 122 123 ? tr("Default (Auto determined)") 123 : "ca__valencia".equals(l.toString()) 124 ? trc("language", "Valencian") 125 : l.getDisplayName(l), 124 : LanguageInfo.getDisplayName(l), 126 125 index, isSelected, cellHasFocus); 127 126 } -
trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java
r8227 r8232 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.openstreetmap.josm.tools.I18n.trc; 3 5 4 6 import java.util.Locale; … … 107 109 * Replies the locale code used by Java for a given locale. 108 110 * 111 * @param locale the locale. Replies "en" if null. 112 * @return the Java code for the given locale 113 * @since 8232 114 */ 115 public static String getJavaLocaleCode(String localeName) { 116 if (localeName == null) return "en"; 117 if ("ca@valencia".equals(localeName)) { 118 localeName = "ca__valencia"; 119 } else if ("he".equals(localeName)) { 120 localeName = "iw_IL"; 121 } else if ("id".equals(localeName)) { 122 localeName = "in"; 123 } 124 return localeName; 125 } 126 127 /** 128 * Replies the display string used by JOSM for a given locale. 129 * 130 * In most cases returns text replied by {@link Locale#getDisplayName()}, for some 131 * locales an override is used (i.e. when unsupported by Java). 132 * 133 * @param locale the locale. Replies "en" if null. 134 * @return the display string for the given locale 135 * @since 8232 136 */ 137 public static String getDisplayName(Locale locale) { 138 String full = locale.toString(); 139 if ("ca__valencia".equals(full)) 140 return trc("language", "Valencian"); 141 142 return locale.getDisplayName(); 143 } 144 145 /** 146 * Replies the locale code used by Java for a given locale. 147 * 109 148 * In most cases JOSM and Java uses the same codes, but for some exceptions this is needed. 110 149 * … … 113 152 */ 114 153 public static Locale getLocale(String localeName) { 115 if ("ca@valencia".equals(localeName)) { 154 localeName = getJavaLocaleCode(localeName); 155 if ("ca__valencia".equals(localeName)) { 116 156 return new Locale("ca", "", "valencia"); 117 }118 if ("he".equals(localeName)) {119 localeName = "iw_IL";120 }121 else if ("id".equals(localeName)) {122 localeName = "in";123 157 } 124 158 Locale l;
Note:
See TracChangeset
for help on using the changeset viewer.