This article describes how you can create tests that can be translated to multiple languages. This contains the following topics:
For translating tests language files (*.lang) are used. These are located in the standard folder "Resources" within a Fabasoft app.test project.
Language files in Fabasoft app.test are usually saved in the "Language Files" folder of a project which is located in the "Resources" folder. Per default the "Language Files" folder contains subfolders for English and for German language files. It is advised that language files for the same language are summarized in one folder.
You can create a new language file by opening the context menu of the folder, where the language file should be created, and clicking “New” -> "Language File".
After entering a name for the file and pressing the Return key, it is opened in the editor.
A language file simply consists of key/value pairs in text format. These can be entered into the grid that is displayed in the "Editor" view. Enter the name of the parameter into the Key field and the value (the language string) into the Value field.
By that way you can create language files for different languages (e.g. German and English). Please note that keys should have the same names in the different language files.
If you view the source of a language file (switch to the "Source" tab in the bottom of the "Editor Area" view), a key/value pair has the following Syntax
key = "value"
ObjectList = "Object List"
Values in language files do not have to be escaped except wild card sequences like [*] or [?] appear in values. For escaping a character use a backslash.
Note: It is not necessary to escape quotes.
Example for Values:
"Object List" --> Object List
If you have recorded a test in a specific language (e.g. English), you can replace all language strings with the keys from a language file. Therefore, mark the test, ensure that the project explorer is focussed, open the menu “File” and select "Translate".
In the wizard that has opened you can select the language file(s) in the Language Files field by clicking the "+" button and selecting a language file. The selected language files are used in the defined order for resolving the test file.
In the Target File field you can select the file that should be created. Therefore, click the "Browse" button and select a test file (or enter a name) and click "Finish".
In the Save new values/unknown keys to field you can define a language file optionally where the keys and values that could not be specified should be saved. If you select an existing language file, you can decide that the file should not be overwritten but the new key/value pairs are added to the file. Therefore, select the Append new entries if file already exists check box.
Per default only the locations of executions and set statements are translated. But you can define additionally which properties should be translated, too.
If you have defined all necessary information, click "Next".
On the next wizard page it is displayed which keys are not set resp. which values are not represented in keys. For unresolved values a key name (which can be edited) is generated automatically. Select the check box of those keys that should be saved in the language file.
Click "Finish" to externalize the strings from the file (which means they are replaced by references to the keys in the language file).
The new test file is created with the references to the language keys from the language file(s). Existing keys stay untouched.
This is an example how the execution statements may look like after translating a file:
The language files used for translating the file are referenced at the beginning of the file (which is displayed in the "Outline" view).
You can resolve a translated file again (which means the language keys are replaced by the language strings). Therefore, select the test, sequence or use case, which should be resolved, in the "Projects" view, open the "File" menu and select "Resolve Translation".
A wizard opens where you can select the language files as well as the target test file that should be created after translating the selected file.
Click "Finish" for translating the file.
Note: If a key could not be resolved its value can be edited on the second wizard page (by clicking "Next" instead if "Finish") and the unsresolved keys can be saved in a language file (which can be defined in the Save unresolved keys to field).
By that way you can for example resolve the file to German language (the file has been recorded in English and the strings have been replaced by references to language keys by externalizing strings).
After Translation (to German)
You can also run tests in the Fabasoft app.test Player which contain language keys. Therefore, you can define the path where the language files are located when starting the Fabasoft app.test Player in the "Run" dialog. This path is needed because usually language files are referenced in test files by using the system parameter langpath. This system parameter is set to the value of the Language Files field of the "Run" dialog.
Note: You can reference language files within a test (analog to parameter tables) when starting the Fabasoft app.test Player. Therefore, you can add a language file to the test when it is opened in the Fabasoft app.test Studio by clicking the "Insert Language File" button in the "Outline" view (when the test is selected).
In the "Properties" view you can select a language file in the Filename field by clicking the "..." button.
When a file is executed that contains references to language files, the language keys in the file are resolved when running the test.
Following options are available:
If you use the Fabasoft app.test Click-Recorder for recording a test you can also translate your test (which means language strings are replaced by the references to language keys).
Therefore, you have to select the Translate check box in the Fabasoft app.test Preferences.
After starting the Fabasoft app.test Recorder you can reference language files in the "Outline" view. Therefore, select the test and click the "Insert Language File" button in the "Outline" view.
After inserting a file select the element in the "Outline" view and go to the "Properties" view. Here you can select a language file to be referenced by clicking the "..." button of the Filename field (see above).
You can load language keys into the Fabasoft app.test Recorder by selecting the translation statement (which means the reference to the language file) in the "Outline" view and clicking the "Step Into" button.
The language keys are loaded. All keys currently available are listed in the "Translation Table" tab in the "Editor Area" view.
If you now record statements in the Fabasoft app.test Click-Recorder, the language strings occuring in the location of an execution are replaced by the reference to the corresponding language key.
If a language string occurs that is not known (which means no language key exists for this string), the execution is recorded as usual. This means the language specific string(s) are not replaced in the location. If you want to save the values that have not been replaced during recording in a language file, you can translate (see chapter "How to Translate a Test”) the recorded test (and save the unknown values in a language file).
Note: In the Fabasoft app.test Click-Recorder the language strings are replaced automatically. If you record statements by using the control tree, you can select different locations (with or without replacing the language strings).
You can import all language strings from Fabasoft Folio into Fabasoft app.test (as language files).
Therefore, open the "File" menu and select "Import"
Select "Import Language Resources" and click "Next".
Now you have to enter the connection information which means where the language files should be imported from. These fields can be set:
In the Destination area you have to select where the language files should be saved as well as the name of the language files. In the Destination Folder field you select the "LanguageFiles" folder of the project where the language files should be saved. In the Name for Language Files field you enter a name for the language files. Please note that each imported language file has the same name but different languages are saved in different folders.
After defining these properties, click "Next" to continue.
On this page you can see all languages that are imported. In the square brackets the name of the folder, where the corresponding language file is saved, is displayed. You can select and deselect languages in here. By clicking "Finish" language files for the selected languages are imported into the defined Fabasoft app.test project.
You can see the progress of importing the language files below the listed languages.
As you can see the language files have been imported. Each language file has the same name (as defined before) but for each language a folder has been created.
This has the following reason: When starting the Fabasoft app.test Player (or Recorder) you have to enter the language path, where the language files are located. Then you can reference the language file by using the langpath system parameter. If you want to run the test in another language you just have to change the language path when starting the Fabasoft app.test Player, because the name of the language file remains the same.
Imported language files can be opened and edited: