Friday, February 26, 2010

How to get a label in a different language

The tasks seems easy enough: How the get a specific label in a different language.
(Remember my post, 'How to set the language used on a report')

Now we only need to retrieve the text for one label id, in any given language. Going through the help files of Ax, you come across this class SysLabel. It contains the labelid2String method.



Only... This does not work like that. Didn't work in Ax 4.0, doesn't work in Ax 2009. You always get the label back in the language that's been setup for the current user, no matter which language you specify in the call to this function.

Luckily, there's an easy workaround, tricking Ax: Split up your label id. Like this:


Credits: With thanx to this blog for this simple but yet very effective solution.

Edit: SysDictCoder pointed out a nicer solution in the comments, by using literalstr.



  1. How about using literalStr("@SYS87980") instead of splitting the label ID? This tells the runtime to skip the label lookup.

  2. Hi SysDictCoder,

    That works perfectly as well! And has a cleaner look.

    Thanx for the tip.

  3. How would you print SSRS report with two simultaneously language? with a slash between? ex: "Facture / Invoice"

    1. create 2 labels one in french and one in English, and they both have the value: "Facture / Invoice"