001: package net.sourceforge.squirrel_sql.plugins.i18n;
002:
003: import java.awt.GridBagConstraints;
004: import java.awt.GridBagLayout;
005: import java.awt.GridLayout;
006: import java.awt.Insets;
007: import java.util.prefs.Preferences;
008:
009: import javax.swing.JButton;
010: import javax.swing.JCheckBox;
011: import javax.swing.JComboBox;
012: import javax.swing.JLabel;
013: import javax.swing.JPanel;
014: import javax.swing.JScrollPane;
015: import javax.swing.JTabbedPane;
016: import javax.swing.JTable;
017: import javax.swing.JTextField;
018:
019: import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
020: import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
021: import net.sourceforge.squirrel_sql.fw.util.StringManager;
022: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
023:
024: public class TranslatorsPanel extends JPanel {
025: private static final StringManager s_stringMgr = StringManagerFactory
026: .getStringManager(TranslatorsPanel.class);
027:
028: JTabbedPane tabTranlators = new JTabbedPane();
029:
030: JComboBox cboLocales = new JComboBox();
031: // i18n[I18n.loadBundles=Load bundles]
032: JButton btnLoad = new JButton(s_stringMgr
033: .getString("I18n.loadBundles"));
034:
035: JTextField txtWorkingDir = new JTextField();
036: JButton btnChooseWorkDir;
037:
038: JTextField txtEditorCommand = new JTextField();
039: JButton btnChooseNativeToAsciiCommand;
040:
041: JTextField txtNativeToAsciiCommand = new JTextField();
042: JButton btnChooseEditorCommand;
043:
044: JTextField txtNativeToAsciiOutDir = new JTextField();
045: JButton btnChooseNativeToAsciiOutDir;
046:
047: JTable tblBundels = new JTable();
048:
049: JCheckBox cbxIncludeTimestamp = null;
050:
051: private static final String PREF_KEY_INCLUDE_TIMESTAMP = "SquirrelSQL.i18n.includeTimestamp";
052:
053: public TranslatorsPanel(PluginResources resources) {
054: setLayout(new GridLayout(1, 1));
055: add(tabTranlators);
056:
057: JPanel translationsPanel = getTranslationsPanel(resources);
058: // i18n[I18n.tranlations=Translations]
059: tabTranlators.addTab(s_stringMgr.getString("I18n.tranlations"),
060: translationsPanel);
061:
062: // i18n[I18n.info=Info]
063: tabTranlators.addTab(s_stringMgr.getString("I18n.info"),
064: new JScrollPane(new MultipleLineLabel(infoText)));
065:
066: String includeTimestamp = Preferences.userRoot().get(
067: PREF_KEY_INCLUDE_TIMESTAMP, "true");
068:
069: cbxIncludeTimestamp
070: .setSelected(includeTimestamp.equals("true"));
071: }
072:
073: private JPanel getTranslationsPanel(PluginResources resources) {
074: JPanel ret = new JPanel();
075:
076: GridBagConstraints gbc;
077:
078: ret.setLayout(new GridBagLayout());
079:
080: gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
081: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
082: new Insets(5, 5, 5, 5), 0, 0);
083: // i18n[I18n.locales=Locales]
084: ret.add(new JLabel(s_stringMgr.getString("I18n.locales")), gbc);
085:
086: gbc = new GridBagConstraints(1, 0, 1, 1, 0, 0,
087: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
088: new Insets(5, 0, 0, 5), 0, 0);
089: ret.add(cboLocales, gbc);
090:
091: gbc = new GridBagConstraints(2, 0, 1, 1, 0, 0,
092: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
093: new Insets(5, 0, 0, 5), 0, 0);
094: ret.add(btnLoad, gbc);
095:
096: gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
097: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
098: new Insets(5, 5, 5, 5), 0, 0);
099: // i18n[I18n.WorkingDir=Working Directory]
100: ret.add(new JLabel(s_stringMgr.getString("I18n.WorkingDir")),
101: gbc);
102:
103: gbc = new GridBagConstraints(1, 1, 1, 1, 1, 0,
104: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
105: new Insets(5, 0, 0, 5), 0, 0);
106: ret.add(txtWorkingDir, gbc);
107:
108: btnChooseWorkDir = new JButton(resources.getIcon("Open"));
109: gbc = new GridBagConstraints(2, 1, 1, 1, 0, 0,
110: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
111: new Insets(5, 0, 0, 5), 0, 0);
112: ret.add(btnChooseWorkDir, gbc);
113:
114: gbc = new GridBagConstraints(0, 2, 1, 1, 0, 0,
115: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
116: new Insets(5, 5, 5, 5), 0, 0);
117: // i18n[I18n.EditorCommand=Editor command]
118: ret
119: .add(new JLabel(s_stringMgr
120: .getString("I18n.EditorCommand")), gbc);
121:
122: gbc = new GridBagConstraints(1, 2, 1, 1, 1, 0,
123: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
124: new Insets(5, 0, 0, 5), 0, 0);
125: ret.add(txtEditorCommand, gbc);
126:
127: btnChooseEditorCommand = new JButton(resources.getIcon("Open"));
128: gbc = new GridBagConstraints(2, 2, 1, 1, 0, 0,
129: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
130: new Insets(5, 0, 0, 5), 0, 0);
131: ret.add(btnChooseEditorCommand, gbc);
132:
133: gbc = new GridBagConstraints(0, 3, 1, 1, 0, 0,
134: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
135: new Insets(5, 5, 5, 5), 0, 0);
136: // i18n[I18n.NativeToAscii=Path to native to Unicode converter (JDK's native2ascii)]
137: ret.add(new MultipleLineLabel(s_stringMgr
138: .getString("I18n.NativeToAscii")), gbc);
139:
140: gbc = new GridBagConstraints(1, 3, 1, 1, 1, 0,
141: GridBagConstraints.CENTER,
142: GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5),
143: 0, 0);
144: ret.add(txtNativeToAsciiCommand, gbc);
145:
146: btnChooseNativeToAsciiCommand = new JButton(resources
147: .getIcon("Open"));
148: gbc = new GridBagConstraints(2, 3, 1, 1, 0, 0,
149: GridBagConstraints.WEST, GridBagConstraints.NONE,
150: new Insets(5, 0, 0, 5), 0, 0);
151: ret.add(btnChooseNativeToAsciiCommand, gbc);
152:
153: gbc = new GridBagConstraints(0, 4, 1, 1, 0, 0,
154: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
155: new Insets(5, 5, 5, 5), 0, 0);
156: // i18n[I18n.NativeToAsciiOutDir=native2Ascii output dir]
157: ret.add(new JLabel(s_stringMgr
158: .getString("I18n.NativeToAsciiOutDir")), gbc);
159:
160: gbc = new GridBagConstraints(1, 4, 1, 1, 1, 0,
161: GridBagConstraints.SOUTHWEST, GridBagConstraints.BOTH,
162: new Insets(5, 0, 0, 5), 0, 0);
163: ret.add(txtNativeToAsciiOutDir, gbc);
164:
165: btnChooseNativeToAsciiOutDir = new JButton(resources
166: .getIcon("Open"));
167: gbc = new GridBagConstraints(2, 4, 1, 1, 0, 0,
168: GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
169: new Insets(5, 0, 0, 5), 0, 0);
170: ret.add(btnChooseNativeToAsciiOutDir, gbc);
171:
172: gbc = new GridBagConstraints(1, 5, 1, 1, 0, 0,
173: GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
174: new Insets(5, 0, 0, 5), 0, 0);
175: // i18n[I18n.includeTimestamp=Include timestamp in modified properties file]
176: cbxIncludeTimestamp = new JCheckBox(s_stringMgr
177: .getString("I18n.includeTimestamp"));
178: ret.add(cbxIncludeTimestamp, gbc);
179:
180: /* gbc = new GridBagConstraints(1,5,1,1,0,0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(5,0,0,5),0,0);
181: // i18n[I18n.includeTimestamp=Include timestamp in modified properties file]
182: JLabel timestampLabel = new JLabel(s_stringMgr.getString("I18n.includeTimestamp"));
183: ret.add(timestampLabel, gbc);
184: */
185:
186: gbc = new GridBagConstraints(0, 6, 3, 1, 0, 0,
187: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
188: new Insets(5, 0, 0, 5), 0, 0);
189: // i18n[I18n.bundles=Bundles]
190: ret.add(new JLabel(s_stringMgr.getString("I18n.bundles")), gbc);
191:
192: gbc = new GridBagConstraints(0, 7, 3, 1, 1, 1,
193: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
194: new Insets(5, 0, 0, 5), 0, 0);
195: ret.add(new JScrollPane(tblBundels), gbc);
196:
197: return ret;
198: }
199:
200: private String infoText = "How translation works:\n"
201: + "1. Choose the locale you wish to translate for. A Locale at least consist of a language part like en (English). "
202: + "It may also consist of a country part like en_us (English _ United States). In most cases your translation won't be "
203: + "country depended. In this case you choose a locale that only consists of a language part.\n"
204: + "\n"
205: + "2. Click the 'Load bundles' button to fill the 'Bundles' table. This will give you an overview how many translations are to be done.\n"
206: + "\n"
207: + "3. Choose a working directory where SQuirreL should generate the templates for your translations. When loading the 'Bundles' table SQuirreL looks in this directory to find out which translations have already been done.\n"
208: + "\n"
209: + "4. Optionally choose an edtior command. This will allow you to open the files where you do your translations via right mouse menu of the bundles table.\n"
210: + "\n"
211: + "5. Before you can start translating you must use the right mouse menu in the 'Bundles' table to generate "
212: + "a translation template file. The generated template file consist of entries like this:\n"
213: + "#button.add.title=Add\n"
214: + "#button.add.title=\n"
215: + "which you turn into an entry of this kind:\n"
216: + "#button.add.title=Add\n"
217: + "button.add.title=<Your translation here>\n"
218: + "After this you might click the load bundles button again to see the number of tranlations to do decrease.\n"
219: + "\n"
220: + "6. To see your translations on next SQuirreL restart you need to:\n"
221: + "i. Edit the class path in your SQuirreL start batch or shell file to include your working directory.\n"
222: + "ii. If your machine is running with locale different from the one you are translating to edit your your SQuirreL start batch or shell to pass the right country to your Java Virtual Machine.\n"
223: + "In the shell or batch files you'll find further details about what to do.\n\n"
224: + "7. For non-latin1 encodings use the native2ascii tool included in JDK 1.4.x. For details see:\n"
225: + "http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html\n\n"
226: + "8. For other translation issues or any further questions see our developer mailing list at "
227: + "squirrel-sql-develop@lists.sourceforge.net";
228:
229: }
|