- Description
- How to use it
- 1. Add a SwatTranslatable to your screen
- 2. Configure the TranslationDialog
- 3. Create a menu function to change the data language
- 4. ABL Helper classes for data & text translation:
Description
The DataTranslation Feature is used for translating the data itself, but not the UI. Technically it is using B1 database tables to save the translation including language and SelfHdl of the translated value.
How to use it
1. Add a SwatTranslatable to your screen
- The object to use the DataTranslation is called
SwatTranslatable
. This behaves like a normalDataField
but got a world-icon next to the input to open a translation dialog - This can be added to any form, which displays data. You have to specify the following attributes:
Name
: Name it like the field in you DB table which you want to translateFieldName
: Name it like the field in you DB table which you want to translate- Keep in mind that the default value of the field will be always the same and not translated
2. Configure the TranslationDialog
- The TranslationDialog, which is opened from a
SwatTranslatable
include an input field for every language you configured. Here you can enter you’re translations - To add more languages, you can go to
Grunddaten
→Lang
→ Add here a new language
3. Create a menu function to change the data language
- To change the data language, you’ll have to create a new menu function for an existing
Toolbar
- Create a new
Menu Function
Function Name
: Choose a proper name, e.g.DataTranslation
Function Type
: UseAkioma.Swat.Studio.Menu.DynCombo
Function Code
: Choose a proper code, e.g.DataTranslation
- Click
Ok
and choose the following attributes in the next screen Action Type
: ChooseRUN
Action Target
: ChooseTABLEIO
Action Parameter
: Insert$changeDataLanguage( self.getValue('DataLanguage') )
Action Options
: Insertwidth=150=int
Events
→Create Event
: Insert$getTextLang( oSelf );
- Create a new
Menu structure
- Create a new menu structure in any already existing toolbar
Label
: Choose a proper nameCode
: Choose a proper codeRelated Function
: Choose your earlier created function, in this caseDataTranslation
- For that add a new DataField to the desired form or grid
- Use the following attributes:
name
:dataTran
ObjectMasterName
: Use hereTran.
+ the field name of the to translated field, e.g. if you want to see the translation for the fieldSelfDesc
, useTran.SelfDesc
hereTableName
:Tran
3.1 Add a translation field to a grid
A possible use case to show the translated value is to add a second field to a grid or form, to additional show the translated value in the choosen language of the user
4. ABL Helper classes for data & text translation:
For texts: class TextHelper
- TextHelper:assignText(): Used to store translated texts. Parameters:
- pcParentHdl: Hdl of the record to which you want to store the text
- pcTypeHdl: Hdl of the Type of text
- pcLangHdl: Hdl of the translated language
- pcText: The text itself
- TextHelper:getTextFormatted(): Used to get translated texts. Parameters:
- pcParentHdl: Hdl of the record to which you want to store the text
- pcTypeHdl: Hdl of the Type of text
- pcLangHdl: Hdl of the translated language
For data translation: Class TranslationHelper
- TranslationHelper:AssignDataTranslation()
- pcRefHdl: Hdl of the record to which you want to store the text
- pcTypeHdl: Hdl of the Type of text
- pcLangHdl: Hdl of the translated language
- pcValue: The text itself
- TranslationHelper:GetDataTranslation(): Used to read stored data translations. Paramters:
- pcRefHdl: Hdl of the record to which you want to store the text
- pcTypeHdl: Hdl of the Type of text
- pcLangHdl: Hdl of the translated language
- pcOptions: Just leave blank (””)
- pcValue: Just leave blank (””)
How to find the Hdl of type and language:
- TypHdl: The types of the texts could be found here: Content Types -> Everything what starts with txt* (use the DevTools to figure out the SelfHdl)
- LangHdl: The languages can be found here: Grunddaten -> Lang (use the DevTools to figure out the SelfHdl)
Back to Documentation
Back to Home Page