TranslateFixed
With this function you can use the ResourceBundle defined in your i-net Clear Reports configuration with "LanguageResource" which allows you to create multi language reports. Usually i-net Clear Reports will only replace the defined keys (in the language property files) inside text elements. With this function you're now able to translate strings inside formulas as well. If no ResourceBundle can be found for the requested language the default language of the system i-net Clear Reports is running on will be used. If no ResourceBundle can be found the original string passed to this function will be returned.
After translation, if an array is given, the placeholders in the translated string, if any, are replaced one by one by the strings in the array given. The placeholders need to be of the form "{0}", "{1}", that is, 0-based. If there are more placeholders than strings given, the extra placeholders will remain in the string. If there are more values than placeholders, the extra values are ignored.
Usage:
TranslateFixed( String, String ) TranslateFixed( String, String, parameters String Array )
Parameters:
String | This is the locale which should be used to translate the key. |
---|---|
String | This is the key of the translated text defined in the language properties files. |
String Array (optional) | These are the values to replace the placeholders in the string to be translated. |
Returns:
String
Examples:
Example 1: Translate static string
-
The value "mypackage.MyLanguageResources" is defined for the property "LanguageResource" in the i-net Clear Reports configuration.
-
The files "MyLanguageResources.properties" (containing the key-value-pair "user_name=User name") and "MyLanguageResources_de.properties" (containing "user_name=Benutzername") has been created.
-
If these two files has been added to the classpath of i-net Clear Reports (using a jar file containing them is the best way) including the package path "mypackage", the formula TranslateFixed("en", "user_name") would return "User name" and TranslateFixed("de", "user_name") would return "Benutzername".
Example 2: Translate string with parameter (placeholder)
-
The value "mypackage.MyLanguageResources" is defined for the property "LanguageResource" in the i-net Clear Reports configuration.
-
The files "MyLanguageResources.properties" (containing the key-value-pair "user_name=User name is {0}") and "MyLanguageResources_de.properties" (containing "user_name=Benutzername lautet {0}") has been created.
-
If these two files has been added to the classpath of i-net Clear Reports (using a jar file containing them is the best way) including the package path "mypackage", the formula array name := ['Smith'];
TranslateFixed("en", "user_name", name); would return "User name is Smith" and array name := ['Smith'];
TranslateFixed("de", "user_name", name); would return "Benutzername lautet Smith".