Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/EAS/String Localization"

< E4‎ | EAS
(Eclipse 3.x API)
m (Eclipse 3.x API)
 
Line 4: Line 4:
 
In Eclipse 3.x, clients use the org.eclipse.osgi.util.NLS API to populate strings with their localized content and for providing arguments to their messages.
 
In Eclipse 3.x, clients use the org.eclipse.osgi.util.NLS API to populate strings with their localized content and for providing arguments to their messages.
  
Populating the strings:
+
===Populating the strings===
 
<source lang="java">
 
<source lang="java">
 
package org.eclipse.e4.internal.core.localization;
 
package org.eclipse.e4.internal.core.localization;
Line 22: Line 22:
 
</source>
 
</source>
  
Using the strings:
+
===Using the strings===
 
<source lang="java">
 
<source lang="java">
 
text.setText(NLS.bind(Messages.Some_Message_With_Arguments, "org.eclipse.e4.core", "E4");
 
text.setText(NLS.bind(Messages.Some_Message_With_Arguments, "org.eclipse.e4.core", "E4");
 
</source>
 
</source>

Latest revision as of 10:36, 26 October 2009

String localization is an important part of any product that markets itself for an international audience and the Eclipse platform is no different. As the Eclipse platform extends itself to other avenues beyond the desktop, it must continue to ensure that NLS is present. It must be possible for contributions, dynamically contributed through a plugin.xml or in code, to be localized. See bug 226340 and bug 244468 for more information.

Eclipse 3.x API

In Eclipse 3.x, clients use the org.eclipse.osgi.util.NLS API to populate strings with their localized content and for providing arguments to their messages.

Populating the strings

package org.eclipse.e4.internal.core.localization;
 
import org.eclipse.osgi.util.NLS;
 
public class Messages extends NLS {
 
  private static final String BUNDLE_NAME = "org.eclipse.e4.internal.core.localization.messages"; //$NON-NLS-1$
 
  public static String Some_Message_With_Arguments;
 
  static {
    NLS.initializeMessages(BUNDLE_NAME, Messages.class);
  }
}

Using the strings

text.setText(NLS.bind(Messages.Some_Message_With_Arguments, "org.eclipse.e4.core", "E4");

Back to the top