translation

This commit is contained in:
bancika
2020-04-23 10:20:56 +02:00
parent 0d556b66e8
commit f92a80e260
10 changed files with 247 additions and 130 deletions
@@ -46,14 +46,21 @@ import org.diylc.core.ValidationException;
import org.diylc.lang.TranslateUtil;
import org.diylc.swingframework.ButtonDialog;
public class PropertyEditorDialog extends ButtonDialog {
public class PropertyEditorDialog extends ButtonDialog {
private static final Logger LOG = Logger.getLogger(PropertyEditorDialog.class);
private static final long serialVersionUID = 1L;
private static final String ERROR_TITLE = TranslateUtil.translate("Error");
private static final String INPUT_ERROR = TranslateUtil.translate("Input error for \"%s\": %s");
private static final String DEFAULT_BOX_TOOLTIP_TEXT =
TranslateUtil.translate("If this box is checked application will use the current value as a<br>default when creating new components of the same type");
private static final String DEFAULT_BOX_TOOLTIP =
"<html>If this box is checked application will use the current value as a<br>default when creating new components of the same type</html>";
"<html>"
+ DEFAULT_BOX_TOOLTIP_TEXT
+ "</html>";
private List<PropertyWrapper> properties;
private Set<PropertyWrapper> defaultedProperties;
@@ -103,7 +110,7 @@ public class PropertyEditorDialog extends ButtonDialog {
property.getValidator().validate(testObject, property.getValue());
} catch (ValidationException ve) {
JOptionPane.showMessageDialog(PropertyEditorDialog.this,
"Input error for \"" + property.getName() + "\": " + ve.getMessage(), "Error",
String.format(INPUT_ERROR, property.getName(), ve.getMessage()), ERROR_TITLE,
JOptionPane.ERROR_MESSAGE);
return false;
}
@@ -44,7 +44,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
*
* @author Branislav Stojkovic
*/
public class ConfigPlugin implements IPlugIn {
public class ConfigPlugin implements IPlugIn {
private static final Logger LOG = Logger.getLogger(ConfigPlugin.class);
@@ -56,7 +56,9 @@ public class ConfigPlugin implements IPlugIn {
public static final String COMPONENT_BROWSER = "componentBrowser";
public static final String SEARCHABLE_TREE = "Searchable Tree";
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
private static final String LANGUAGE_MENU = "Language";
private static final String LANGUAGE_MENU = TranslateUtil.translate("Language");
private static final String LANG_RESTART = TranslateUtil.translate("Language selection will be applied after the application is restarted.");
private ISwingUI swingUI;
@@ -183,7 +185,7 @@ public class ConfigPlugin implements IPlugIn {
@Override
public void valueChanged(String key, Object value) {
swingUI.showMessage("Language selection will be applied after the application is restarted.", "Language", ISwingUI.INFORMATION_MESSAGE);
swingUI.showMessage(LANG_RESTART, LANGUAGE_MENU, ISwingUI.INFORMATION_MESSAGE);
}
});
}
@@ -53,7 +53,10 @@ import org.diylc.swingframework.update.UpdateDialog;
*/
public class HelpMenuPlugin implements IPlugIn {
private static final String HELP_TITLE = "Help";
private static final String HELP_TITLE = "Help";
private static final String INFORMATION = TranslateUtil.translate("Information");
private static final String HISTORY_NOT_AVAILABLE = TranslateUtil.translate("Version history is not available.");
public static String MANUAL_URL = "https://github.com/bancika/diy-layout-creator/blob/wiki/Manual.md";
public static String FAQ_URL = "https://github.com/bancika/diy-layout-creator/blob/wiki/FAQ.md";
@@ -123,7 +126,7 @@ public class HelpMenuPlugin implements IPlugIn {
public AboutAction() {
super();
putValue(AbstractAction.NAME, TranslateUtil.translate("About"));
putValue(AbstractAction.NAME, "About");
putValue(AbstractAction.SMALL_ICON, IconLoader.About.getIcon());
}
@@ -139,7 +142,7 @@ public class HelpMenuPlugin implements IPlugIn {
public RecentUpdatesAction() {
super();
putValue(AbstractAction.NAME, TranslateUtil.translate("Recent Updates"));
putValue(AbstractAction.NAME, "Recent Updates");
putValue(AbstractAction.SMALL_ICON, IconLoader.ScrollInformation.getIcon());
}
@@ -147,7 +150,7 @@ public class HelpMenuPlugin implements IPlugIn {
public void actionPerformed(ActionEvent e) {
List<Version> updates = plugInPort.getRecentUpdates();
if (updates == null)
swingUI.showMessage("Version history is not available.", "Information", IView.INFORMATION_MESSAGE);
swingUI.showMessage(HISTORY_NOT_AVAILABLE, INFORMATION, IView.INFORMATION_MESSAGE);
else {
String html = UpdateChecker.createUpdateHTML(updates);
UpdateDialog updateDialog = new UpdateDialog(swingUI.getOwnerFrame().getRootPane(), html, (String)null);
@@ -165,7 +168,7 @@ public class HelpMenuPlugin implements IPlugIn {
public NavigateURLAction(String name, Icon icon, String url) {
super();
this.url = url;
putValue(AbstractAction.NAME, TranslateUtil.translate(name));
putValue(AbstractAction.NAME, name);
putValue(AbstractAction.SMALL_ICON, icon);
}
@@ -188,7 +191,7 @@ public class HelpMenuPlugin implements IPlugIn {
public NavigateFolderAction(String name, Icon icon, String url) {
super();
this.url = url;
putValue(AbstractAction.NAME, TranslateUtil.translate(name));
putValue(AbstractAction.NAME, name);
putValue(AbstractAction.SMALL_ICON, icon);
}
@@ -69,6 +69,7 @@ import org.diylc.common.ITask;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IView;
import org.diylc.images.IconLoader;
import org.diylc.lang.TranslateUtil;
import org.diylc.presenter.Presenter;
import org.diylc.swing.ISwingUI;
import org.diylc.swingframework.MemoryBar;
@@ -78,12 +79,33 @@ import org.diylc.swingframework.update.UpdateLabel;
public class StatusBar extends JPanel implements IPlugIn {
private static final String CLICK_TO_CREATE = TranslateUtil.translate("Click on the canvas to create a new %s or press %s to cancel");
private static final String CLICK_TO_SET_POINT =
TranslateUtil.translate("Click on the canvas to set the %s control point of a new %s or press %s to cancel");
private static final String HOLD_TO_UNSTUCK = TranslateUtil.translate("hold %s and drag to unstuck from");
private static final String SELECTION = TranslateUtil.translate("Selection");
private static final String DRAG_POINTS_OF = TranslateUtil.translate("Drag control point(s) of");
private static final String DRAG_TO_PLACE_A_NEW = TranslateUtil.translate("Drag the mouse over the canvas to place a new");
private static final String ZOOM = TranslateUtil.translate("Zoom");
private static final String SELECTION_SIZE = TranslateUtil.translate("Selection Size");
private static final String SELECTION_IS_EMPTY = TranslateUtil.translate("Selection is empty.");
private static final String INFORMATION = TranslateUtil.translate("Information");
private static final String NO_HISTORY = TranslateUtil.translate("Version history is not available.");
private static final String CLICK_UPDATES = TranslateUtil.translate("Click to show recent changes and updates");
private static final String NO_ANNOUNCEMENTS = TranslateUtil.translate("No new public announcements available.");
private static final String ERROR_TITLE = TranslateUtil.translate("Error");
private static final String PUBLIC_ANNOUNCEMENT = TranslateUtil.translate("Public Announcement");
private static final String COULD_NOT_FETCH_ANNOUNCEMENTS = TranslateUtil.translate("Could not fetch public announcements.");
private static final String CLICK_TO_FETCH_ANNOUNCEMENT = TranslateUtil.translate("Click to fetch the most recent public announcement");
private static final String CLICK_THE_LIGHBULB = TranslateUtil.translate("Click the lighbulb icon in the bottom-right corner of the window for more info.");
private static final String NEW_VERSION_AVAILABLE = TranslateUtil.translate("New version available");
private static String HIGHLIGHT_CONNECTED_TIP = TranslateUtil.translate("Click on a component to highlight area directly or indirectly connected to the area below the cursor. To continue editing, this mode needs to be switched OFF");
private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(StatusBar.class);
public static String UPDATE_URL = "http://diy-fever.com/diylc/api/v1/update.xml";
private static String HIGHLIGHT_CONNECTED_TIP = "Click on a component to highlight area directly or indirectly connected to the area below the cursor. To continue editing, this mode needs to be switched OFF";
public static String UPDATE_URL = "http://diy-fever.com/diylc/api/v1/update.xml";
private static final Format sizeFormat = new DecimalFormat("0.##");
private JComboBox zoomBox;
@@ -138,8 +160,9 @@ public class StatusBar extends JPanel implements IPlugIn {
if (update != null) {
String updateHtml =
"<font size='4'><b>New version available:</b> " + update
+ "</font><br>Click the lighbulb icon in the bottom-right corner of the window for more info.";
"<font size='4'><b>" + NEW_VERSION_AVAILABLE + ":</b> " + update
+ "</font><br>"
+ CLICK_THE_LIGHBULB;
if (announcements == null || announcements.length() == 0)
return "<html>" + updateHtml + "</html>";
announcements = announcements.replace("<html>", "<html>" + updateHtml + "<br>");
@@ -225,7 +248,7 @@ public class StatusBar extends JPanel implements IPlugIn {
return new Point(0, -16);
}
};
announcementLabel.setToolTipText("Click to fetch the most recent public announcement");
announcementLabel.setToolTipText(CLICK_TO_FETCH_ANNOUNCEMENT);
announcementLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
announcementLabel.addMouseListener(new MouseAdapter() {
@@ -241,16 +264,16 @@ public class StatusBar extends JPanel implements IPlugIn {
@Override
public void failed(Exception e) {
LOG.error("Error while fetching announcements", e);
swingUI.showMessage("Could not fetch public announcements.", "Error", IView.ERROR_MESSAGE);
swingUI.showMessage(COULD_NOT_FETCH_ANNOUNCEMENTS, ERROR_TITLE, IView.ERROR_MESSAGE);
}
@Override
public void complete(String result) {
if (result != null && result.length() > 0) {
swingUI.showMessage(result, "Public Announcement", IView.INFORMATION_MESSAGE);
swingUI.showMessage(result, PUBLIC_ANNOUNCEMENT, IView.INFORMATION_MESSAGE);
announcementProvider.dismissed();
} else
swingUI.showMessage("No new public announcements available.", "Public Announcement",
swingUI.showMessage(NO_ANNOUNCEMENTS, PUBLIC_ANNOUNCEMENT,
IView.INFORMATION_MESSAGE);
}
@@ -272,7 +295,7 @@ public class StatusBar extends JPanel implements IPlugIn {
return new Point(0, -16);
}
};
recentChangesLabel.setToolTipText("Click to show recent changes and updates");
recentChangesLabel.setToolTipText(CLICK_UPDATES);
recentChangesLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
recentChangesLabel.addMouseListener(new MouseAdapter() {
@@ -281,7 +304,7 @@ public class StatusBar extends JPanel implements IPlugIn {
public void mouseClicked(MouseEvent e) {
List<Version> updates = plugInPort.getRecentUpdates();
if (updates == null)
swingUI.showMessage("Version history is not available.", "Information", IView.INFORMATION_MESSAGE);
swingUI.showMessage(NO_HISTORY, INFORMATION, IView.INFORMATION_MESSAGE);
else {
String html = UpdateChecker.createUpdateHTML(updates);
UpdateDialog updateDialog = new UpdateDialog(swingUI.getOwnerFrame().getRootPane(), html, (String)null);
@@ -344,13 +367,13 @@ public class StatusBar extends JPanel implements IPlugIn {
Point2D[] sizes = plugInPort.calculateSelectionDimension();
String text;
if (sizes == null) {
text = "Selection is empty.";
text = SELECTION_IS_EMPTY;
} else {
text =
sizeFormat.format(sizes[0].getX()) + " x " + sizeFormat.format(sizes[0].getY()) + " in\n"
+ sizeFormat.format(sizes[1].getX()) + " x " + sizeFormat.format(sizes[1].getY()) + " cm";
}
JOptionPane.showMessageDialog(SwingUtilities.getRootPane(StatusBar.this), text, "Selection Size",
JOptionPane.showMessageDialog(SwingUtilities.getRootPane(StatusBar.this), text, SELECTION_SIZE,
JOptionPane.INFORMATION_MESSAGE);
}
});
@@ -372,7 +395,7 @@ public class StatusBar extends JPanel implements IPlugIn {
add(getPositionLabel(), gbc);
JPanel zoomPanel = new JPanel(new BorderLayout());
zoomPanel.add(new JLabel("Zoom: "), BorderLayout.WEST);
zoomPanel.add(new JLabel(ZOOM + ": "), BorderLayout.WEST);
zoomPanel.add(getZoomBox(), BorderLayout.CENTER);
// zoomPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
// .createEtchedBorder(), BorderFactory.createEmptyBorder(2, 4, 2,
@@ -502,7 +525,7 @@ public class StatusBar extends JPanel implements IPlugIn {
if (componentSlot == null) {
if (componentNamesUnderCursor != null && !componentNamesUnderCursor.isEmpty()) {
String formattedNames = Utils.toCommaString(componentNamesUnderCursor);
statusText = "<html>Drag control point(s) of " + formattedNames + "</html>";
statusText = "<html>" + DRAG_POINTS_OF + " " + formattedNames + "</html>";
} else if (selectedComponentNames != null && !selectedComponentNames.isEmpty()) {
StringBuilder builder = new StringBuilder();
builder.append(Utils.toCommaString(selectedComponentNames.subList(0,
@@ -511,18 +534,18 @@ public class StatusBar extends JPanel implements IPlugIn {
builder.append(" and " + (selectedComponentNames.size() - 15) + " more");
}
if (!stuckComponentNames.isEmpty()) {
builder.append(" (hold <b>Ctrl</b> and drag to unstuck from ");
builder.append(" (" + String.format(HOLD_TO_UNSTUCK, "<b>Ctrl</b>") + " ");
builder.append(Utils.toCommaString(stuckComponentNames.subList(0, Math.min(5, stuckComponentNames.size()))));
if (stuckComponentNames.size() > 5) {
builder.append(" and " + (stuckComponentNames.size() - 5) + " more");
}
builder.append(")");
}
statusText = "<html>Selection: " + builder.toString() + "</html>";
statusText = "<html>" + SELECTION + ": " + builder.toString() + "</html>";
}
} else {
if (forceInstatiate != null && forceInstatiate)
statusText = "<html>Drag the mouse over the canvas to place a new <font color='blue'>" + componentSlot.getName()
statusText = "<html>" + DRAG_TO_PLACE_A_NEW + " <font color='blue'>" + componentSlot.getName()
+ "</font></html>";
else
switch (componentSlot.getCreationMethod()) {
@@ -534,13 +557,13 @@ public class StatusBar extends JPanel implements IPlugIn {
count = "second";
}
statusText =
"<html>Click on the canvas to set the " + count + " control point of a new <font color='blue'>"
+ componentSlot.getName() + "</font> or press <b>Esc</b> to cancel</html>";
"<html>" + String.format(CLICK_TO_SET_POINT, count, "<font color='blue'>"
+ componentSlot.getName() + "</font>", "<b>Esc</b>") + "</html>";
break;
case SINGLE_CLICK:
statusText =
"<html>Click on the canvas to create a new <font color='blue'>" + componentSlot.getName()
+ "</font> or press <b>Esc</b> to cancel</html>";
"<html>" + String.format(CLICK_TO_CREATE, "<font color='blue'>" + componentSlot.getName()
+ "</font>", "<b>Esc</b>") + "</html>";
break;
}
}
@@ -84,6 +84,7 @@ import org.diylc.core.IDIYComponent;
import org.diylc.core.IView;
import org.diylc.core.Template;
import org.diylc.images.IconLoader;
import org.diylc.lang.TranslateUtil;
import org.diylc.presenter.ComponentProcessor;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.plugins.toolbox.ComponentButtonFactory;
@@ -93,6 +94,9 @@ public class TreePanel extends JPanel {
private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(TreePanel.class);
private static final String CLICK_TO_INSTANTIATE =
TranslateUtil.translate("Left click to instantiate this component, right click for more options");
public static final String COMPONENT_SHORTCUT_KEY = "componentShortcuts";
@@ -751,11 +755,11 @@ public class TreePanel extends JPanel {
if (payload.isVisible())
setPreferredSize(new Dimension(250, 20));
else
setPreferredSize(new Dimension(0, 0));
setPreferredSize(new Dimension(0, 0));
} else {
setToolTipText("<html><b>" + payload.getComponentType().getName() + "</b><br>"
+ payload.getComponentType().getDescription() + "<br>Author: " + payload.getComponentType().getAuthor()
+ "<br><br>Left click to instantiate this component, right click for more options" + "</html>");
+ "<br><br>" + CLICK_TO_INSTANTIATE + "</html>");
setIcon(payload.getComponentType().getIcon());
if (payload.isVisible())
setPreferredSize(new Dimension(250, 32));
@@ -791,7 +795,8 @@ public class TreePanel extends JPanel {
}
}
setText("<html>" + payload.forDisplay() + shortCutHtml + variantsHtml + "</html>");
// translate categories
setText("<html>" + (payload.getComponentType() == null ? TranslateUtil.translate(payload.forDisplay()) : payload.forDisplay()) + shortCutHtml + variantsHtml + "</html>");
}
return this;