Browse Source

Merge pull request #456 in BA/design from ~RICHIE/design:master to master

* commit 'f7c12ec7513e5eed6106fa5a8d7af1274ba2f04f':
  自定义国际化在web端也能支持
master
superman 8 years ago
parent
commit
791861a200
  1. 75
      designer_base/src/com/fr/design/actions/file/LocalePane.java

75
designer_base/src/com/fr/design/actions/file/LocalePane.java

@ -8,13 +8,7 @@ import java.awt.BorderLayout;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.RowFilter; import javax.swing.RowFilter;
@ -31,10 +25,7 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.FRLogger; import com.fr.general.*;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -43,12 +34,6 @@ import com.fr.stable.project.ProjectConstants;
* @since : 8.0 * @since : 8.0
*/ */
public class LocalePane extends BasicPane { public class LocalePane extends BasicPane {
private static final String FR = "fr.properties";
private static final String US = "fr_en_US.properties";
private static final String CN = "fr_zh_CN.properties";
private static final String JP = "fr_ja_JP.properties";
private static final String TW = "fr_zh_TW.properties";
private static final String KR = "fr_ko_KR.properties";
private static final String PREFIX = "fr_"; private static final String PREFIX = "fr_";
private static final int LOCALE_NAME_LEN = 5; private static final int LOCALE_NAME_LEN = 5;
@ -124,39 +109,35 @@ public class LocalePane extends BasicPane {
} }
private void initPredefinedProperties() { private void initPredefinedProperties() {
Properties fr = loadLocaleProperties(FR); Map<Locale, LocalePackage> map = Inter.getPredefinedPackageMap();
Properties us = loadLocaleProperties(US); LocalePackage chinese = map.get(Locale.SIMPLIFIED_CHINESE);
Properties cn = loadLocaleProperties(CN);
Properties jp = loadLocaleProperties(JP); List<String> sortKeys = new ArrayList<String>();
Properties tw = loadLocaleProperties(TW);
Properties kr = loadLocaleProperties(KR);
Set<ResourceBundle> bundles = chinese.getKindsOfResourceBundle();
Set<String> keys = fr.stringPropertyNames(); for (ResourceBundle bundle : bundles) {
List<String> sortKeys = new ArrayList<String>(keys); sortKeys.addAll(bundle.keySet());
}
Collections.sort(sortKeys); Collections.sort(sortKeys);
Vector<String> keyVector = new Vector<String>();
Vector<String> valueVector = new Vector<String>(); Map<Locale, Vector<String>> data = new HashMap<Locale, Vector<String>>();
Vector<String> usVector = new Vector<String>(); for (Map.Entry<Locale, LocalePackage> entry : map.entrySet()) {
Vector<String> cnVector = new Vector<String>(); Vector<String> column = new Vector<String>();
Vector<String> jpVector = new Vector<String>(); for (String key : sortKeys) {
Vector<String> twVector = new Vector<String>(); column.add(entry.getValue().getLocText(key));
Vector<String> krVector = new Vector<String>(); }
for (String key : sortKeys) { data.put(entry.getKey(), column);
keyVector.add(key);
valueVector.add(fr.getProperty(key));
usVector.add(us.getProperty(key));
cnVector.add(cn.getProperty(key));
jpVector.add(jp.getProperty(key));
twVector.add(tw.getProperty(key));
krVector.add(kr.getProperty(key));
} }
Vector<String> keyVector = new Vector<String>();
keyVector.addAll(sortKeys);
predefineTableModel.addColumn(Inter.getLocText("Key"), keyVector); predefineTableModel.addColumn(Inter.getLocText("Key"), keyVector);
predefineTableModel.addColumn(Inter.getLocText("Value"), valueVector); for (Map.Entry<Locale, Vector<String>> entry : data.entrySet()) {
predefineTableModel.addColumn("en_US", usVector); predefineTableModel.addColumn(entry.getKey().getDisplayName(), entry.getValue());
predefineTableModel.addColumn("zh_CN", cnVector); }
predefineTableModel.addColumn("ja_JP", jpVector);
predefineTableModel.addColumn("zh_TW", twVector);
predefineTableModel.addColumn("ko_KR", krVector);
} }
private void initCustomProperties() throws Exception { private void initCustomProperties() throws Exception {

Loading…
Cancel
Save