@@ -79,6 +79,75 @@ 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+ "العربية" + " (" + _ ("Arabic" ) + ")" ,
85+ "Aragonés" + " (" + _ ("Aragonese" ) + ")" ,
86+ "Català" + " (" + _ ("Catalan" ) + ")" ,
87+ "简体中文" + " (" + _ ("Chinese Simplified" ) + ")" ,
88+ "繁體中文" + " (" + _ ("Chinese Traditional" ) + ")" ,
89+ "Dansk" + " (" + _ ("Danish" ) + ")" ,
90+ "Nederlands" + " (" + _ ("Dutch" ) + ")" ,
91+ "English" + " (" + _ ("English" ) + ")" ,
92+ "Eesti" + " (" + _ ("Estonian" ) + ")" ,
93+ "Pilipino" + " (" + _ ("Filipino" ) + ")" ,
94+ "Français" + " (" + _ ("French" ) + ")" ,
95+ "Galego" + " (" + _ ("Galician" ) + ")" ,
96+ "Deutsch" + " (" + _ ("German" ) + ")" ,
97+ "ελληνικά" + " (" + _ ("Greek" ) + ")" ,
98+ "Magyar" + " (" + _ ("Hindi" ) + ")" ,
99+ "Magyar" + " (" + _ ("Hungarian" ) + ")" ,
100+ "Bahasa Indonesia" + " (" + _ ("Indonesian" ) + ")" ,
101+ "Italiano" + " (" + _ ("Italian" ) + ")" ,
102+ "日本語" + " (" + _ ("Japanese" ) + ")" ,
103+ "한국어" + " (" + _ ("Korean" ) + ")" ,
104+ "Latviešu" + " (" + _ ("Latvian" ) + ")" ,
105+ "Lietuvių Kalba" + " (" + _ ("Lithuaninan" ) + ")" ,
106+ "मराठी" + " (" + _ ("Marathi" ) + ")" ,
107+ "Norsk" + " (" + _ ("Norwegian" ) + ")" ,
108+ "فارسی" + " (" + _ ("Persian" ) + ")" ,
109+ "Język Polski" + " (" + _ ("Polish" ) + ")" ,
110+ "Português" + " (" + _ ("Portuguese" ) + " - Brazil)" ,
111+ "Português" + " (" + _ ("Portuguese" ) + " - Portugal)" ,
112+ "Română" + " (" + _ ("Romanian" ) + ")" ,
113+ "Русский" + " (" + _ ("Russian" ) + ")" ,
114+ "Español" + " (" + _ ("Spanish" ) + ")" ,
115+ "தமிழ்" + " (" + _ ("Tamil" ) + ")" };
116+ String [] languagesISO = {
117+ "" ,
118+ "ar" ,
119+ "an" ,
120+ "ca" ,
121+ "zh_cn" ,
122+ "zh_tw" ,
123+ "da" ,
124+ "nl" ,
125+ "en" ,
126+ "et" ,
127+ "tl" ,
128+ "fr" ,
129+ "gl" ,
130+ "de" ,
131+ "el" ,
132+ "hi" ,
133+ "hu" ,
134+ "id" ,
135+ "it" ,
136+ "ja" ,
137+ "ko" ,
138+ "lv" ,
139+ "lt" ,
140+ "mr" ,
141+ "no_nb" ,
142+ "fa" ,
143+ "pl" ,
144+ "pt_br" ,
145+ "pt_pt" ,
146+ "ro" ,
147+ "ru" ,
148+ "es" ,
149+ "ta" };
150+
82151 /**
83152 * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
84153 * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
@@ -124,6 +193,7 @@ public class Preferences {
124193 JTextField fontSizeField ;
125194 JCheckBox updateExtensionBox ;
126195 JCheckBox autoAssociateBox ;
196+ JComboBox comboLanguage ;
127197
128198
129199 // the calling editor, so updates can be applied
@@ -270,9 +340,25 @@ public void actionPerformed(ActionEvent e) {
270340 top += vmax + GUI_BETWEEN ;
271341
272342
343+ // Preferred language: [ ] (requires restart of Arduino)
344+ Container box = Box .createHorizontalBox ();
345+ label = new JLabel (_ ("Editor language: " ));
346+ box .add (label );
347+ comboLanguage = new JComboBox (languages );
348+ comboLanguage .setSelectedIndex ((Arrays .asList (languagesISO )).indexOf (Preferences .get ("editor.languages.current" )));
349+ box .add (comboLanguage );
350+ label = new JLabel (_ (" (requires restart of Arduino)" ));
351+ box .add (label );
352+ pain .add (box );
353+ d = box .getPreferredSize ();
354+ box .setForeground (Color .gray );
355+ box .setBounds (left , top , d .width , d .height );
356+ right = Math .max (right , left + d .width );
357+ top += d .height + GUI_BETWEEN ;
358+
273359 // Editor font size [ ]
274360
275- Container box = Box .createHorizontalBox ();
361+ box = Box .createHorizontalBox ();
276362 label = new JLabel (_ ("Editor font size: " ));
277363 box .add (label );
278364 fontSizeField = new JTextField (4 );
@@ -303,7 +389,7 @@ public void actionPerformed(ActionEvent e) {
303389
304390 // [ ] Verify code after upload
305391
306- verifyUploadBox = new JCheckBox ("Verify code after upload" );
392+ verifyUploadBox = new JCheckBox (_ ( "Verify code after upload" ) );
307393 pain .add (verifyUploadBox );
308394 d = verifyUploadBox .getPreferredSize ();
309395 verifyUploadBox .setBounds (left , top , d .width + 10 , d .height );
@@ -350,7 +436,6 @@ public void actionPerformed(ActionEvent e) {
350436 top += d .height + GUI_BETWEEN ;
351437 }
352438
353-
354439 // More preferences are in the ...
355440
356441 label = new JLabel (_ ("More preferences can be edited directly in the file" ));
@@ -539,6 +624,11 @@ protected void applyFrame() {
539624
540625 setBoolean ("editor.update_extension" , updateExtensionBox .isSelected ());
541626
627+ // adds the selected language to the preferences file
628+ Object newItem = comboLanguage .getSelectedItem ();
629+ int pos = (Arrays .asList (languages )).indexOf (newItem .toString ()); // position in the languages array
630+ set ("editor.languages.current" ,(Arrays .asList (languagesISO )).get (pos ));
631+
542632 editor .applyPreferences ();
543633 }
544634
0 commit comments