Axaptapedia is now maintained by AgileCadence For more information please click here.

Label

From Axaptapedia
Jump to: navigation, search

Labels are used to localize strings in Dynamic AX. A label start with a @ followed by a module identification and a label number.

A label @SYS12 may translate to "Account/Group number" in English and to "Konto-/Gruppennummer" in German.

When you as a developer use labels you should create a new label-file so your string customizations will be translatable. And even if your customization is for one language only it is best practice to make a label because you can reuse terms within your customization.

Label files[edit]

The label strings are stored in an file with the extension ”.ald”. You will have to make one file for each language you make. The complete filename will a concatenation of “ax”, a “label module id” and “language id”. The system auto-creates two other files with the extension ".ali" and ".alc".

File name Usage
axSYSen-gb.ald Label source file (in Ansi or UTF-8)
axSYSen-gb.alc Label comments (binary, auto-created from source file)
axSYSen-gb.ali Label index (binary, auto-created from source file)

Label file content[edit]

The first 6 lines of axSYSen-gb.ald:

@SYS0 Microsoft Business Solutions Axapta 3.0 Build #1951.3460/514/OP023
@SYS1 Time transactions
@SYS2 Creating Element: %1
@SYS3 Post to a temporary account when making payment transfers?
@SYS4 First function on start date with regard to end of interval
@SYS6 Link from %1 to %02.
@SYS12 Account/Group number

The same 6 lines of axSYSde.ald:

@SYS0 Microsoft Business Solutions Axapta 3.0 Build #1951.3460/514/OP023
@SYS1 Zeitbuchungen
@SYS2 Element %1 wird erstellt
@SYS3 Bei Überweisungen auf ein temporäres Konto buchen?
@SYS4 Erste Funktion des Startdatums hinsichtlich des Intervallendes
@SYS6 Link von %1 nach %2.
@SYS12 Konto-/Gruppennummer

Label file creation[edit]

There is a wizard to create the label files from the menu: Tools\Development Tools\Wizards\Label file Wizard

Label search and editor[edit]

The form SysLabelSearch is used to search for strings and to insert the label back to a property or code. You use the the form to create new labels as well.

The keyboard shortcut from the property window: <ctrl-space>

The keyboard shortcut from the code editor: <ctrl-alt-space>

Change labels by code[edit]

This job search for labels defined in one language (en-us) which are not defined in another language (en-gb) and insert the label. There is no update of the label log.

Very handy to update a similar language!

<xpp> static void LabelUpdateMissing(Args _args) {

   SysLabel      srcLang = new SysLabel('en-us');
   SysLabel      trgLang = new SysLabel('en-gb');
   LabelModuleId module  = 'SYP';
   LabelIdNum    frLabel = 1;
   LabelIdNum    toLabel = 1000;
   LabelIdNum    labNum;
   LabelId       label;
   Counter       ins;
   ;
   setPrefix("@SYS58308");
   for (labNum = frLabel; labNum <= toLabel; labNum++)
   {
       label = srcLang.name(module, labNum);
       if (srcLang.exists(label) && srcLang.extractString(label))
       {
           if (!trgLang.exists(label) || !trgLang.extractString(label))
           {
               info(strFmt("@SYS76766", label, srcLang.extractString(label)));
               ins += trgLang.modify(label, srcLang.extractString(label), srcLang.extractComment(label));
           }
       }
   }
   info(strFmt("@SYS86860", ins));

} </xpp>