Changeset 12644 in josm for trunk/src/org/openstreetmap/josm/tools/I18n.java
- Timestamp:
- 2017-08-25T15:17:01+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/I18n.java
r12627 r12644 2 2 package org.openstreetmap.josm.tools; 3 3 4 import java.awt.GraphicsEnvironment;5 4 import java.io.BufferedInputStream; 6 5 import java.io.File; … … 22 21 import java.util.jar.JarInputStream; 23 22 import java.util.zip.ZipEntry; 24 25 import javax.swing.JColorChooser;26 import javax.swing.JFileChooser;27 import javax.swing.UIManager;28 29 import org.openstreetmap.gui.jmapviewer.FeatureAdapter.TranslationAdapter;30 import org.openstreetmap.josm.gui.util.GuiHelper;31 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;32 23 33 24 /** … … 95 86 private static volatile String loadedCode = "en"; 96 87 97 /* Localization keys for file chooser (and color chooser). */ 98 private static final String[] JAVA_INTERNAL_MESSAGE_KEYS = new String[] { 99 /* JFileChooser windows laf */ 100 "FileChooser.detailsViewActionLabelText", 101 "FileChooser.detailsViewButtonAccessibleName", 102 "FileChooser.detailsViewButtonToolTipText", 103 "FileChooser.fileAttrHeaderText", 104 "FileChooser.fileDateHeaderText", 105 "FileChooser.fileNameHeaderText", 106 "FileChooser.fileNameLabelText", 107 "FileChooser.fileSizeHeaderText", 108 "FileChooser.fileTypeHeaderText", 109 "FileChooser.filesOfTypeLabelText", 110 "FileChooser.homeFolderAccessibleName", 111 "FileChooser.homeFolderToolTipText", 112 "FileChooser.listViewActionLabelText", 113 "FileChooser.listViewButtonAccessibleName", 114 "FileChooser.listViewButtonToolTipText", 115 "FileChooser.lookInLabelText", 116 "FileChooser.newFolderAccessibleName", 117 "FileChooser.newFolderActionLabelText", 118 "FileChooser.newFolderToolTipText", 119 "FileChooser.refreshActionLabelText", 120 "FileChooser.saveInLabelText", 121 "FileChooser.upFolderAccessibleName", 122 "FileChooser.upFolderToolTipText", 123 "FileChooser.viewMenuLabelText", 124 125 /* JFileChooser gtk laf */ 126 "FileChooser.acceptAllFileFilterText", 127 "FileChooser.cancelButtonText", 128 "FileChooser.cancelButtonToolTipText", 129 "FileChooser.deleteFileButtonText", 130 "FileChooser.filesLabelText", 131 "FileChooser.filterLabelText", 132 "FileChooser.foldersLabelText", 133 "FileChooser.newFolderButtonText", 134 "FileChooser.newFolderDialogText", 135 "FileChooser.openButtonText", 136 "FileChooser.openButtonToolTipText", 137 "FileChooser.openDialogTitleText", 138 "FileChooser.pathLabelText", 139 "FileChooser.renameFileButtonText", 140 "FileChooser.renameFileDialogText", 141 "FileChooser.renameFileErrorText", 142 "FileChooser.renameFileErrorTitle", 143 "FileChooser.saveButtonText", 144 "FileChooser.saveButtonToolTipText", 145 "FileChooser.saveDialogTitleText", 146 147 /* JFileChooser motif laf */ 148 //"FileChooser.cancelButtonText", 149 //"FileChooser.cancelButtonToolTipText", 150 "FileChooser.enterFileNameLabelText", 151 //"FileChooser.filesLabelText", 152 //"FileChooser.filterLabelText", 153 //"FileChooser.foldersLabelText", 154 "FileChooser.helpButtonText", 155 "FileChooser.helpButtonToolTipText", 156 //"FileChooser.openButtonText", 157 //"FileChooser.openButtonToolTipText", 158 //"FileChooser.openDialogTitleText", 159 //"FileChooser.pathLabelText", 160 //"FileChooser.saveButtonText", 161 //"FileChooser.saveButtonToolTipText", 162 //"FileChooser.saveDialogTitleText", 163 "FileChooser.updateButtonText", 164 "FileChooser.updateButtonToolTipText", 165 166 /* gtk color chooser */ 167 "GTKColorChooserPanel.blueText", 168 "GTKColorChooserPanel.colorNameText", 169 "GTKColorChooserPanel.greenText", 170 "GTKColorChooserPanel.hueText", 171 "GTKColorChooserPanel.nameText", 172 "GTKColorChooserPanel.redText", 173 "GTKColorChooserPanel.saturationText", 174 "GTKColorChooserPanel.valueText", 175 176 /* JOptionPane */ 177 "OptionPane.okButtonText", 178 "OptionPane.yesButtonText", 179 "OptionPane.noButtonText", 180 "OptionPane.cancelButtonText" 181 }; 88 182 89 private static volatile Map<String, String> strings; 183 90 private static volatile Map<String, String[]> pstrings; … … 679 586 } 680 587 681 /**682 * Localizations for file chooser dialog.683 * For some locales (e.g. de, fr) translations are provided684 * by Java, but not for others (e.g. ru, uk).685 */686 public static void translateJavaInternalMessages() {687 Locale l = Locale.getDefault();688 689 AbstractFileChooser.setDefaultLocale(l);690 JFileChooser.setDefaultLocale(l);691 JColorChooser.setDefaultLocale(l);692 for (String key : JAVA_INTERNAL_MESSAGE_KEYS) {693 String us = UIManager.getString(key, Locale.US);694 String loc = UIManager.getString(key, l);695 // only provide custom translation if it is not already localized by Java696 if (us != null && us.equals(loc)) {697 UIManager.put(key, tr(us));698 }699 }700 }701 702 588 private static int pluralEval(long n) { 703 589 switch(pluralMode) { … … 732 618 return 0; 733 619 } 734 735 public static TranslationAdapter getTranslationAdapter() {736 return I18n::tr;737 }738 739 /**740 * Setup special font for Khmer script, as the default Java fonts do not display these characters.741 *742 * @since 8282743 */744 public static void setupLanguageFonts() {745 // Use special font for Khmer script, as the default Java font do not display these characters746 if ("km".equals(LanguageInfo.getJOSMLocaleCode())) {747 Collection<String> fonts = Arrays.asList(748 GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());749 for (String f : new String[]{"Khmer UI", "DaunPenh", "MoolBoran"}) {750 if (fonts.contains(f)) {751 GuiHelper.setUIFont(f);752 break;753 }754 }755 }756 }757 620 }
Note:
See TracChangeset
for help on using the changeset viewer.