@@ -79,6 +79,51 @@ public class Preferences {
79
79
static final String PROMPT_OK = _ ("OK" );
80
80
static final String PROMPT_BROWSE = _ ("Browse" );
81
81
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
+
82
127
/**
83
128
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
84
129
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
@@ -124,6 +169,7 @@ public class Preferences {
124
169
JTextField fontSizeField ;
125
170
JCheckBox updateExtensionBox ;
126
171
JCheckBox autoAssociateBox ;
172
+ JComboBox comboLanguage ;
127
173
128
174
129
175
// the calling editor, so updates can be applied
@@ -270,9 +316,25 @@ public void actionPerformed(ActionEvent e) {
270
316
top += vmax + GUI_BETWEEN ;
271
317
272
318
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
+
273
335
// Editor font size [ ]
274
336
275
- Container box = Box .createHorizontalBox ();
337
+ box = Box .createHorizontalBox ();
276
338
label = new JLabel (_ ("Editor font size: " ));
277
339
box .add (label );
278
340
fontSizeField = new JTextField (4 );
@@ -350,7 +412,6 @@ public void actionPerformed(ActionEvent e) {
350
412
top += d .height + GUI_BETWEEN ;
351
413
}
352
414
353
-
354
415
// More preferences are in the ...
355
416
356
417
label = new JLabel (_ ("More preferences can be edited directly in the file" ));
@@ -539,6 +600,11 @@ protected void applyFrame() {
539
600
540
601
setBoolean ("editor.update_extension" , updateExtensionBox .isSelected ());
541
602
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
+
542
608
editor .applyPreferences ();
543
609
}
544
610
0 commit comments