mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
UI i18n and the Japanese text catalog.
Wrapped the every string literals with _(...) function. The _() function resides in "app/src/processing/app/I18n.java", which translates the UI texts using "Resources_XX.properties" file where XX is the locale code. I provided the properties file for the ja (Japanese) locale. I created this file using "xgettext" and "msgcat" commands. "i18n_update.{py,sh}" files are the tool I used to do that. Change in "app/build.xml" is to include the properties files in jar file.
This commit is contained in:
committed by
Shigeru KANEMOTO
parent
fa4ab4f6ab
commit
541a7b3575
@ -32,6 +32,7 @@ import javax.swing.*;
|
||||
import processing.app.debug.Compiler;
|
||||
import processing.app.debug.Target;
|
||||
import processing.core.*;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
|
||||
/**
|
||||
@ -177,8 +178,8 @@ public class Base {
|
||||
} catch (Exception e) {
|
||||
String mess = e.getMessage();
|
||||
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
|
||||
System.err.println("Non-fatal error while setting the Look & Feel.");
|
||||
System.err.println("The error message follows, however Arduino should run fine.");
|
||||
System.err.println(_("Non-fatal error while setting the Look & Feel."));
|
||||
System.err.println(_("The error message follows, however Arduino should run fine."));
|
||||
System.err.println(mess);
|
||||
}
|
||||
}
|
||||
@ -213,9 +214,9 @@ public class Base {
|
||||
}
|
||||
platform = (Platform) platformClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
Base.showError("Problem Setting the Platform",
|
||||
"An unknown error occurred while trying to load\n" +
|
||||
"platform-specific code for your machine.", e);
|
||||
Base.showError(_("Problem Setting the Platform"),
|
||||
_("An unknown error occurred while trying to load\n" +
|
||||
"platform-specific code for your machine."), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,10 +226,10 @@ public class Base {
|
||||
Class.forName("com.sun.jdi.VirtualMachine");
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
Base.showPlatforms();
|
||||
Base.showError("Please install JDK 1.5 or later",
|
||||
"Arduino requires a full JDK (not just a JRE)\n" +
|
||||
"to run. Please install JDK 1.5 or later.\n" +
|
||||
"More information can be found in the reference.", cnfe);
|
||||
Base.showError(_("Please install JDK 1.5 or later"),
|
||||
_("Arduino requires a full JDK (not just a JRE)\n" +
|
||||
"to run. Please install JDK 1.5 or later.\n" +
|
||||
"More information can be found in the reference."), cnfe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,12 +251,12 @@ public class Base {
|
||||
if (sketchbookPath != null) {
|
||||
File skechbookFolder = new File(sketchbookPath);
|
||||
if (!skechbookFolder.exists()) {
|
||||
Base.showWarning("Sketchbook folder disappeared",
|
||||
"The sketchbook folder no longer exists.\n" +
|
||||
"Arduino will switch to the default sketchbook\n" +
|
||||
"location, and create a new sketchbook folder if\n" +
|
||||
"necessary. Arduino will then stop talking about\n" +
|
||||
"himself in the third person.", null);
|
||||
Base.showWarning(_("Sketchbook folder disappeared"),
|
||||
_("The sketchbook folder no longer exists.\n" +
|
||||
"Arduino will switch to the default sketchbook\n" +
|
||||
"location, and create a new sketchbook folder if\n" +
|
||||
"necessary. Arduino will then stop talking about\n" +
|
||||
"himself in the third person."), null);
|
||||
sketchbookPath = null;
|
||||
}
|
||||
}
|
||||
@ -525,13 +526,13 @@ public class Base {
|
||||
if (index == 26) {
|
||||
// In 0159, avoid running past z by sending people outdoors.
|
||||
if (!breakTime) {
|
||||
Base.showWarning("Time for a Break",
|
||||
"You've reached the limit for auto naming of new sketches\n" +
|
||||
"for the day. How about going for a walk instead?", null);
|
||||
Base.showWarning(_("Time for a Break"),
|
||||
_("You've reached the limit for auto naming of new sketches\n" +
|
||||
"for the day. How about going for a walk instead?"), null);
|
||||
breakTime = true;
|
||||
} else {
|
||||
Base.showWarning("Sunshine",
|
||||
"No really, time for some fresh air for you.", null);
|
||||
Base.showWarning(_("Sunshine"),
|
||||
_("No really, time for some fresh air for you."), null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -626,7 +627,7 @@ public class Base {
|
||||
public void handleOpenPrompt() {
|
||||
// get the frontmost window frame for placing file dialog
|
||||
FileDialog fd = new FileDialog(activeEditor,
|
||||
"Open an Arduino sketch...",
|
||||
_("Open an Arduino sketch..."),
|
||||
FileDialog.LOAD);
|
||||
// This was annoying people, so disabled it in 0125.
|
||||
//fd.setDirectory(Preferences.get("sketchbook.path"));
|
||||
@ -765,17 +766,17 @@ public class Base {
|
||||
if (Base.isMacOS()) {
|
||||
Object[] options = { "OK", "Cancel" };
|
||||
String prompt =
|
||||
"<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"</style> </head>" +
|
||||
"<b>Are you sure you want to Quit?</b>" +
|
||||
"<p>Closing the last open sketch will quit Arduino.";
|
||||
_("<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"</style> </head>" +
|
||||
"<b>Are you sure you want to Quit?</b>" +
|
||||
"<p>Closing the last open sketch will quit Arduino.");
|
||||
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
prompt,
|
||||
"Quit",
|
||||
_("Quit"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
@ -896,7 +897,7 @@ public class Base {
|
||||
|
||||
//System.out.println("rebuilding toolbar menu");
|
||||
// Add the single "Open" item
|
||||
item = Editor.newJMenuItem("Open...", 'O');
|
||||
item = Editor.newJMenuItem(_("Open..."), 'O');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleOpenPrompt();
|
||||
@ -963,7 +964,7 @@ public class Base {
|
||||
File sketchbookLibraries = getSketchbookLibrariesFolder();
|
||||
boolean found = addLibraries(importMenu, sketchbookLibraries);
|
||||
if (found) {
|
||||
JMenuItem contrib = new JMenuItem("Contributed");
|
||||
JMenuItem contrib = new JMenuItem(_("Contributed"));
|
||||
contrib.setEnabled(false);
|
||||
importMenu.insert(contrib, separatorIndex);
|
||||
importMenu.insertSeparator(separatorIndex);
|
||||
@ -1087,10 +1088,10 @@ public class Base {
|
||||
handleOpen(path);
|
||||
}
|
||||
} else {
|
||||
showWarning("Sketch Does Not Exist",
|
||||
"The selected sketch no longer exists.\n" +
|
||||
"You may need to restart Arduino to update\n" +
|
||||
"the sketchbook menu.", null);
|
||||
showWarning(_("Sketch Does Not Exist"),
|
||||
_("The selected sketch no longer exists.\n" +
|
||||
"You may need to restart Arduino to update\n" +
|
||||
"the sketchbook menu."), null);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1116,14 +1117,15 @@ public class Base {
|
||||
//if (!sanityCheck.equals(list[i])) {
|
||||
if (!Sketch.isSanitaryName(list[i])) {
|
||||
if (!builtOnce) {
|
||||
String complaining =
|
||||
"The sketch \"" + list[i] + "\" cannot be used.\n" +
|
||||
"Sketch names must contain only basic letters and numbers\n" +
|
||||
"(ASCII-only with no spaces, " +
|
||||
"and it cannot start with a number).\n" +
|
||||
"To get rid of this message, remove the sketch from\n" +
|
||||
entry.getAbsolutePath();
|
||||
Base.showMessage("Ignoring sketch with bad name", complaining);
|
||||
String complaining = I18n.format(
|
||||
_("The sketch \"{0}\" cannot be used.\n" +
|
||||
"Sketch names must contain only basic letters and numbers\n" +
|
||||
"(ASCII-only with no spaces, " +
|
||||
"and it cannot start with a number).\n" +
|
||||
"To get rid of this message, remove the sketch from\n" +
|
||||
"{1}"), list[i], entry.getAbsolutePath()
|
||||
);
|
||||
Base.showMessage(_("Ignoring sketch with bad name"), complaining);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -1192,11 +1194,13 @@ public class Base {
|
||||
// if (libraryJar.exists()) {
|
||||
String sanityCheck = Sketch.sanitizeName(potentialName);
|
||||
if (!sanityCheck.equals(potentialName)) {
|
||||
String mess =
|
||||
"The library \"" + potentialName + "\" cannot be used.\n" +
|
||||
"Library names must contain only basic letters and numbers.\n" +
|
||||
"(ASCII only and no spaces, and it cannot start with a number)";
|
||||
Base.showMessage("Ignoring bad library name", mess);
|
||||
String mess = I18n.format(
|
||||
_("The library \"{0}\" cannot be used.\n" +
|
||||
"Library names must contain only basic letters and numbers.\n" +
|
||||
"(ASCII only and no spaces, and it cannot start with a number)"),
|
||||
potentialName
|
||||
);
|
||||
Base.showMessage(_("Ignoring bad library name"), mess);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1421,17 +1425,17 @@ public class Base {
|
||||
try {
|
||||
settingsFolder = platform.getSettingsFolder();
|
||||
} catch (Exception e) {
|
||||
showError("Problem getting data folder",
|
||||
"Error getting the Arduino data folder.", e);
|
||||
showError(_("Problem getting data folder"),
|
||||
_("Error getting the Arduino data folder."), e);
|
||||
}
|
||||
}
|
||||
|
||||
// create the folder if it doesn't exist already
|
||||
if (!settingsFolder.exists()) {
|
||||
if (!settingsFolder.mkdirs()) {
|
||||
showError("Settings issues",
|
||||
"Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your settings.", null);
|
||||
showError(_("Settings issues"),
|
||||
_("Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your settings."), null);
|
||||
}
|
||||
}
|
||||
return settingsFolder;
|
||||
@ -1591,9 +1595,9 @@ public class Base {
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
showError("You forgot your sketchbook",
|
||||
"Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your sketchbook.", null);
|
||||
showError(_("You forgot your sketchbook"),
|
||||
_("Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your sketchbook."), null);
|
||||
}
|
||||
|
||||
return sketchbookFolder;
|
||||
@ -1612,7 +1616,7 @@ public class Base {
|
||||
return folder;
|
||||
}
|
||||
|
||||
String prompt = "Select (or create new) folder for sketches...";
|
||||
String prompt = _("Select (or create new) folder for sketches...");
|
||||
folder = Base.selectFolder(prompt, null, null);
|
||||
if (folder == null) {
|
||||
System.exit(0);
|
||||
@ -1636,8 +1640,8 @@ public class Base {
|
||||
platform.openURL(url);
|
||||
|
||||
} catch (Exception e) {
|
||||
showWarning("Problem Opening URL",
|
||||
"Could not open the URL\n" + url, e);
|
||||
showWarning(_("Problem Opening URL"),
|
||||
I18n.format(_("Could not open the URL\n{0}"), url), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1660,8 +1664,8 @@ public class Base {
|
||||
platform.openFolder(file);
|
||||
|
||||
} catch (Exception e) {
|
||||
showWarning("Problem Opening Folder",
|
||||
"Could not open the folder\n" + file.getAbsolutePath(), e);
|
||||
showWarning(_("Problem Opening Folder"),
|
||||
I18n.format(_("Could not open the folder\n{0}"), file.getAbsolutePath()), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1774,36 +1778,36 @@ public class Base {
|
||||
|
||||
static public void showGettingStarted() {
|
||||
if (Base.isMacOS()) {
|
||||
Base.showReference("Guide_MacOSX.html");
|
||||
Base.showReference(_("Guide_MacOSX.html"));
|
||||
} else if (Base.isWindows()) {
|
||||
Base.showReference("Guide_Windows.html");
|
||||
Base.showReference(_("Guide_Windows.html"));
|
||||
} else {
|
||||
Base.openURL("http://www.arduino.cc/playground/Learning/Linux");
|
||||
Base.openURL(_("http://www.arduino.cc/playground/Learning/Linux"));
|
||||
}
|
||||
}
|
||||
|
||||
static public void showReference() {
|
||||
showReference("index.html");
|
||||
showReference(_("index.html"));
|
||||
}
|
||||
|
||||
|
||||
static public void showEnvironment() {
|
||||
showReference("Guide_Environment.html");
|
||||
showReference(_("Guide_Environment.html"));
|
||||
}
|
||||
|
||||
|
||||
static public void showPlatforms() {
|
||||
showReference("environment" + File.separator + "platforms.html");
|
||||
showReference(_("environment") + File.separator + _("platforms.html"));
|
||||
}
|
||||
|
||||
|
||||
static public void showTroubleshooting() {
|
||||
showReference("Guide_Troubleshooting.html");
|
||||
showReference(_("Guide_Troubleshooting.html"));
|
||||
}
|
||||
|
||||
|
||||
static public void showFAQ() {
|
||||
showReference("FAQ.html");
|
||||
showReference(_("FAQ.html"));
|
||||
}
|
||||
|
||||
|
||||
@ -1815,7 +1819,7 @@ public class Base {
|
||||
* much of a bummer, but something to notify the user about.
|
||||
*/
|
||||
static public void showMessage(String title, String message) {
|
||||
if (title == null) title = "Message";
|
||||
if (title == null) title = _("Message");
|
||||
|
||||
if (commandLine) {
|
||||
System.out.println(title + ": " + message);
|
||||
@ -1831,7 +1835,7 @@ public class Base {
|
||||
* Non-fatal error message with optional stack trace side dish.
|
||||
*/
|
||||
static public void showWarning(String title, String message, Exception e) {
|
||||
if (title == null) title = "Warning";
|
||||
if (title == null) title = _("Warning");
|
||||
|
||||
if (commandLine) {
|
||||
System.out.println(title + ": " + message);
|
||||
@ -1850,7 +1854,7 @@ public class Base {
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
static public void showError(String title, String message, Throwable e) {
|
||||
if (title == null) title = "Error";
|
||||
if (title == null) title = _("Error");
|
||||
|
||||
if (commandLine) {
|
||||
System.err.println(title + ": " + message);
|
||||
@ -2183,14 +2187,22 @@ public class Base {
|
||||
if (file.exists()) {
|
||||
boolean result = file.delete();
|
||||
if (!result) {
|
||||
throw new IOException("Could not remove old version of " +
|
||||
file.getAbsolutePath());
|
||||
throw new IOException(
|
||||
I18n.format(
|
||||
_("Could not remove old version of {0}"),
|
||||
file.getAbsolutePath()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
boolean result = temp.renameTo(file);
|
||||
if (!result) {
|
||||
throw new IOException("Could not replace " +
|
||||
file.getAbsolutePath());
|
||||
throw new IOException(
|
||||
I18n.format(
|
||||
_("Could not replace {0}"),
|
||||
file.getAbsolutePath()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2228,7 +2240,7 @@ public class Base {
|
||||
if (dir.exists()) {
|
||||
removeDescendants(dir);
|
||||
if (!dir.delete()) {
|
||||
System.err.println("Could not delete " + dir);
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2251,7 +2263,7 @@ public class Base {
|
||||
if (!Preferences.getBoolean("compiler.save_build_files")) {
|
||||
if (!dead.delete()) {
|
||||
// temporarily disabled
|
||||
System.err.println("Could not delete " + dead);
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dead));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user