Skip to content

Commit b2f4e5f

Browse files
committed
Merge branch 'master' of github.com:arduino/Arduino into LUFA_bootloader
2 parents 3f6342e + c540ac1 commit b2f4e5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+58611
-1279
lines changed

app/src/processing/app/Base.java

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ static public void main(String args[]) {
169169
// run static initialization that grabs all the prefs
170170
Preferences.init(null);
171171

172+
// load the I18n module for internationalization
173+
I18n.init(Preferences.get("editor.languages.current"));
174+
172175
// setup the theme coloring fun
173176
Theme.init();
174177

app/src/processing/app/I18n.java

+14
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@
1212
*/
1313

1414
package processing.app;
15+
1516
import java.util.*;
17+
import java.util.Locale.*;
1618
import java.text.MessageFormat;
1719

1820
public class I18n {
21+
// start using current locale but still allow using the dropdown list later
1922
private static ResourceBundle i18n = ResourceBundle.getBundle("processing.app.Resources");
23+
public static Locale locale;
24+
25+
static protected void init (String language) {
26+
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
27+
try {
28+
if (language == null || language.trim().length() == 0) locale = Locale.getDefault();
29+
else locale = new Locale(language);
30+
i18n = ResourceBundle.getBundle("processing.app.Resources", locale);
31+
} catch (java.lang.NullPointerException e) {
32+
}
33+
}
2034

2135
public static String _(String s) {
2236
try {

app/src/processing/app/Preferences.java

+68-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,51 @@ public class Preferences {
7979
static final String PROMPT_OK = _("OK");
8080
static final String PROMPT_BROWSE = _("Browse");
8181

82+
String[] languages = {
83+
_("System Default"),
84+
"Català" + " (" + _("Catalan") + ")",
85+
"简体中文" + " (" + _("Chinese Simplified") + ")",
86+
"繁體中文" + " (" + _("Chinese Traditional") + ")",
87+
"Dansk" + " (" + _("Danish") + ")",
88+
"Nederlands" + " (" + _("Dutch") + ")",
89+
"English" + " (" + _("English") + ")",
90+
"Français" + " (" + _("French") + ")",
91+
"Pilipino" + " (" + _("Filipino") + ")",
92+
"Galego" + " (" + _("Galician") + ")",
93+
"Deutsch" + " (" + _("German") + ")",
94+
"ελληνικά" + " (" + _("Greek") + ")",
95+
"Magyar" + " (" + _("Hungarian") + ")",
96+
"Italiano" + " (" + _("Italian") + ")",
97+
"日本語" + " (" + _("Japanese") + ")",
98+
"Latviešu" + " (" + _("Latvian") + ")",
99+
"فارسی" + " (" + _("Persian") + ")",
100+
"Português" + " (" + _("Portuguese") + ")",
101+
"Română" + " (" + _("Romanian") + ")",
102+
"русский" + " (" + _("Russian") + ")",
103+
"Español" + " (" + _("Spanish") + ")"};
104+
String[] languagesISO = {
105+
"",
106+
"ca",
107+
"zh_cn",
108+
"zh_tw",
109+
"da",
110+
"nl",
111+
"en",
112+
"fr",
113+
"tl",
114+
"gl",
115+
"de",
116+
"el",
117+
"hu",
118+
"it",
119+
"ja",
120+
"lv",
121+
"fa",
122+
"pt_br",
123+
"ro",
124+
"ru",
125+
"es"};
126+
82127
/**
83128
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
84129
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
@@ -124,6 +169,7 @@ public class Preferences {
124169
JTextField fontSizeField;
125170
JCheckBox updateExtensionBox;
126171
JCheckBox autoAssociateBox;
172+
JComboBox comboLanguage;
127173

128174

129175
// the calling editor, so updates can be applied
@@ -270,9 +316,25 @@ public void actionPerformed(ActionEvent e) {
270316
top += vmax + GUI_BETWEEN;
271317

272318

319+
// Preferred language: [ ] (requires restart of Arduino)
320+
Container box = Box.createHorizontalBox();
321+
label = new JLabel(_("Editor language: "));
322+
box.add(label);
323+
comboLanguage = new JComboBox(languages);
324+
comboLanguage.setSelectedIndex((Arrays.asList(languagesISO)).indexOf(Preferences.get("editor.languages.current")));
325+
box.add(comboLanguage);
326+
label = new JLabel(_(" (requires restart of Arduino)"));
327+
box.add(label);
328+
pain.add(box);
329+
d = box.getPreferredSize();
330+
box.setForeground(Color.gray);
331+
box.setBounds(left, top, d.width, d.height);
332+
right = Math.max(right, left + d.width);
333+
top += d.height + GUI_BETWEEN;
334+
273335
// Editor font size [ ]
274336

275-
Container box = Box.createHorizontalBox();
337+
box = Box.createHorizontalBox();
276338
label = new JLabel(_("Editor font size: "));
277339
box.add(label);
278340
fontSizeField = new JTextField(4);
@@ -350,7 +412,6 @@ public void actionPerformed(ActionEvent e) {
350412
top += d.height + GUI_BETWEEN;
351413
}
352414

353-
354415
// More preferences are in the ...
355416

356417
label = new JLabel(_("More preferences can be edited directly in the file"));
@@ -539,6 +600,11 @@ protected void applyFrame() {
539600

540601
setBoolean("editor.update_extension", updateExtensionBox.isSelected());
541602

603+
// adds the selected language to the preferences file
604+
Object newItem = comboLanguage.getSelectedItem();
605+
int pos = (Arrays.asList(languages)).indexOf(newItem.toString()); // position in the languages array
606+
set("editor.languages.current",(Arrays.asList(languagesISO)).get(pos));
607+
542608
editor.applyPreferences();
543609
}
544610

0 commit comments

Comments
 (0)