Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 331260 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+4 lines)
Lines 11-18 Link Here
11
 CDC-1.1/Foundation-1.1
11
 CDC-1.1/Foundation-1.1
12
Import-Package: javax.inject,
12
Import-Package: javax.inject,
13
 org.eclipse.osgi.service.debug;version="1.1.0",
13
 org.eclipse.osgi.service.debug;version="1.1.0",
14
 org.eclipse.osgi.service.localization;version="1.1.0",
14
 org.osgi.framework;version="1.3.0",
15
 org.osgi.framework;version="1.3.0",
15
 org.osgi.service.event;resolution:=optional,
16
 org.osgi.service.event;resolution:=optional,
17
 org.osgi.service.log;version="1.3.0",
18
 org.osgi.service.packageadmin;version="1.2.0",
16
 org.osgi.util.tracker;version="1.4.2"
19
 org.osgi.util.tracker;version="1.4.2"
17
Require-Bundle: org.eclipse.equinox.common;bundle-version="3.4.0",
20
Require-Bundle: org.eclipse.equinox.common;bundle-version="3.4.0",
18
 org.eclipse.equinox.preferences;bundle-version="3.3.0",
21
 org.eclipse.equinox.preferences;bundle-version="3.3.0",
Lines 42-47 Link Here
42
   org.eclipse.e4.ui.workbench.swt,
45
   org.eclipse.e4.ui.workbench.swt,
43
   org.eclipse.ui.workbench",
46
   org.eclipse.ui.workbench",
44
 org.eclipse.e4.core.services.statusreporter;x-friends:="org.eclipse.e4.ui.workbench.swt",
47
 org.eclipse.e4.core.services.statusreporter;x-friends:="org.eclipse.e4.ui.workbench.swt",
48
 org.eclipse.e4.core.services.translation,
45
 org.eclipse.e4.core.services.util;x-internal:=true,
49
 org.eclipse.e4.core.services.util;x-internal:=true,
46
 org.eclipse.e4.core.services.work;x-friends:="org.eclipse.e4.ui.workbench"
50
 org.eclipse.e4.core.services.work;x-friends:="org.eclipse.e4.ui.workbench"
