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.
Example:
info(SysLabel::labelId2String2("@SYS87980","de"));
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:
info(SysLabel::labelId2String2("@"+"SYS87980","de"));
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.
info(SysLabel::labelId2String2(literalstr("@SYS87980"),"de"));
Friday, February 26, 2010
Subscribe to:
Post Comments (Atom)
How about using literalStr("@SYS87980") instead of splitting the label ID? This tells the runtime to skip the label lookup.
ReplyDeleteHi SysDictCoder,
ReplyDeleteThat works perfectly as well! And has a cleaner look.
Thanx for the tip.
How would you print SSRS report with two simultaneously language? with a slash between? ex: "Facture / Invoice"
ReplyDeletecreate 2 labels one in french and one in English, and they both have the value: "Facture / Invoice"
Delete