When you develop
extensions, the
vSphere Web
Client can appear in different languages in different locales.
You can set information that appears in the
vSphere Web
Client, for example, the extension name, as resources that can be
translated.
You provide information that
requires translation in an
ExtensionResourceInfo
data object. You can add an
ExtensionResourceInfo
object for every locale that your extension supports. You set an array of
ExtensionResourceInfo
objects in the
resourceList property
of the
Extension instance that
defines your extension.
You provide onscreen messages
and labels to
ExtensionResourceInfo
in a key and value pairing that you add to a
KeyValue array in the
ExtensionResourceInfo
data property. You
can set the values for the
KeyValue pair directly
in the
ExtensionResourceInfo
object, or you can refer to entries in resource files that contain the message
text in different languages, according to the locale in which vSphere is
running. For simplicity, the EAM Sample Solution sets the data directly in the
KeyValue
implementation.
You provide a two-character
ISO-639 language ID for the
KeyValue
locale property, and
set the
module property to
the type of resource to which this locale applies. For example, you can set the
module value to
task,
event,
auth, or
extension, depending on whether the messages that the
resource contains relate to tasks, events, privileges, or extensions.
Prerequisites
■
|
Download the vSphere ESX Agent Manager SDK.
|
■
|
Verify that you have set up
and started the EAM Sample Solution in an application server.
|
■
|
Verify that you have opened
eam_work_folder\src\com\vmware\eam\sample\solution\Manager.java
in an editor.
|
Procedure
1 | Create an instance of
the
ExtensionResourceInfo
data object.
Manager.java
instantiates
ExtensionResourceInfo
in the implementation of
Extension.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
[...]
}
|
2 | Set the locale and
module properties for the
ExtensionResourceInfo
object.
Manager.java sets the
default locale to
en and applies this locale to the
Extension instance,
extension.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
[...]
}
|
3 | Provide the data to the
ExtensionResourceInfo
in the form of a
KeyValue array.
The
label property is a property of the
Description object,
that
Extension implements,
and defines the name of the extension as it appears in the vSphere web client.
Manager.java adds the
text
EAM Sample Solution as the value of the
label property
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
KeyValue keyValue = new KeyValue();
keyValue.setKey(EXTENSION_KEY + ".label");
keyValue.setValue("EAM Sample Solution");
[...]
}
|
4 | Call the
ExtensionResourceInfo.getData()
method to add the
KeyValue array that
contains the localization data to the
data property of the
ExtensionResourceInfo
object.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
KeyValue keyValue = new KeyValue();
keyValue.setKey(EXTENSION_KEY + ".label");
keyValue.setValue("EAM Sample Solution");
extensionResourceInfo.getData().add(keyValue);
[...]
}
|
5 | (Optional) Add another
KeyValue object to the
ExtensionResourceInfo
data property that
adds a description of the extension for a given locale.
For example, you
can add the following description to
Manager.java in a
KeyValue object named
keyValue_summary.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
KeyValue keyValue = new KeyValue();
keyValue.setKey(EXTENSION_KEY + ".label");
keyValue.setValue("EAM Sample Solution");
KeyValue keyValue_summary = new KeyValue();
keyValue_summary.setKey(EXTENSION_KEY + ".summary");
keyValue_summary.setValue("Brief description");
extensionResourceInfo.getData().add(keyValue);
extensionResourceInfo.getData().add(keyValue_summary);
[...]
}
|
6 | Call the
Extension.getResourceList()
method to pass the
ExtensionResourceInfo
object to the
Extension instance.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
KeyValue keyValue = new KeyValue();
keyValue.setKey(EXTENSION_KEY + ".label");
keyValue.setValue("EAM Sample Solution");
KeyValue keyValue_summary = new KeyValue();
keyValue_summary.setKey(EXTENSION_KEY + ".summary");
keyValue_summary.setValue("Brief description");
extensionResourceInfo.getData().add(keyValue);
extensionResourceInfo.getData().add(keyValue_summary);
extension.getResourceList().add(extensionResourceInfo);
[...]
}
|
7 | (Optional) Add more
ExtensionResourceInfo
instances to provide localized text that displays when the extension runs in
different locales.
For example, you
can add an
ExtensionResourceInfo
instance to
Manager.java to
provide a French translation of the extension name.
private Extension createExtensionObject() {
Extension extension = new Extension();
[...]
ExtensionResourceInfo extensionResourceInfo = new ExtensionResourceInfo();
extensionResourceInfo.setLocale("en");
extensionResourceInfo.setModule("extension");
KeyValue keyValue = new KeyValue();
keyValue.setKey(EXTENSION_KEY + ".label");
keyValue.setValue("EAM Sample Solution");
KeyValue keyValue_summary = new KeyValue();
keyValue_summary.setKey(EXTENSION_KEY + ".summary");
keyValue_summary.setValue("Brief description");
extensionResourceInfo.getData().add(keyValue);
extensionResourceInfo.getData().add(keyValue_summary);
ExtensionResourceInfo extensionResourceInfo_FR = new ExtensionResourceInfo();
extensionResourceInfo_FR.setLocale("fr");
extensionResourceInfo_FR.setModule("extension");
KeyValue keyValue_FR = new KeyValue();
keyValue_FR.setKey(EXTENSION_KEY + ".label");
keyValue_FR.setValue("Exemple d'une Solution EAM");
extensionResourceInfo_FR.getData().add(keyValue_FR);
extension.getResourceList().add(extensionResourceInfo);
extension.getResourceList().add(extensionResourceInfo_FR);
[...]
}
|
8 | (Optional) If you modified
Manager.java, save
your changes and rebuild and redeploy the EAM Sample Solution.
If you
changed the
label value, the
extension appears in Solutions Manager with the new name. If you added an
ExtensionResourceInfo
object for a different locale, the localized text that you added appears in
Solutions Manager when you connect the EAM Sample Solution to a
vCenter Server
instance that runs in that locale.
|
You added localizable message
resources to the extension, so that onscreen messages and labels that your
extension provides can appear in different languages in different locales.