47
Eclipse-ExtensibleAPI: true
51
Eclipse-ExtensibleAPI: true
(-)src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java (+113 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.e4.core.internal.services;
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import java.util.MissingResourceException;
16
import java.util.ResourceBundle;
17
import org.eclipse.e4.core.services.translation.TranslationService;
18
import org.eclipse.osgi.service.localization.BundleLocalization;
19
import org.osgi.framework.Bundle;
20
import org.osgi.service.log.LogService;
21
import org.osgi.service.packageadmin.PackageAdmin;
22
23
// There is no replacement for PackageAdmin#getBundles()
24
@SuppressWarnings("deprecation")
25
public class BundleTranslationProvider extends TranslationService {
26
27
	/**
28
	 * The schema identifier used for Eclipse platform references
29
	 */
30
	final private static String PLATFORM_SCHEMA = "platform"; //$NON-NLS-1$
31
	final private static String PLUGIN_SEGMENT = "/plugin/"; //$NON-NLS-1$
32
	final private static String FRAGMENT_SEGMENT = "/fragment/"; //$NON-NLS-1$
33
34
	/**
35
	 * Prefix for keys to be translated
36
	 */
37
	private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
38
39
	/**
40
	 * Prefix that aborts translation
41
	 */
42
	private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$	
43
44
	@Override
45
	public String translate(String key, String contributorURI) {
46
		Bundle bundle = getBundle(contributorURI);
47
		if (bundle == null)
48
			return key;
49
		BundleLocalization localizationService = ServicesActivator.getDefault()
50
				.getLocalizationService();
51
		if (localizationService == null)
52
			return key;
53
		// TBD locale might contain extra information, such as calendar specification
54
		// that might need to be removed.
55
		ResourceBundle resourceBundle = localizationService.getLocalization(bundle, locale);
56
		return getResourceString(key, resourceBundle);
57
	}
58
59
	private Bundle getBundle(String contributorURI) {
60
		if (contributorURI == null)
61
			return null;
62
		URI uri;
63
		try {
64
			uri = new URI(contributorURI);
65
		} catch (URISyntaxException e) {
66
			LogService logService = ServicesActivator.getDefault().getLogService();
67
			if (logService != null)
68
				logService.log(LogService.LOG_ERROR, "Invalid contributor URI: " + contributorURI); //$NON-NLS-1$
69
			return null;
70
		}
71
		if (!PLATFORM_SCHEMA.equals(uri.getScheme()))
72
			return null; // not implemented
73
		String bundleName = uri.getPath();
74
		if (bundleName.startsWith(PLUGIN_SEGMENT))
75
			bundleName = bundleName.substring(PLUGIN_SEGMENT.length());
76
		else if (bundleName.startsWith(FRAGMENT_SEGMENT))
77
			bundleName = bundleName.substring(FRAGMENT_SEGMENT.length());
78
		PackageAdmin packageAdmin = ServicesActivator.getDefault().getPackageAdmin();
79
		Bundle[] bundles = packageAdmin.getBundles(bundleName, null);
80
		if (bundles == null)
81
			return null;
82
		// Return the first bundle that is not installed or uninstalled
83
		for (int i = 0; i < bundles.length; i++) {
84
			if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
85
				return bundles[i];
86
			}
87
		}
88
		return null;
89
	}
90
91
	public String getResourceString(String value, ResourceBundle resourceBundle) {
92
		String s = value.trim();
93
		if (!s.startsWith(KEY_PREFIX, 0))
94
			return s;
95
		if (s.startsWith(KEY_DOUBLE_PREFIX, 0))
96
			return s.substring(1);
97
98
		int ix = s.indexOf(' ');
99
		String key = ix == -1 ? s : s.substring(0, ix);
100
		String dflt = ix == -1 ? s : s.substring(ix + 1);
101
102
		if (resourceBundle == null)
103
			return dflt;
104
105
		try {
106
			return resourceBundle.getString(key.substring(1));
107
		} catch (MissingResourceException e) {
108
			// this will avoid requiring a bundle access on the next lookup
109
			return dflt;
110
		}
111
	}
112
113
}
(-)src/org/eclipse/e4/core/internal/services/ServicesActivator.java (-17 / +49 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2009 IBM Corporation and others.
2
 *  Copyright (c) 2009, 2011 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.e4.core.internal.services;
11
package org.eclipse.e4.core.internal.services;
12
12
13
import org.eclipse.osgi.service.debug.DebugOptions;
13
import org.eclipse.osgi.service.localization.BundleLocalization;
14
import org.osgi.framework.BundleActivator;
14
import org.osgi.framework.BundleActivator;
15
import org.osgi.framework.BundleContext;
15
import org.osgi.framework.BundleContext;
16
import org.osgi.service.log.LogService;
17
import org.osgi.service.packageadmin.PackageAdmin;
16
import org.osgi.util.tracker.ServiceTracker;
18
import org.osgi.util.tracker.ServiceTracker;
17
19
20
//there is no replacement for PackageAdmin#getBundles()
21
@SuppressWarnings("deprecation")
18
public class ServicesActivator implements BundleActivator {
22
public class ServicesActivator implements BundleActivator {
19
23
20
	static private ServicesActivator defaultInstance;
24
	static private ServicesActivator defaultInstance;
21
	private BundleContext bundleContext;
25
	private BundleContext bundleContext;
22
	private ServiceTracker debugTracker = null;
26
	private ServiceTracker<PackageAdmin, PackageAdmin> pkgAdminTracker;
27
	private ServiceTracker<LogService, LogService> logTracker;
28
	private ServiceTracker<BundleLocalization, BundleLocalization> localizationTracker = null;
23
29
24
	public ServicesActivator() {
30
	public ServicesActivator() {
25
		defaultInstance = this;
31
		defaultInstance = this;
Lines 34-58 Link Here
34
	}
40
	}
35
41
36
	public void stop(BundleContext context) throws Exception {
42
	public void stop(BundleContext context) throws Exception {
37
		if (debugTracker != null) {
43
		if (pkgAdminTracker != null) {
38
			debugTracker.close();
44
			pkgAdminTracker.close();
39
			debugTracker = null;
45
			pkgAdminTracker = null;
46
		}
47
		if (localizationTracker != null) {
48
			localizationTracker.close();
49
			localizationTracker = null;
50
		}
51
		if (logTracker != null) {
52
			logTracker.close();
53
			logTracker = null;
40
		}
54
		}
41
		bundleContext = null;
55
		bundleContext = null;
42
	}
56
	}
43
57
44
	public boolean getBooleanDebugOption(String option, boolean defaultValue) {
58
	public PackageAdmin getPackageAdmin() {
45
		if (debugTracker == null) {
59
		if (pkgAdminTracker == null) {
46
			debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
60
			if (bundleContext == null)
47
			debugTracker.open();
61
				return null;
48
		}
62
			pkgAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(bundleContext,
49
		DebugOptions options = (DebugOptions) debugTracker.getService();
63
					PackageAdmin.class, null);
50
		if (options != null) {
64
			pkgAdminTracker.open();
51
			String value = options.getOption(option);
52
			if (value != null)
53
				return value.equalsIgnoreCase("true"); //$NON-NLS-1$
54
		}
65
		}
55
		return defaultValue;
66
		return (PackageAdmin) pkgAdminTracker.getService();
56
	}
67
	}
57
68
69
	public LogService getLogService() {
70
		if (logTracker == null) {
71
			if (bundleContext == null)
72
				return null;
73
			logTracker = new ServiceTracker<LogService, LogService>(bundleContext,
74
					LogService.class, null);
75
			logTracker.open();
76
		}
77
		return logTracker.getService();
78
	}
79
80
	public BundleLocalization getLocalizationService() {
81
		if (localizationTracker == null) {
82
			if (bundleContext == null)
83
				return null;
84
			localizationTracker = new ServiceTracker<BundleLocalization, BundleLocalization>(
85
					bundleContext, BundleLocalization.class, null);
86
			localizationTracker.open();
87
		}
88
		return localizationTracker.getService();
89
	}
58
}
90
}
(-)src/org/eclipse/e4/core/services/translation/TranslationProviderFactory.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.e4.core.services.translation;
12
13
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
14
import org.eclipse.e4.core.contexts.IEclipseContext;
15
import org.eclipse.e4.core.internal.services.BundleTranslationProvider;
16
17
/**
18
 * Factory for translation providers.
19
 */
20
final public class TranslationProviderFactory {
21
22
	private TranslationProviderFactory() {
23
		// prevents instantiation
24
	}
25
26
	/**
27
	 * Returns default bundle-based translation provider.
28
	 * 
29
	 * @param context
30
	 *            the context for the translation provider
31
	 * @return bundle-based translation provider
32
	 */
33
	static public TranslationService bundleTranslationService(IEclipseContext context) {
34
		return ContextInjectionFactory.make(BundleTranslationProvider.class, context);
35
	}
36
37
}
(-)src/org/eclipse/e4/core/services/translation/TranslationService.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.e4.core.services.translation;
12
13
import javax.inject.Inject;
14
import javax.inject.Named;
15
16
/**
17
 * Provides localization service.
18
 */
19
abstract public class TranslationService {
20
21
	/**
22
	 * The name of the context variable with locale information
23
	 */
24
	static public final String LOCALE = "org.eclipse.e4.core.locale"; //$NON-NLS-1$
25
26
	@Inject
27
	@Named(LOCALE)
28
	protected String locale;
29
30
	@Inject
31
	public TranslationService() {
32
		// placeholder
33
	}
34
35
	/**
36
	 * Translates the key from the contributor. If translation can not be found, the original key
37
	 * should be returned.
38
	 * <p>
39
	 * This method is expected to be overridden by the implementors.
40
	 * </p>
41
	 * 
42
	 * @param key
43
	 *            the key
44
	 * @param contributorURI
45
	 *            URI of the contributor
46
	 * @return localized value, or the original key if the translation can not be done
47
	 */
48
	public String translate(String key, String contributorURI) {
49
		return key;
50
	}
51
}
(-)Application.e4xmi (-1 / +1 lines)
Lines 10-16 Link Here
10
      </children>
10
      </children>
11
    </children>
11
    </children>
12
    <mainMenu xmi:id="menu:org.eclipse.ui.main.menu" elementId="menu:org.eclipse.ui.main.menu">
12
    <mainMenu xmi:id="menu:org.eclipse.ui.main.menu" elementId="menu:org.eclipse.ui.main.menu">
13
      <children xsi:type="menu:Menu" xmi:id="_SeXUD-8EEd6FC9cDb6iV7g" elementId="_SeXUD-8EEd6FC9cDb6iV7g" label="File">
13
      <children xsi:type="menu:Menu" xmi:id="_SeXUD-8EEd6FC9cDb6iV7g" elementId="_SeXUD-8EEd6FC9cDb6iV7g" label="%fileMenu">
14
        <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"/>
14
        <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"/>
15
        <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"/>
15
        <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"/>
16
        <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"/>
16
        <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"/>
(-)build.properties (-1 / +3 lines)
Lines 10-13 Link Here
10
               css/,\
10
               css/,\
11
               splash.bmp,\
11
               splash.bmp,\
12
               plugin_customization.ini,\
12
               plugin_customization.ini,\
13
               vcards/
13
               vcards/,\
14
               plugin_ru.properties,\
15
               plugin.properties
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 24-35 Link Here
24
 org.eclipse.e4.ui.bindings;bundle-version="0.9.0",
24
 org.eclipse.e4.ui.bindings;bundle-version="0.9.0",
25
 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.0",
25
 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.0",
26
 org.eclipse.e4.ui.css.swt;bundle-version="0.9.1",
26
 org.eclipse.e4.ui.css.swt;bundle-version="0.9.1",
27
 org.eclipse.e4.ui.di;bundle-version="0.9.0"
27
 org.eclipse.e4.ui.di;bundle-version="0.9.0",
28
 org.eclipse.e4.core.services;bundle-version="0.9.1"
28
Bundle-ActivationPolicy: lazy
29
Bundle-ActivationPolicy: lazy
29
Bundle-Vendor: Eclipse.org
30
Bundle-Vendor: Eclipse.org
30
Import-Package: javax.annotation;version="1.0.0",
31
Import-Package: javax.annotation;version="1.0.0",
31
 javax.inject;version="1.0.0"
32
 javax.inject;version="1.0.0"
32
Bundle-Activator: org.eclipse.e4.demo.contacts.BundleActivatorImpl
33
Bundle-Activator: org.eclipse.e4.demo.contacts.BundleActivatorImpl
33
Export-Package: org.eclipse.e4.demo.contacts.model
34
Export-Package: org.eclipse.e4.demo.contacts.model
35
Bundle-Localization: plugin
34
36
35
37
(-)plugin.properties (+11 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
# 
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
fileMenu = &File
(-)plugin_ru.properties (+11 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
# 
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
fileMenu = &\u0424\u0430\u0439\u043B
(-)src/org/eclipse/e4/demo/contacts/model/internal/BinaryTranslatorProvider.java (+31 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.e4.demo.contacts.model.internal;
12
13
import org.eclipse.e4.core.services.translation.TranslationService;
14
15
public class BinaryTranslatorProvider extends TranslationService {
16
17
	@Override
18
	public String translate(String key, String contributorURI) {
19
		if (key == null)
20
			return null;
21
		char[] charArray = key.toCharArray();
22
		StringBuffer tmp = new StringBuffer();
23
		tmp.append("0x");
24
		for(int i = 0; i < charArray.length; i++) {
25
			int value = charArray[i];
26
			tmp.append(Integer.toHexString(value));
27
		}
28
		return tmp.toString();
29
	}
30
31
}
(-)src/org/eclipse/e4/demo/contacts/model/internal/ModelLifeCycleExtension.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.e4.demo.contacts.model.internal;
12
13
import javax.inject.Inject;
14
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
15
import org.eclipse.e4.core.contexts.IEclipseContext;
16
import org.eclipse.e4.core.services.translation.TranslationService;
17
import org.eclipse.e4.ui.model.application.MApplication;
18
import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals;
19
20
public class ModelLifeCycleExtension {
21
	
22
	@Inject
23
	public ModelLifeCycleExtension() {
24
		// placeholder
25
	}
26
27
	@ProcessRemovals
28
	public void overrideTranslation(MApplication application) {
29
		IEclipseContext appContext = application.getContext();
30
		BinaryTranslatorProvider translationService = ContextInjectionFactory.make(BinaryTranslatorProvider.class, appContext);
31
		appContext.set(TranslationService.class, translationService);
32
	}
33
34
}
(-)src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRenderer.java (-1 / +14 lines)
Lines 25-32 Link Here
25
import org.eclipse.e4.core.contexts.RunAndTrack;
25
import org.eclipse.e4.core.contexts.RunAndTrack;
26
import org.eclipse.e4.core.services.events.IEventBroker;
26
import org.eclipse.e4.core.services.events.IEventBroker;
27
import org.eclipse.e4.core.services.log.Logger;
27
import org.eclipse.e4.core.services.log.Logger;
28
import org.eclipse.e4.core.services.translation.TranslationService;
28
import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer;
29
import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer;
29
import org.eclipse.e4.ui.model.application.MApplication;
30
import org.eclipse.e4.ui.model.application.MApplication;
31
import org.eclipse.e4.ui.model.application.MApplicationElement;
30
import org.eclipse.e4.ui.model.application.ui.MCoreExpression;
32
import org.eclipse.e4.ui.model.application.ui.MCoreExpression;
31
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
33
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
32
import org.eclipse.e4.ui.model.application.ui.MUIElement;
34
import org.eclipse.e4.ui.model.application.ui.MUIElement;
Lines 754-760 Link Here
754
		if (text == null || text.length() == 0) {
756
		if (text == null || text.length() == 0) {
755
			return NO_LABEL;
757
			return NO_LABEL;
756
		}
758
		}
757
		return text;
759
		// XXX
760
		return translate(text, menuModel);
761
	}
762
763
	private String translate(String key, MApplicationElement element) {
764
		IEclipseContext parentContext = modelService
765
				.getContainingContext((MUIElement) element);
766
		TranslationService translation = parentContext
767
				.get(TranslationService.class);
768
		String translated = translation.translate(key,
769
				element.getContributorURI());
770
		return translated;
758
	}
771
	}
759
772
760
	private ImageDescriptor getImageDescriptor(MUILabel element) {
773
	private ImageDescriptor getImageDescriptor(MUILabel element) {
(-)src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java (+12 lines)
Lines 18-23 Link Here
18
import java.io.OutputStream;
18
import java.io.OutputStream;
19
import java.net.URL;
19
import java.net.URL;
20
import java.util.List;
20
import java.util.List;
21
import java.util.Locale;
21
import java.util.Properties;
22
import java.util.Properties;
22
import org.eclipse.core.databinding.observable.Realm;
23
import org.eclipse.core.databinding.observable.Realm;
23
import org.eclipse.core.runtime.Assert;
24
import org.eclipse.core.runtime.Assert;
Lines 35-40 Link Here
35
import org.eclipse.e4.core.services.log.ILoggerProvider;
36
import org.eclipse.e4.core.services.log.ILoggerProvider;
36
import org.eclipse.e4.core.services.log.Logger;
37
import org.eclipse.e4.core.services.log.Logger;
37
import org.eclipse.e4.core.services.statusreporter.StatusReporter;
38
import org.eclipse.e4.core.services.statusreporter.StatusReporter;
39
import org.eclipse.e4.core.services.translation.TranslationService;
40
import org.eclipse.e4.core.services.translation.TranslationProviderFactory;
38
import org.eclipse.e4.ui.internal.workbench.ActiveChildLookupFunction;
41
import org.eclipse.e4.ui.internal.workbench.ActiveChildLookupFunction;
39
import org.eclipse.e4.ui.internal.workbench.ActivePartLookupFunction;
42
import org.eclipse.e4.ui.internal.workbench.ActivePartLookupFunction;
40
import org.eclipse.e4.ui.internal.workbench.DefaultLoggerProvider;
43
import org.eclipse.e4.ui.internal.workbench.DefaultLoggerProvider;
Lines 428-433 Link Here
428
		appContext
431
		appContext
429
				.set(Logger.class.getName(), ContextInjectionFactory.make(
432
				.set(Logger.class.getName(), ContextInjectionFactory.make(
430
						WorkbenchLogger.class, appContext));
433
						WorkbenchLogger.class, appContext));
434
435
		// translation
436
		String locale = Locale.getDefault().toString();
437
		appContext.set(TranslationService.LOCALE, locale);
438
		TranslationService bundleTranslationProvider = TranslationProviderFactory
439
				.bundleTranslationService(appContext);
440
		appContext.set(TranslationService.class,
441
				bundleTranslationProvider);
442
431
		appContext.set(Adapter.class.getName(),
443
		appContext.set(Adapter.class.getName(),
432
				ContextInjectionFactory.make(EclipseAdapter.class, appContext));
444
				ContextInjectionFactory.make(EclipseAdapter.class, appContext));
433
445

Return to bug 331260