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

DSDP/TML/Creating TmL Devices/I18N Resources class

// Package declaration. Usually the same package of the device.
package org.eclipse.tml.device.sampleDevice;
 
// Import the NLS class, as this class extends it.
import org.eclipse.osgi.util.NLS;
 
/**
 * Resources for externalized Strings of the TmL Emulator Core.
 */
public class SampleDeviceResources extends NLS {
 
	// The bundle name must be defined. It identifies this pool of messages.
	private static String BUNDLE_NAME = "org.eclipse.tml.device.sampledevice.SampleDeviceResources";
 
	// The list of messages belonging to this resource class.
	public static String TML_Device_Plugin_Name;
	public static String TML_Error;
	public static String TML_Resource_Not_Available;
 
	// Mandatory initialization block.
	static {
		NLS.initializeMessages(BUNDLE_NAME, SampleDeviceResources.class);
	}
 
}

Understanding the Resources Class

  • It is recommended that this class be placed on the same package of the device it is intended to be used with so it can be easily referred to. However, it is not mandatory.
  • You have to import the NLS class, as the resources class extends this class.
  • You have to devine the BUNDLE_NAME string as exemplified here. It must be initialized with the full path of this class.
  • The messages you want to internationalize are represented by the uninitialized public static Strings. The example given contains three constants: TML_Device_Plugin_Name, TML_Error, TML_Resource_Not_Available.
  • It must contain the static block of code as exemplified here.

Back to the top