Creating Language Files for Localization of Apps
To create a language file for an app, you need to create a .properties language resource file for the language that you want to use in the app. You then add it to the list of language files in the Languages node. As an example, you can download tubular_reactor_en_US.properties from the Tubular Reactor with Jacket app (tubular_reactor), available in the COMSOL Multiphysics Application Library. The first lines of that file, for American English, look like the following:
Activation_energy = Activation energy
Are_you_sure_you_want_to_reset_all_parameters_to_their_default_values = Are you sure you want to reset all parameters to their default values?
Cancel = Cancel
Compute = Compute
Connection_security = Connection security
Conversion = Conversion
Conversion_profiles = Conversion profiles
Documentation = Documentation
Email_address = Email address
Email_report_to = Email report to
Email_settings = Email settings
Expected_computation_time = Expected computation time
From_address = From address
Heat_of_reaction = Heat of reaction
Help = Help
Home = Home
Host = Host
Information = Information
Input = Input
Input_and_description = Input and Description
Last_computation_time = Last computation time
Lte_value_gte_XY = #0 <= value <= #1
...
In a localized file, you replace the English text in the right side of each line with the translation in the language of your choice. For example, in the Tubular Reactor with Jacket app, the top key, Activation_energy:, is used as the text label for a user input in the Inputs section in the app settings. By using the key instead of plain English (Activation energy:), the translated right side in the language file for the chosen language is displayed instead. (The colon at the end is ignored; see the syntax rules below.)
Localization is performed on settings that are displayed as texts in the app, including error messages, for example, but not text that is editable by app users such as the content of text fields and table cells. Also, the contents of generated reports and text related to model features exposed by the app using Data Access, for example, are localized using the language preference setting in the COMSOL Desktop.
In a text resource file, the following syntax is used:
Parameters can be used to insert text from the key part of the resource into the value part of the resource. Parameters are indicated by X in the key and # in the value. In the key, # indicates the start of a parameter. Parameters must be at the end of the key. The # in the value indicates the parameter position in the text. In the value, a specific parameter (if more than one parameter is used) is indicated by a nonnegative digit (starting with 0) after the #. For instance, #0 indicates the first parameter of the key (typically X, then Y and Z with three parameters). An example of the use of variables is on the last line of the example above, where you also need to use #0 and #1 in the localization, at suitable locations to get a correct translation. In the app, that resource string might appear as 0 <= value <= 5, for example.
A trailing colon (:) is ignored by the resource lookup and is appended to the translated value.
Text resources that are used in apps but are not found in the language file used for app localization will be reported in the Debug Log window. Reporting of missing text resources only occurs when using the Test Application command and if the app uses localization. A missing resource is reported once per Test Application session.