aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2011-08-22 11:17:31 (EDT)
committerPaul Webster2011-08-25 10:22:05 (EDT)
commit9e12cfb2ca24556273a9f3ef52e97314ad4c812d (patch)
treed4e7ad87ab2016b5accc2f4b2117a93be559388a
parentb32c69f18bd47e52d9733d8a9eead0bbf85d29c6 (diff)
downloadeclipse.platform.ui-9e12cfb2ca24556273a9f3ef52e97314ad4c812d.zip
eclipse.platform.ui-9e12cfb2ca24556273a9f3ef52e97314ad4c812d.tar.gz
eclipse.platform.ui-9e12cfb2ca24556273a9f3ef52e97314ad4c812d.tar.bz2
Fix for 353587 - Translation keys in Keys preference page
* Cause CommandProcessingAddon to localize names and description when transforming model commands and categories to legacy command and categories * Fix mistaken fragment reference for close-dialog command
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/src/org/eclipse/e4/ui/workbench/renderers/swt/cocoa/CocoaUIHandler.java4
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java30
2 files changed, 28 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/src/org/eclipse/e4/ui/workbench/renderers/swt/cocoa/CocoaUIHandler.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/src/org/eclipse/e4/ui/workbench/renderers/swt/cocoa/CocoaUIHandler.java
index 1e5896c..3588214 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/src/org/eclipse/e4/ui/workbench/renderers/swt/cocoa/CocoaUIHandler.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt.cocoa/src/org/eclipse/e4/ui/workbench/renderers/swt/cocoa/CocoaUIHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Adobe Systems, Inc. and others.
+ * Copyright (c) 2008, 2010-2011 Adobe Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -341,7 +341,7 @@ public class CocoaUIHandler {
closeDialogCommand.setElementId(COMMAND_ID_CLOSE_DIALOG);
closeDialogCommand.setCommandName("%command.closeDialog.name"); //$NON-NLS-1$
closeDialogCommand.setDescription("%command.closeDialog.desc"); //$NON-NLS-1$
- closeDialogCommand.setContributorURI(CocoaUIProcessor.FRAGMENT_ID);
+ closeDialogCommand.setContributorURI(CocoaUIProcessor.FRAGMENT_URI);
app.getCommands().add(closeDialogCommand);
}
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java
index 6167871..a545861 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010-2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,9 @@ import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.internal.workbench.Activator;
import org.eclipse.e4.ui.internal.workbench.Parameter;
import org.eclipse.e4.ui.internal.workbench.Policy;
+import org.eclipse.e4.ui.model.LocalizationHelper;
import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.commands.MCategory;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandParameter;
@@ -105,7 +107,8 @@ public class CommandProcessingAddon {
private void createCommand(MCommand cmdModel) {
IParameter[] parms = null;
String id = cmdModel.getElementId();
- String name = cmdModel.getCommandName();
+ String name = localize(cmdModel.getCommandName(), cmdModel);
+ String desc = localize(cmdModel.getDescription(), cmdModel);
List<MCommandParameter> modelParms = cmdModel.getParameters();
if (modelParms != null && !modelParms.isEmpty()) {
ArrayList<Parameter> parmList = new ArrayList<Parameter>();
@@ -123,7 +126,7 @@ public class CommandProcessingAddon {
if (cmdModel.getCategory() != null) {
cat = commandService.getCategory(cmdModel.getCategory().getElementId());
}
- commandService.defineCommand(id, name, null, cat, parms);
+ commandService.defineCommand(id, name, desc, cat, parms);
}
private void createCategories() {
@@ -135,7 +138,26 @@ public class CommandProcessingAddon {
private void createCategory(MCategory catModel) {
Category category = commandService.getCategory(catModel.getElementId());
if (!category.isDefined()) {
- category.define(catModel.getName(), catModel.getDescription());
+ category.define(localize(catModel.getName(), catModel),
+ localize(catModel.getDescription(), catModel));
}
}
+
+ /**
+ * Attempt to localize the provided key. Return the localized variant if found or the key itself
+ * otherwise.
+ *
+ * @param key
+ * the possible key reference
+ * @param modelElement
+ * the defining model element
+ * @return the localized variant if found, or the key
+ */
+ private String localize(String key, MApplicationElement modelElement) {
+ if (key == null) {
+ return null;
+ }
+ String localized = LocalizationHelper.getLocalized(key, modelElement);
+ return localized == null ? key : localized;
+ }
}