A while ago I had the need to translate labels, I was creating eMail bodys while using SysMailer and wanted to use different languages for different customers.
I found the class SysLabel and tried to use it. But the problem was that this didn´t work. I allways got the string in the language that was set up under Tools/Options.
print SysLabel::labelId2String2("@SYS54971", "en-us"); |
print SysLabel::labelId2String2("@SYS54971", "en-us");
I usually have Swedish setup as language when I run Dynamics AX, and this is the result when running previous code.
Aktiveringsdatum
If there are any english readers: “Aktiveringsdatum” is the Swedish translation of “Activation date“.
I traced the code and found out that the label converts to it’s string before it´s sent into the method labelId2String2. Since the input value wasn’t a labelId anymore, the method just returned the exact string that was sent in.
I found a solution to this problem by piecing together the labelname in the call to the method. It seems that the label didn’t convert to it’s string when I did it this way.
Continue reading Get label string in different languages →