Applying Multiple Languages

You can load and apply language-specific strings for use within the application by accessing a StringResource you created within your project or data in a remote location.

StringResource

StringResource is data consisting of keys and a language column. When you specify a key within the page, the string corresponding to the key and language can be loaded and applied.

Create a new StringResource

You can select StringResource within the Resource Explorer tab and create a new StringResource item.


Item

Description

1

Name, Location

Only one StringResource can be created in a project.

The name and path of the file created will be set as default values and cannot be modified.

2

Web URL

Select whether to receive data from a remote resource and create StringResource. When selecting an item, you must set a URL to receive the resource file.

For data types, see Remote StringResource Data Types

3

System Locale

The language column set in the system locale is additionally created.

For example, if the system locale is set to Japanese, an additional Japanese (ja) language column is created.

4

Note

This is the default setting when StringResource is created.

- The English(en) language column is created by default.

- Change the value of the environment's useringresource property to true.

The editing window is opened once the StringResource is created. If you have set up additional system locale settings, you can check whether the default (en) column and system locale (ja) column have been added.

If the StringResource is created by receiving resource from a web URL, you can check the added status of the columns and data set in the resource.

If the SDK version was changed for a project created on a previous version, the TypeDefinition will not have the StringResource information.

In this case, create the StringResource information by selecting [File > New > StringResource].

Adding and Deleting the Locale (Language Column)

Click the [Add Locale] icon on the toolbar to open the window where you can select a language to add. Select a language and click the [OK] button to add the column for the selected language.

You can delete language columns that are no longer used. Click the [Delete Locale] icon on the toolbar to see a list of currently set language columns and select the language to delete. English (EN) cannot be deleted because it is the default language.

Adding and Deleting Data

Click the [Add Key] icon on the toolbar to add an empty row. Edit the key value in the added row and enter the appropriate value in each language column.

To delete data, select the key item to delete and click the [Delete Key] icon on the toolbar.

Making Modifications in the Data Source

StringResource data are stored in JSON format. You can check the data you created by selecting the Source tab. You can also modify the value after modifying the data according to the designated format outside.

Overwriting with external StringResource data

When Overwrite data is selected, all existing data is deleted and overwritten with new data.

Import (overwrite)

When importing a StringResource from an external source or creating a StringResource and then overwriting it with other data, select the StringResource item in Resource Explorer and select [Import (overwrite)] from the context menu.

Resource files can be selected from remote files or downloaded files.


Item

Description

1

Web URL

Set the URL where the resource file is located.

2

File

Select the resource file.

pull

When creating a StringResource file with a remote resource file or specify a Web URL when importing (overwrite), you can overwrite the data by selecting the [pull] menu.

In Resource Explorer, select the generated stringresource.xstring file entry and select [pull] from the context menu.

There is no need to specify the resource file URL because the previously entered URL information is used.

Applying Multiple Languages

Let's examine how to reflect the StringResource data that have been created as a component property value.

Reflecting Selected Key Value in Components in the StringResource Pane

Select the menu [View > StringResource] item to display the StringResource window. Select the key item you want to apply, drag and drop it onto the component, and the string corresponding to the selected key will be set as the default multilingual property value of the component.

The default multilingual property for each component are shown below.

Default Multilingual Property

Target Component

text

Button, CheckBox, Div, FileDownload, GroupBox, ImageViewer, PopupDiv, ProgressBar, Sketch, Static, TabpageControl, View

tooltiptext

Calendar, CheckBoxSet, Combo, DateRangePicker, Edit, ListBox, MaskEdit, Menu, MultiCombo, Panel, PopupDateRangePicker, PopupMenu, Radio, Spin, Tab, TextArea

nodatatext

Grid, ListView

titletext

ChildFrame, Form, FrameSet, HFrameSet, MainFrame, TileFrameSet, VFrameSet

buttontext

FileUpload

labeltext

DateField, MultiLineTextField, TextField

For the Button component, the default multilingual property is text. When you drag and drop a key value in the StringResource pane, it will be applied to the text property value.

Changing the Language Applied to the Page

Click the button in the top right corner of the StringResource window to display a list of languages you can set.

When you select a language to apply to the page, the StringResource window, as well as the property values applied to the page, will display the changes.

Reflecting the Key Value in Components in the Properties Pane

After selecting a component, select [StringResource] on the toolbar of the Properties pane to display a list of properties to which multiple languages an be applied. Among the Component properties, the properties where you can set text will be displayed.

Click the button on the right side of the Properties pane to display a list of keys you have added to the StringResource. When you select a key value, the selected value will be reflected as a property value for the Component.

If there is no property value that has been set, the key value will be loaded, and if there is a property value that has been set, the key value will be checked and if there is no value corresponding to the key value, the existing property value will be set.

TEXT function

To apply multiple languages to a component property value, you can use the TEXT function to apply StringResource values. The TEXT function is applied in two forms as shown below:

In the following case, the string “TEST” is displayed because there is no language column value corresponding to “btn_0001”. If there is no column value, it is displayed as [Undefined].

Importing the Key Value with a Script

getStringResourceValue method

This is a method of importing the value set in a StringResource.

For example, the value of the text property of a Button component can be set as follows:

this.Button00.text = nexacro.getStringResourceValue("btn_0001");
this.Static00.text = nexacro.getStringResourceValue("msg_0001")
	+" 24.0.0.100 "
	+nexacro.getStringResourceValue("msg_0002");

Importing Data from a Remotely Located StringResource

Remote StringResource Data Types

This is the data type needed when creating a new StringResource using a remote resource or calling the nexacro.loadStringResource method.

The returned data should be formatted as shown below:

{
	"[Locale Code_1]":	{
		"[Key_1]" : "[Value_1]",
		"[Key_2]" : "[Value_2]"
	},
	"[Locale Code_2]":	{
		"[Key_1]" : "[Value_1]",
		"[Key_2]" : "[Value_2]"
	}
}
{
	"en":	{
    		"btn_0001" : "Example",
    		"btn_0002" : "Source",
    		"btn_0003" : "Script",
    		"msg_0001" : "The example application was tested on the Nexaro N",
    		"msg_0002" : "version."
	},
	"de":	{
    		"btn_0001" : "Beispiel",
    		"btn_0002" : "Quelle",
    		"btn_0003" : "Skript",
    		"msg_0001" : "Die Beispielanwendung wurde auf dem Nexaro N getestet",
    		"msg_0002" : "version."
	}
}

If you do not specify a value for the key, it is set to null.

{
	"en":	{
    		"btn_0001" : "Example",
    		"btn_0002" : "Source",
    		"btn_0003" : "Script",
    		"msg_0001" : "The example application was tested on the Nexaro N",
    		"msg_0002" : "version."
	},
	"de":	{
    		"btn_0001" : "Beispiel",
    		"btn_0002" : "Quelle",
    		"btn_0003" : "Skript",
    		"msg_0001" : "Die Beispielanwendung wurde auf dem Nexaro N getestet",
    		"msg_0002" : "version."
	},
	"ko" : {
    		"btn_0001" : null,
    		"btn_0002" : null,
    		"btn_0003" : null,
    		"msg_0001" : null,
    		"msg_0002" : null
	}
}

Multiple Language Application Criteria

Language

They are applied in the following order of priority:

  1. Environment locale properties

  2. User operating system locale information

If the applicable language column is not present in the StringResource, it will be applied based on English (en).

StringResource Data

It will be applied in the following order of priority:

  1. loadStringResource method

  2. If the usestringresource property value is false: stringresourceserviceurl property

    If the usestringresource property value is true: StringResource