mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
hacked the IDE to support multiple translations and include a dropdown list to choose the most convenient
This commit is contained in:
1481
app/src/processing/app/11418.po
Normal file
1481
app/src/processing/app/11418.po
Normal file
File diff suppressed because it is too large
Load Diff
0
app/src/processing/app/11418.properties
Normal file
0
app/src/processing/app/11418.properties
Normal file
@ -169,6 +169,9 @@ public class Base {
|
||||
// run static initialization that grabs all the prefs
|
||||
Preferences.init(null);
|
||||
|
||||
// load the I18n module for internationalization
|
||||
I18n.init(Preferences.get("editor.languages.current"));
|
||||
|
||||
// setup the theme coloring fun
|
||||
Theme.init();
|
||||
|
||||
|
@ -12,11 +12,24 @@
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Locale.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public class I18n {
|
||||
// start using current locale but still allow using the dropdown list later
|
||||
private static ResourceBundle i18n = ResourceBundle.getBundle("processing.app.Resources");
|
||||
public static Locale locale;
|
||||
|
||||
static protected void init (String language) {
|
||||
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
|
||||
try {
|
||||
locale = new Locale(language);
|
||||
i18n = ResourceBundle.getBundle("processing.app.Resources", locale);
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static String _(String s) {
|
||||
try {
|
||||
|
@ -79,6 +79,79 @@ public class Preferences {
|
||||
static final String PROMPT_OK = _("OK");
|
||||
static final String PROMPT_BROWSE = _("Browse");
|
||||
|
||||
// XXX: DC 20120407
|
||||
// Language Combo Box
|
||||
// the right way to do this would be having a string[] inside the preferences.txt
|
||||
// file like follows:
|
||||
//
|
||||
// # list of available languages (in English so far)
|
||||
// editor.languages.available.list = Catalan,English,Spanish
|
||||
//
|
||||
// # list of ISO names (same order as previous)
|
||||
// editor.languages.ISO.list = ca,en,es
|
||||
//
|
||||
// --> but that will require having a method to upgrade to the latest selection of
|
||||
// translation files. That could be done in multiple ways, but requires some thought
|
||||
//
|
||||
// the code to gather those arrays into Preferences.java goes as follows:
|
||||
//
|
||||
// String languagesAvailable = Preferences.get("editor.languages.available.list");
|
||||
// String languagesAvailableISO = Preferences.get("editor.languages.ISO.list");
|
||||
// String[] languages = languagesAvailable.split(",");
|
||||
// String[] languagesISO = languagesAvailableISO.split(",");
|
||||
//
|
||||
// --> instead, DM and DC agree that, for the time being, the languages will be listed internally
|
||||
// inside the Java code, they will have to be moved out at some point
|
||||
//
|
||||
// also note that right now, by default we will take English, in the future, once JRE7 is running in
|
||||
// Arduino, we will use the locale, since it will behave in a similar way for all OSs. Thing is, up
|
||||
// to JRE6, it was misbehaving as noted here:
|
||||
// http://stackoverflow.com/questions/7107972/java-7-default-locale
|
||||
//
|
||||
// ALSO: for this to work, the languages/languagesISO arraylists need to be declared global, yeah!
|
||||
|
||||
// language related arrays, please read notes later, where the language combo box is introduced
|
||||
String[] languages = {
|
||||
_("Catalan"),
|
||||
_("Chinese Simplified"),
|
||||
_("Chinese Taiwan"),
|
||||
_("Danish"),
|
||||
_("Dutch"),
|
||||
_("English"),
|
||||
_("French"),
|
||||
_("Filipino"),
|
||||
_("Galician"),
|
||||
_("German"),
|
||||
_("Greek"),
|
||||
_("Hungarian"),
|
||||
_("Italian"),
|
||||
_("Japanese"),
|
||||
_("Latvian"),
|
||||
_("Persian"),
|
||||
_("Portuguese (Brazil)"),
|
||||
_("Romanian"),
|
||||
_("Spanish")};
|
||||
String[] languagesISO = {
|
||||
"ca",
|
||||
"zh_cn",
|
||||
"zh_tw",
|
||||
"da",
|
||||
"nl",
|
||||
"en",
|
||||
"fr",
|
||||
"tl",
|
||||
"gl",
|
||||
"de",
|
||||
"el",
|
||||
"hu",
|
||||
"it",
|
||||
"ja",
|
||||
"lv",
|
||||
"fa",
|
||||
"pt_br",
|
||||
"ro",
|
||||
"es"};
|
||||
|
||||
/**
|
||||
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
|
||||
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
|
||||
@ -124,6 +197,7 @@ public class Preferences {
|
||||
JTextField fontSizeField;
|
||||
JCheckBox updateExtensionBox;
|
||||
JCheckBox autoAssociateBox;
|
||||
JComboBox comboLanguage;
|
||||
|
||||
|
||||
// the calling editor, so updates can be applied
|
||||
@ -350,6 +424,30 @@ public class Preferences {
|
||||
top += d.height + GUI_BETWEEN;
|
||||
}
|
||||
|
||||
//Label for the language combo box
|
||||
box = Box.createHorizontalBox();
|
||||
label = new JLabel(_("Preferred Language: "));
|
||||
box.add(label);
|
||||
|
||||
//Create the combo box, select the item at index 4.
|
||||
comboLanguage = new JComboBox(languages);
|
||||
comboLanguage.setSelectedIndex((Arrays.asList(languagesISO)).indexOf(Preferences.get("editor.languages.current")));
|
||||
comboLanguage.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
JComboBox cb = (JComboBox)evt.getSource();
|
||||
// the update to the language is done outside
|
||||
}
|
||||
});
|
||||
box.add(comboLanguage);
|
||||
label = new JLabel(_(" (requires restart of Arduino)"));
|
||||
box.add(label);
|
||||
pain.add(box);
|
||||
d = box.getPreferredSize();
|
||||
box.setForeground(Color.gray);
|
||||
box.setBounds(left, top, d.width, d.height);
|
||||
right = Math.max(right, left + d.width);
|
||||
top += d.height + GUI_BETWEEN;
|
||||
|
||||
|
||||
// More preferences are in the ...
|
||||
|
||||
@ -539,6 +637,11 @@ public class Preferences {
|
||||
|
||||
setBoolean("editor.update_extension", updateExtensionBox.isSelected());
|
||||
|
||||
// adds the selected language to the preferences file
|
||||
Object newItem = comboLanguage.getSelectedItem();
|
||||
int pos = (Arrays.asList(languages)).indexOf(newItem.toString()); // position in the languages array
|
||||
set("editor.languages.current",(Arrays.asList(languagesISO)).get(pos));
|
||||
|
||||
editor.applyPreferences();
|
||||
}
|
||||
|
||||
|
1597
app/src/processing/app/Resources_ca.po
Normal file
1597
app/src/processing/app/Resources_ca.po
Normal file
File diff suppressed because it is too large
Load Diff
1008
app/src/processing/app/Resources_ca.properties
Normal file
1008
app/src/processing/app/Resources_ca.properties
Normal file
File diff suppressed because it is too large
Load Diff
1621
app/src/processing/app/Resources_da.po
Normal file
1621
app/src/processing/app/Resources_da.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_da.properties
Normal file
1007
app/src/processing/app/Resources_da.properties
Normal file
File diff suppressed because it is too large
Load Diff
1482
app/src/processing/app/Resources_de.po
Normal file
1482
app/src/processing/app/Resources_de.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_de.properties
Normal file
1007
app/src/processing/app/Resources_de.properties
Normal file
File diff suppressed because it is too large
Load Diff
1483
app/src/processing/app/Resources_el.po
Normal file
1483
app/src/processing/app/Resources_el.po
Normal file
File diff suppressed because it is too large
Load Diff
1008
app/src/processing/app/Resources_el.properties
Normal file
1008
app/src/processing/app/Resources_el.properties
Normal file
File diff suppressed because it is too large
Load Diff
1482
app/src/processing/app/Resources_en.po
Normal file
1482
app/src/processing/app/Resources_en.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_en.properties
Normal file
1007
app/src/processing/app/Resources_en.properties
Normal file
File diff suppressed because it is too large
Load Diff
1638
app/src/processing/app/Resources_es.po
Normal file
1638
app/src/processing/app/Resources_es.po
Normal file
File diff suppressed because it is too large
Load Diff
1012
app/src/processing/app/Resources_es.properties
Normal file
1012
app/src/processing/app/Resources_es.properties
Normal file
File diff suppressed because it is too large
Load Diff
1589
app/src/processing/app/Resources_fa.po
Normal file
1589
app/src/processing/app/Resources_fa.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_fa.properties
Normal file
1007
app/src/processing/app/Resources_fa.properties
Normal file
File diff suppressed because it is too large
Load Diff
1637
app/src/processing/app/Resources_fr.po
Normal file
1637
app/src/processing/app/Resources_fr.po
Normal file
File diff suppressed because it is too large
Load Diff
1016
app/src/processing/app/Resources_fr.properties
Normal file
1016
app/src/processing/app/Resources_fr.properties
Normal file
File diff suppressed because it is too large
Load Diff
1634
app/src/processing/app/Resources_gl.po
Normal file
1634
app/src/processing/app/Resources_gl.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_gl.properties
Normal file
1007
app/src/processing/app/Resources_gl.properties
Normal file
File diff suppressed because it is too large
Load Diff
1503
app/src/processing/app/Resources_hr.po
Normal file
1503
app/src/processing/app/Resources_hr.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_hr.properties
Normal file
1007
app/src/processing/app/Resources_hr.properties
Normal file
File diff suppressed because it is too large
Load Diff
1607
app/src/processing/app/Resources_hu.po
Normal file
1607
app/src/processing/app/Resources_hu.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_hu.properties
Normal file
1007
app/src/processing/app/Resources_hu.properties
Normal file
File diff suppressed because it is too large
Load Diff
1623
app/src/processing/app/Resources_it.po
Normal file
1623
app/src/processing/app/Resources_it.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_it.properties
Normal file
1007
app/src/processing/app/Resources_it.properties
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1633
app/src/processing/app/Resources_lv.po
Normal file
1633
app/src/processing/app/Resources_lv.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_lv.properties
Normal file
1007
app/src/processing/app/Resources_lv.properties
Normal file
File diff suppressed because it is too large
Load Diff
1482
app/src/processing/app/Resources_mr.po
Normal file
1482
app/src/processing/app/Resources_mr.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_mr.properties
Normal file
1007
app/src/processing/app/Resources_mr.properties
Normal file
File diff suppressed because it is too large
Load Diff
1620
app/src/processing/app/Resources_nl.po
Normal file
1620
app/src/processing/app/Resources_nl.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_nl.properties
Normal file
1007
app/src/processing/app/Resources_nl.properties
Normal file
File diff suppressed because it is too large
Load Diff
1482
app/src/processing/app/Resources_pl.po
Normal file
1482
app/src/processing/app/Resources_pl.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_pl.properties
Normal file
1007
app/src/processing/app/Resources_pl.properties
Normal file
File diff suppressed because it is too large
Load Diff
1488
app/src/processing/app/Resources_pt_br.po
Normal file
1488
app/src/processing/app/Resources_pt_br.po
Normal file
File diff suppressed because it is too large
Load Diff
1012
app/src/processing/app/Resources_pt_br.properties
Normal file
1012
app/src/processing/app/Resources_pt_br.properties
Normal file
File diff suppressed because it is too large
Load Diff
1629
app/src/processing/app/Resources_ro.po
Normal file
1629
app/src/processing/app/Resources_ro.po
Normal file
File diff suppressed because it is too large
Load Diff
1009
app/src/processing/app/Resources_ro.properties
Normal file
1009
app/src/processing/app/Resources_ro.properties
Normal file
File diff suppressed because it is too large
Load Diff
1621
app/src/processing/app/Resources_tl.po
Normal file
1621
app/src/processing/app/Resources_tl.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_tl.properties
Normal file
1007
app/src/processing/app/Resources_tl.properties
Normal file
File diff suppressed because it is too large
Load Diff
1622
app/src/processing/app/Resources_zh_cn.po
Normal file
1622
app/src/processing/app/Resources_zh_cn.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_zh_cn.properties
Normal file
1007
app/src/processing/app/Resources_zh_cn.properties
Normal file
File diff suppressed because it is too large
Load Diff
1618
app/src/processing/app/Resources_zh_tw.po
Normal file
1618
app/src/processing/app/Resources_zh_tw.po
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/src/processing/app/Resources_zh_tw.properties
Normal file
1007
app/src/processing/app/Resources_zh_tw.properties
Normal file
File diff suppressed because it is too large
Load Diff
@ -255,3 +255,9 @@ serial.databits=8
|
||||
serial.stopbits=1
|
||||
serial.parity=N
|
||||
serial.debug_rate=9600
|
||||
|
||||
# I18 Preferences
|
||||
|
||||
# default chosen language (none for none)
|
||||
editor.languages.current = en
|
||||
|
||||
|
Reference in New Issue
Block a user