Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 186735 Details for
Bug 331260
Implement an extensible translation service
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch alternative demo - replacing translation service
patch translation Oleg demo2.txt (text/plain), 25.76 KB, created by
Oleg Besedin
on 2011-01-13 10:46:03 EST
(
hide
)
Description:
Patch alternative demo - replacing translation service
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2011-01-13 10:46:03 EST
Size:
25.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.core.services >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.services/META-INF/MANIFEST.MF,v >retrieving revision 1.33 >diff -u -r1.33 MANIFEST.MF >--- META-INF/MANIFEST.MF 20 Jul 2010 19:43:28 -0000 1.33 >+++ META-INF/MANIFEST.MF 13 Jan 2011 15:36:57 -0000 >@@ -11,8 +11,11 @@ > CDC-1.1/Foundation-1.1 > Import-Package: javax.inject, > org.eclipse.osgi.service.debug;version="1.1.0", >+ org.eclipse.osgi.service.localization;version="1.1.0", > org.osgi.framework;version="1.3.0", > org.osgi.service.event;resolution:=optional, >+ org.osgi.service.log;version="1.3.0", >+ org.osgi.service.packageadmin;version="1.2.0", > org.osgi.util.tracker;version="1.4.2" > Require-Bundle: org.eclipse.equinox.common;bundle-version="3.4.0", > org.eclipse.equinox.preferences;bundle-version="3.3.0", >@@ -42,6 +45,7 @@ > org.eclipse.e4.ui.workbench.swt, > org.eclipse.ui.workbench", > org.eclipse.e4.core.services.statusreporter;x-friends:="org.eclipse.e4.ui.workbench.swt", >+ org.eclipse.e4.core.services.translation, > org.eclipse.e4.core.services.util;x-internal:=true, > org.eclipse.e4.core.services.work;x-friends:="org.eclipse.e4.ui.workbench" > Eclipse-ExtensibleAPI: true >Index: src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java >=================================================================== >RCS file: src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java >diff -N src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.core.internal.services; >+ >+import java.net.URI; >+import java.net.URISyntaxException; >+import java.util.MissingResourceException; >+import java.util.ResourceBundle; >+import org.eclipse.e4.core.services.translation.TranslationService; >+import org.eclipse.osgi.service.localization.BundleLocalization; >+import org.osgi.framework.Bundle; >+import org.osgi.service.log.LogService; >+import org.osgi.service.packageadmin.PackageAdmin; >+ >+// There is no replacement for PackageAdmin#getBundles() >+@SuppressWarnings("deprecation") >+public class BundleTranslationProvider extends TranslationService { >+ >+ /** >+ * The schema identifier used for Eclipse platform references >+ */ >+ final private static String PLATFORM_SCHEMA = "platform"; //$NON-NLS-1$ >+ final private static String PLUGIN_SEGMENT = "/plugin/"; //$NON-NLS-1$ >+ final private static String FRAGMENT_SEGMENT = "/fragment/"; //$NON-NLS-1$ >+ >+ /** >+ * Prefix for keys to be translated >+ */ >+ private static final String KEY_PREFIX = "%"; //$NON-NLS-1$ >+ >+ /** >+ * Prefix that aborts translation >+ */ >+ private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$ >+ >+ @Override >+ public String translate(String key, String contributorURI) { >+ Bundle bundle = getBundle(contributorURI); >+ if (bundle == null) >+ return key; >+ BundleLocalization localizationService = ServicesActivator.getDefault() >+ .getLocalizationService(); >+ if (localizationService == null) >+ return key; >+ // TBD locale might contain extra information, such as calendar specification >+ // that might need to be removed. >+ ResourceBundle resourceBundle = localizationService.getLocalization(bundle, locale); >+ return getResourceString(key, resourceBundle); >+ } >+ >+ private Bundle getBundle(String contributorURI) { >+ if (contributorURI == null) >+ return null; >+ URI uri; >+ try { >+ uri = new URI(contributorURI); >+ } catch (URISyntaxException e) { >+ LogService logService = ServicesActivator.getDefault().getLogService(); >+ if (logService != null) >+ logService.log(LogService.LOG_ERROR, "Invalid contributor URI: " + contributorURI); //$NON-NLS-1$ >+ return null; >+ } >+ if (!PLATFORM_SCHEMA.equals(uri.getScheme())) >+ return null; // not implemented >+ String bundleName = uri.getPath(); >+ if (bundleName.startsWith(PLUGIN_SEGMENT)) >+ bundleName = bundleName.substring(PLUGIN_SEGMENT.length()); >+ else if (bundleName.startsWith(FRAGMENT_SEGMENT)) >+ bundleName = bundleName.substring(FRAGMENT_SEGMENT.length()); >+ PackageAdmin packageAdmin = ServicesActivator.getDefault().getPackageAdmin(); >+ Bundle[] bundles = packageAdmin.getBundles(bundleName, null); >+ if (bundles == null) >+ return null; >+ // Return the first bundle that is not installed or uninstalled >+ for (int i = 0; i < bundles.length; i++) { >+ if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { >+ return bundles[i]; >+ } >+ } >+ return null; >+ } >+ >+ public String getResourceString(String value, ResourceBundle resourceBundle) { >+ String s = value.trim(); >+ if (!s.startsWith(KEY_PREFIX, 0)) >+ return s; >+ if (s.startsWith(KEY_DOUBLE_PREFIX, 0)) >+ return s.substring(1); >+ >+ int ix = s.indexOf(' '); >+ String key = ix == -1 ? s : s.substring(0, ix); >+ String dflt = ix == -1 ? s : s.substring(ix + 1); >+ >+ if (resourceBundle == null) >+ return dflt; >+ >+ try { >+ return resourceBundle.getString(key.substring(1)); >+ } catch (MissingResourceException e) { >+ // this will avoid requiring a bundle access on the next lookup >+ return dflt; >+ } >+ } >+ >+} >Index: src/org/eclipse/e4/core/internal/services/ServicesActivator.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ServicesActivator.java,v >retrieving revision 1.1 >diff -u -r1.1 ServicesActivator.java >--- src/org/eclipse/e4/core/internal/services/ServicesActivator.java 30 Nov 2009 16:55:53 -0000 1.1 >+++ src/org/eclipse/e4/core/internal/services/ServicesActivator.java 13 Jan 2011 15:36:57 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 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 >@@ -10,16 +10,22 @@ > *******************************************************************************/ > package org.eclipse.e4.core.internal.services; > >-import org.eclipse.osgi.service.debug.DebugOptions; >+import org.eclipse.osgi.service.localization.BundleLocalization; > import org.osgi.framework.BundleActivator; > import org.osgi.framework.BundleContext; >+import org.osgi.service.log.LogService; >+import org.osgi.service.packageadmin.PackageAdmin; > import org.osgi.util.tracker.ServiceTracker; > >+//there is no replacement for PackageAdmin#getBundles() >+@SuppressWarnings("deprecation") > public class ServicesActivator implements BundleActivator { > > static private ServicesActivator defaultInstance; > private BundleContext bundleContext; >- private ServiceTracker debugTracker = null; >+ private ServiceTracker<PackageAdmin, PackageAdmin> pkgAdminTracker; >+ private ServiceTracker<LogService, LogService> logTracker; >+ private ServiceTracker<BundleLocalization, BundleLocalization> localizationTracker = null; > > public ServicesActivator() { > defaultInstance = this; >@@ -34,25 +40,51 @@ > } > > public void stop(BundleContext context) throws Exception { >- if (debugTracker != null) { >- debugTracker.close(); >- debugTracker = null; >+ if (pkgAdminTracker != null) { >+ pkgAdminTracker.close(); >+ pkgAdminTracker = null; >+ } >+ if (localizationTracker != null) { >+ localizationTracker.close(); >+ localizationTracker = null; >+ } >+ if (logTracker != null) { >+ logTracker.close(); >+ logTracker = null; > } > bundleContext = null; > } > >- public boolean getBooleanDebugOption(String option, boolean defaultValue) { >- if (debugTracker == null) { >- debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null); >- debugTracker.open(); >- } >- DebugOptions options = (DebugOptions) debugTracker.getService(); >- if (options != null) { >- String value = options.getOption(option); >- if (value != null) >- return value.equalsIgnoreCase("true"); //$NON-NLS-1$ >+ public PackageAdmin getPackageAdmin() { >+ if (pkgAdminTracker == null) { >+ if (bundleContext == null) >+ return null; >+ pkgAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(bundleContext, >+ PackageAdmin.class, null); >+ pkgAdminTracker.open(); > } >- return defaultValue; >+ return (PackageAdmin) pkgAdminTracker.getService(); > } > >+ public LogService getLogService() { >+ if (logTracker == null) { >+ if (bundleContext == null) >+ return null; >+ logTracker = new ServiceTracker<LogService, LogService>(bundleContext, >+ LogService.class, null); >+ logTracker.open(); >+ } >+ return logTracker.getService(); >+ } >+ >+ public BundleLocalization getLocalizationService() { >+ if (localizationTracker == null) { >+ if (bundleContext == null) >+ return null; >+ localizationTracker = new ServiceTracker<BundleLocalization, BundleLocalization>( >+ bundleContext, BundleLocalization.class, null); >+ localizationTracker.open(); >+ } >+ return localizationTracker.getService(); >+ } > } >Index: src/org/eclipse/e4/core/services/translation/TranslationProviderFactory.java >=================================================================== >RCS file: src/org/eclipse/e4/core/services/translation/TranslationProviderFactory.java >diff -N src/org/eclipse/e4/core/services/translation/TranslationProviderFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/core/services/translation/TranslationProviderFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.core.services.translation; >+ >+import org.eclipse.e4.core.contexts.ContextInjectionFactory; >+import org.eclipse.e4.core.contexts.IEclipseContext; >+import org.eclipse.e4.core.internal.services.BundleTranslationProvider; >+ >+/** >+ * Factory for translation providers. >+ */ >+final public class TranslationProviderFactory { >+ >+ private TranslationProviderFactory() { >+ // prevents instantiation >+ } >+ >+ /** >+ * Returns default bundle-based translation provider. >+ * >+ * @param context >+ * the context for the translation provider >+ * @return bundle-based translation provider >+ */ >+ static public TranslationService bundleTranslationService(IEclipseContext context) { >+ return ContextInjectionFactory.make(BundleTranslationProvider.class, context); >+ } >+ >+} >Index: src/org/eclipse/e4/core/services/translation/TranslationService.java >=================================================================== >RCS file: src/org/eclipse/e4/core/services/translation/TranslationService.java >diff -N src/org/eclipse/e4/core/services/translation/TranslationService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/core/services/translation/TranslationService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.core.services.translation; >+ >+import javax.inject.Inject; >+import javax.inject.Named; >+ >+/** >+ * Provides localization service. >+ */ >+abstract public class TranslationService { >+ >+ /** >+ * The name of the context variable with locale information >+ */ >+ static public final String LOCALE = "org.eclipse.e4.core.locale"; //$NON-NLS-1$ >+ >+ @Inject >+ @Named(LOCALE) >+ protected String locale; >+ >+ @Inject >+ public TranslationService() { >+ // placeholder >+ } >+ >+ /** >+ * Translates the key from the contributor. If translation can not be found, the original key >+ * should be returned. >+ * <p> >+ * This method is expected to be overridden by the implementors. >+ * </p> >+ * >+ * @param key >+ * the key >+ * @param contributorURI >+ * URI of the contributor >+ * @return localized value, or the original key if the translation can not be done >+ */ >+ public String translate(String key, String contributorURI) { >+ return key; >+ } >+} >#P org.eclipse.e4.demo.contacts >Index: Application.e4xmi >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.demo.contacts/Application.e4xmi,v >retrieving revision 1.17 >diff -u -r1.17 Application.e4xmi >--- Application.e4xmi 1 Dec 2010 19:06:49 -0000 1.17 >+++ Application.e4xmi 13 Jan 2011 15:36:57 -0000 >@@ -10,7 +10,7 @@ > </children> > </children> > <mainMenu xmi:id="menu:org.eclipse.ui.main.menu" elementId="menu:org.eclipse.ui.main.menu"> >- <children xsi:type="menu:Menu" xmi:id="_SeXUD-8EEd6FC9cDb6iV7g" elementId="_SeXUD-8EEd6FC9cDb6iV7g" label="File"> >+ <children xsi:type="menu:Menu" xmi:id="_SeXUD-8EEd6FC9cDb6iV7g" elementId="_SeXUD-8EEd6FC9cDb6iV7g" label="%fileMenu"> > <children xsi:type="menu:HandledMenuItem" xmi:id="_SeXUEO8EEd6FC9cDb6iV7g" elementId="_SeXUEO8EEd6FC9cDb6iV7g" label="Save" iconURI="platform:/plugin/org.eclipse.e4.demo.contacts/icons/silk/disk.png" command="contacts.save"/> > <children xsi:type="menu:HandledMenuItem" xmi:id="_SeXUEe8EEd6FC9cDb6iV7g" elementId="_SeXUEe8EEd6FC9cDb6iV7g" label="Delete" iconURI="platform:/plugin/org.eclipse.e4.demo.contacts/icons/silk/user_delete.png" command="contacts.delete"/> > <children xsi:type="menu:DirectMenuItem" xmi:id="_SeXUEu8EEd6FC9cDb6iV7g" elementId="_SeXUEu8EEd6FC9cDb6iV7g" label="Direct Exit" contributionURI="platform:/plugin/org.eclipse.e4.demo.contacts/org.eclipse.e4.demo.contacts.handlers.ExitHandler"/> >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.demo.contacts/build.properties,v >retrieving revision 1.4 >diff -u -r1.4 build.properties >--- build.properties 16 Apr 2010 17:28:17 -0000 1.4 >+++ build.properties 13 Jan 2011 15:36:57 -0000 >@@ -10,4 +10,6 @@ > css/,\ > splash.bmp,\ > plugin_customization.ini,\ >- vcards/ >+ vcards/,\ >+ plugin_ru.properties,\ >+ plugin.properties >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.demo.contacts/META-INF/MANIFEST.MF,v >retrieving revision 1.15 >diff -u -r1.15 MANIFEST.MF >--- META-INF/MANIFEST.MF 24 Jun 2010 14:19:44 -0000 1.15 >+++ META-INF/MANIFEST.MF 13 Jan 2011 15:36:57 -0000 >@@ -24,12 +24,14 @@ > org.eclipse.e4.ui.bindings;bundle-version="0.9.0", > org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.0", > org.eclipse.e4.ui.css.swt;bundle-version="0.9.1", >- org.eclipse.e4.ui.di;bundle-version="0.9.0" >+ org.eclipse.e4.ui.di;bundle-version="0.9.0", >+ org.eclipse.e4.core.services;bundle-version="0.9.1" > Bundle-ActivationPolicy: lazy > Bundle-Vendor: Eclipse.org > Import-Package: javax.annotation;version="1.0.0", > javax.inject;version="1.0.0" > Bundle-Activator: org.eclipse.e4.demo.contacts.BundleActivatorImpl > Export-Package: org.eclipse.e4.demo.contacts.model >+Bundle-Localization: plugin > > >Index: plugin.properties >=================================================================== >RCS file: plugin.properties >diff -N plugin.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,11 @@ >+############################################################################### >+# Copyright (c) 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 >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+fileMenu = &File >Index: plugin_ru.properties >=================================================================== >RCS file: plugin_ru.properties >diff -N plugin_ru.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin_ru.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,11 @@ >+############################################################################### >+# Copyright (c) 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 >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+fileMenu = &\u0424\u0430\u0439\u043B >Index: src/org/eclipse/e4/demo/contacts/model/internal/BinaryTranslatorProvider.java >=================================================================== >RCS file: src/org/eclipse/e4/demo/contacts/model/internal/BinaryTranslatorProvider.java >diff -N src/org/eclipse/e4/demo/contacts/model/internal/BinaryTranslatorProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/demo/contacts/model/internal/BinaryTranslatorProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.e4.demo.contacts.model.internal; >+ >+import org.eclipse.e4.core.services.translation.TranslationService; >+ >+public class BinaryTranslatorProvider extends TranslationService { >+ >+ @Override >+ public String translate(String key, String contributorURI) { >+ if (key == null) >+ return null; >+ char[] charArray = key.toCharArray(); >+ StringBuffer tmp = new StringBuffer(); >+ tmp.append("0x"); >+ for(int i = 0; i < charArray.length; i++) { >+ int value = charArray[i]; >+ tmp.append(Integer.toHexString(value)); >+ } >+ return tmp.toString(); >+ } >+ >+} >Index: src/org/eclipse/e4/demo/contacts/model/internal/ModelLifeCycleExtension.java >=================================================================== >RCS file: src/org/eclipse/e4/demo/contacts/model/internal/ModelLifeCycleExtension.java >diff -N src/org/eclipse/e4/demo/contacts/model/internal/ModelLifeCycleExtension.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/demo/contacts/model/internal/ModelLifeCycleExtension.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.e4.demo.contacts.model.internal; >+ >+import javax.inject.Inject; >+import org.eclipse.e4.core.contexts.ContextInjectionFactory; >+import org.eclipse.e4.core.contexts.IEclipseContext; >+import org.eclipse.e4.core.services.translation.TranslationService; >+import org.eclipse.e4.ui.model.application.MApplication; >+import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals; >+ >+public class ModelLifeCycleExtension { >+ >+ @Inject >+ public ModelLifeCycleExtension() { >+ // placeholder >+ } >+ >+ @ProcessRemovals >+ public void overrideTranslation(MApplication application) { >+ IEclipseContext appContext = application.getContext(); >+ BinaryTranslatorProvider translationService = ContextInjectionFactory.make(BinaryTranslatorProvider.class, appContext); >+ appContext.set(TranslationService.class, translationService); >+ } >+ >+} >#P org.eclipse.e4.ui.workbench.renderers.swt >Index: src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java,v >retrieving revision 1.6 >diff -u -r1.6 MenuManagerRenderer.java >--- src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java 18 Nov 2010 20:35:56 -0000 1.6 >+++ src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java 13 Jan 2011 15:36:58 -0000 >@@ -25,8 +25,10 @@ > import org.eclipse.e4.core.contexts.RunAndTrack; > import org.eclipse.e4.core.services.events.IEventBroker; > import org.eclipse.e4.core.services.log.Logger; >+import org.eclipse.e4.core.services.translation.TranslationService; > import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer; > import org.eclipse.e4.ui.model.application.MApplication; >+import org.eclipse.e4.ui.model.application.MApplicationElement; > import org.eclipse.e4.ui.model.application.ui.MCoreExpression; > import org.eclipse.e4.ui.model.application.ui.MElementContainer; > import org.eclipse.e4.ui.model.application.ui.MUIElement; >@@ -754,7 +756,18 @@ > if (text == null || text.length() == 0) { > return NO_LABEL; > } >- return text; >+ // XXX >+ return translate(text, menuModel); >+ } >+ >+ private String translate(String key, MApplicationElement element) { >+ IEclipseContext parentContext = modelService >+ .getContainingContext((MUIElement) element); >+ TranslationService translation = parentContext >+ .get(TranslationService.class); >+ String translated = translation.translate(key, >+ element.getContributorURI()); >+ return translated; > } > > private ImageDescriptor getImageDescriptor(MUILabel element) { >#P org.eclipse.e4.ui.workbench.swt >Index: src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java,v >retrieving revision 1.30 >diff -u -r1.30 E4Application.java >--- src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java 29 Nov 2010 20:13:34 -0000 1.30 >+++ src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java 13 Jan 2011 15:36:58 -0000 >@@ -18,6 +18,7 @@ > import java.io.OutputStream; > import java.net.URL; > import java.util.List; >+import java.util.Locale; > import java.util.Properties; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.runtime.Assert; >@@ -35,6 +36,8 @@ > import org.eclipse.e4.core.services.log.ILoggerProvider; > import org.eclipse.e4.core.services.log.Logger; > import org.eclipse.e4.core.services.statusreporter.StatusReporter; >+import org.eclipse.e4.core.services.translation.TranslationService; >+import org.eclipse.e4.core.services.translation.TranslationProviderFactory; > import org.eclipse.e4.ui.internal.workbench.ActiveChildLookupFunction; > import org.eclipse.e4.ui.internal.workbench.ActivePartLookupFunction; > import org.eclipse.e4.ui.internal.workbench.DefaultLoggerProvider; >@@ -428,6 +431,15 @@ > appContext > .set(Logger.class.getName(), ContextInjectionFactory.make( > WorkbenchLogger.class, appContext)); >+ >+ // translation >+ String locale = Locale.getDefault().toString(); >+ appContext.set(TranslationService.LOCALE, locale); >+ TranslationService bundleTranslationProvider = TranslationProviderFactory >+ .bundleTranslationService(appContext); >+ appContext.set(TranslationService.class, >+ bundleTranslationProvider); >+ > appContext.set(Adapter.class.getName(), > ContextInjectionFactory.make(EclipseAdapter.class, appContext)); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 331260
:
183968
|
184155
|
185001
|
185457
|
186664
|
186665
|
186735
|
186742
|
186743
|
186844