Monday, March 8, 2010

Getting label text in different languages

Sometimes it is needed to get a label text in a language that is different from the current one. To do that the labelId2String method of the SysLabel class can be used.
Example:
SysLabel::labelId2String(literalstr('@SYS1'), 'en-us');
Gives: Time transactions
SysLabel::labelId2String(literalstr('@SYS1'), 'de');
Gives: Zeit Transaktionen

13 comments:

  1. thanks can be handy,

    Btw Do you know any way to catch the conversion of labels

    So if a label does not exist in the user language we can display it in the English language.

    ReplyDelete
  2. There is no such method to my knowledge. The problem is that it is not clear which language should be used as fallback one. You say ‘en-us’ which is reasonable, however it gives a special status to the English language which is not correct from the localizability point of view.

    ReplyDelete
  3. Well this could be a parameter, in my case English should be given a special status since it's our official group language

    I made some tests, when you do for example

    str msg = "@AAA1"

    If you use the debugger you can see immediatly that the label is converted to txt when the msg variable is instantiated

    ReplyDelete