Managing Multilanguage Development

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 13 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Managing Multilanguage Development in Dynamics 365 Business Central

Introduction: Why Multilanguage Matters in Business Central

In the modern global economy, businesses rarely operate within the confines of a single language or a single geographic region. Dynamics 365 Business Central is designed to scale across borders, allowing companies to manage subsidiaries, vendors, and customers in multiple countries simultaneously. As a developer, the ability to build extensions that support these diverse environments is not just a technical skill; it is a fundamental requirement for any professional solution. If your application only speaks one language, you are artificially limiting the market reach of your client and failing to account for the reality of international trade.

Managing multilanguage development in Business Central involves more than just translating labels on a page. It requires a disciplined approach to how you define captions, how you store translated strings, and how you handle data that may need to be localized. When you build an extension, you must ensure that every user—whether they are sitting in an office in Tokyo, Berlin, or New York—sees the application in their preferred language without the need for custom code for every region. This lesson will guide you through the architecture, implementation, and maintenance of multilanguage extensions, ensuring your code remains clean, maintainable, and globally ready.

Not read yet

Understanding the Multilanguage Architecture

At its core, Business Central handles languages through the use of XLIFF (XML Localization Interchange File Format) files. When you define an object in AL (Application Language), such as a table, page, or report, you assign captions to fields, actions, and labels. Instead of hardcoding these strings directly into the AL files, the platform encourages the use of translation files that separate the logic from the presentation layer. This decoupling is essential because it allows translators to work on content without needing access to your source code or the ability to compile the AL project.

When a user logs into Business Central, the system detects their Language ID (LCID). It then looks for the corresponding translation in the installed language packs or your custom extension's translation files. If a translation exists for that specific string, the system displays it; if not, it falls back to the default language defined in your extension's manifest. Understanding this hierarchy is the first step toward mastering global development, as it helps you predict how the system will behave when a specific translation is missing or incorrectly formatted.

Callout: The XLIFF Standard XLIFF is an industry-standard XML format used to store localizable data. By using this standard, Business Central ensures that your translation files can be opened and edited by almost any professional translation software (CAT tools). This means you do not need to build custom tools to manage translations; you can simply hand off the XLIFF files to a professional translation agency, and they can return them in a format that your AL project will accept without modification.

Not read yet

Step-by-Step: Setting Up Multilanguage Support

To begin supporting multiple languages in your Business Central extension, you must configure your project to generate the necessary files. This process is straightforward but requires strict attention to detail in your app.json file and your object definitions.

1. Configuring the Manifest

First, you need to ensure your app.json file is prepared to handle translations. While the system handles basic translations automatically, you should define your default language to ensure the system knows what to fall back on if a translation is missing.

{
  "name": "MyGlobalApp",
  "publisher": "MyCompany",
  "version": "1.0.0.0",
  "id": "guid-here",
  "brief": "A global business solution",
  "description": "This app supports multiple languages.",
  "runtime": "12.0",
  "features": [],
  "dependencies": [],
  "showMyCode": true
}

2. Enabling Translation Generation

To generate the translation files, you must add a setting to your .vscode/settings.json file. This tells the AL compiler to create an XLIFF file every time you build your project.

{
  "al.enableTranslationFiles": true
}

Once this is enabled, the next time you compile your project (using Ctrl+Shift+B), the compiler will scan your code for all Caption and Label properties. It will then generate a file inside the Translations folder in your project root, usually named [YourAppName].g.xlf. This file serves as your "source of truth" for all translatable content.

3. Creating Specific Language Files

The generated .g.xlf file is a template. You should not edit this file directly. Instead, you create a copy of it and rename it according to the language you wish to support (e.g., MyGlobalApp.en-US.xlf or MyGlobalApp.de-DE.xlf). Inside these specific files, you will provide the translation for each string.

Not read yet

Implementing Captions and Labels in AL Code

When writing AL code, you must be diligent about using the Caption property instead of just displaying text. If you hardcode a string into a message or a notification, it will be very difficult to translate later.

Best Practices for Captions

Always use the Caption property for fields, table headers, and page titles. For messages and labels that appear in code, use the Label object. Labels are a powerful feature in AL because they allow you to define a string once and reuse it across multiple objects, while also providing a "Comment" field that helps translators understand the context of the text.

Example of a Label object:

label(OrderProcessedMsg)
{
    Caption = 'The order has been processed successfully.';
    Comment = 'This is shown to the user after clicking the Post button.';
}

procedure MyProcedure()
begin
    Message(OrderProcessedMsg);
end;

By defining the label this way, the compiler extracts the string into your XLIFF file. The Comment field is included in the XLIFF file, which is incredibly helpful for human translators who might otherwise struggle to understand the context of a short, ambiguous phrase like "Post."

Tip: Context is King Translators often fail because they don't know where a piece of text appears. Always fill out the Comment property for your labels. If a string is "Order," does it mean "to place an order" (verb) or "a purchase document" (noun)? Providing that context in the Comment property ensures the translation is accurate the first time.

Not read yet

Handling Data Translation

While UI elements (captions, labels, actions) are easy to translate via XLIFF files, translating the data stored in your tables is a different challenge. If you have a table that stores "Product Categories," and you want those categories to appear in different languages, XLIFF files will not work because the data is stored in the database, not defined in your code.

For data-driven translations, you have two primary options:

  1. Multilanguage Tables: Create a separate table that stores the translation for a specific record. For example, a Category table and a Category Translation table. The translation table would have fields for Category Code, Language ID, and Description.
  2. The "Text" Data Type: Use the Text data type for fields that require translation, but be aware that this can lead to performance issues if not handled carefully.

For most business scenarios, the separate translation table is the industry standard. It keeps your primary table clean and allows you to easily add new languages without altering the structure of your core data.

Not read yet

The XLIFF Workflow: A Practical Example

Let’s walk through a scenario where you have created a new page in Business Central and want to add support for German (de-DE).

  1. Develop: You create a page with a field: field(1; "Item Name"; Rec."Item Name") { Caption = 'Item Name'; }.
  2. Generate: You run the build task. The compiler creates MyGlobalApp.g.xlf.
  3. Copy: You copy the content of the .g.xlf file into a new file named MyGlobalApp.de-DE.xlf.
  4. Translate: You open the de-DE.xlf file and find the <target> tag for the "Item Name" entry. You change it:
    <trans-unit id="Table 12345 - Field 1 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
        <source>Item Name</source>
        <target>Artikelname</target>
        <note from="Developer" annotates="general" priority="2">The name of the item.</note>
    </trans-unit>
    
  5. Build: When you build the project again, the compiler now sees the de-DE.xlf file and includes it in the final app package. When a user with a German locale logs in, Business Central automatically maps the "Item Name" caption to "Artikelname."

Warning: Never Edit the .g.xlf File The .g.xlf file is generated by the compiler every time you build. Any changes you make to this file will be overwritten the next time you save your code or run a build. Always treat the .g.xlf as a read-only template and perform your translations in separate, language-specific files.

Not read yet

Best Practices for Multilanguage Development

To keep your projects manageable, follow these established industry practices:

  • Consistent Naming: Use consistent IDs for your labels. If you rename a label in your code, the compiler will see it as a "new" string and remove the translation for the "old" string, forcing you to re-translate it.
  • Use Professional Translation Tools: As your project grows, manually editing XML files becomes error-prone. Use dedicated XLIFF editors or CAT (Computer-Assisted Translation) tools. These tools manage the XML structure for you and provide features like translation memory, which remembers how you translated a specific phrase in the past.
  • Limit Hardcoding: Never use hardcoded strings in code, even for small messages. If you write Error('Invalid date'); in your code, that string will never appear in your XLIFF file, and it will be impossible to translate without changing the source code. Always use a Label object.
  • Test with Multiple Locales: Don't just rely on the developer environment. Use the "Language" setting in your Business Central user profile to switch between languages and verify that your translations are appearing correctly in the UI.
  • Handle Pluralization Carefully: Business Central's native translation support handles basic strings well, but it struggles with complex pluralization rules (e.g., "1 item" vs. "2 items"). In these cases, it is often better to use a generic string or handle the logic in code using a function that returns the appropriate string based on the count.

Not read yet

Common Pitfalls and How to Avoid Them

Even experienced developers fall into common traps when dealing with multilanguage support. Recognizing these early will save you hours of debugging.

The "Missing Translation" Trap

The most common mistake is forgetting to update your translation files after adding new fields or labels. If you add a field but don't re-run the build process or don't update your .xlf files, the user will see the default language (or a blank string) instead of the translated one.

  • Solution: Integrate translation generation into your CI/CD pipeline. Ensure that your automated build process fails if the translation files are incomplete or if new, untranslated strings are detected.

The "Over-Translation" Trap

Some developers try to translate everything, including error messages that are meant for internal system logging or technical debugging.

  • Solution: Only translate strings that are visible to the end-user. Technical error messages that are meant for developers should remain in the default language, as they are often searched for in forums or documentation.

The "Context Mismatch" Trap

Translating a word like "Account" without knowing if it refers to a "General Ledger Account" or a "Customer Account" will lead to incorrect translations in languages where these words have distinct meanings.

  • Solution: Always use the Comment property in your Label objects to provide context. If you are using a professional translation agency, provide them with a document that explains the functional areas of your application.

Not read yet

Comparison Table: Captions vs. Labels

Feature Caption Property Label Object
Usage Fields, Actions, Pages, Tables Messages, Notifications, Reports
Reusability Limited to the specific object Highly reusable across the app
Context Limited High (includes Comment field)
Maintenance Easy to update in source Easy to update via XLIFF

Advanced Techniques: Dynamic Translations

In some advanced scenarios, you may need to display a message that includes data from the database, such as: "The document [No.] has been posted."

If you try to translate this as a single string, you will run into issues because the order of words changes between languages. For example, the placeholder [No.] might need to be at the beginning of the sentence in one language and at the end in another.

The correct approach is to use placeholders in your labels:

label(PostedMsg)
{
    Caption = 'The document %1 has been posted.';
    Comment = '%1 is the document number.';
}

// Usage in code
Message(PostedMsg, DocumentNo);

By using the %1 placeholder, you allow the translator to move the placeholder to the correct position in the sentence for their specific language. This is a critical technique for high-quality, professional localization.

Not read yet

Managing Translations for Large Projects

When working on a large extension with hundreds of labels, the XLIFF files can become massive and difficult to manage. To keep your workflow efficient, consider the following strategies:

  1. Modularization: Break your extension into smaller, functional modules. Each module can have its own translation files, which makes it easier to track changes and manage translations for specific features.
  2. Translation Memory: If you are working with an agency, ensure they are using Translation Memory (TM). This allows them to reuse translations from previous versions of your app, ensuring consistency and reducing the cost of translation for new versions.
  3. Versioning: Just like your AL code, your translation files should be version-controlled in Git. This allows you to track exactly what was changed in a translation file and why.

Localization vs. Translation

It is important to distinguish between translation and localization. Translation is simply converting the text from one language to another. Localization involves adapting the entire application to the cultural and functional requirements of a specific region.

For example, in the United States, dates are typically formatted as MM/DD/YYYY, while in most of Europe, they are formatted as DD/MM/YYYY. Additionally, address formats, tax calculation methods, and legal requirements vary significantly by country. While Business Central handles much of this through its core localization (the "Country" versions of Business Central), your extension must respect these settings.

When developing your extension, avoid hardcoding formats. Use the system's built-in formatting functions (like Format(Date, 0, '<Day,2>/<Month,2>/<Year4>')) to ensure that your UI respects the user's regional settings. If you ignore these regional differences, your app might be "translated," but it will feel foreign and difficult to use for local users.

Callout: Localization is More Than Language Never assume that language is the only barrier to global adoption. Different regions have different ways of doing business. A "Post" action might be called "Register" in some regions, or a "Customer" might be referred to as a "Client." Always consult with local partners or users to ensure your terminology aligns with local business practices.

Not read yet

Troubleshooting Common Translation Issues

If you find that your translations are not appearing in the client, follow this checklist:

  • Check the Language ID: Ensure the language code in your .xlf file matches the Language ID in the user's Business Central profile. If you have a file named MyGlobalApp.de-DE.xlf but the user is set to de-AT (Austrian German), the system will not automatically fall back to the German (Germany) file unless you have specifically configured it to do so or provided a generic de file.
  • Compile and Deploy: Did you re-publish your app after updating the XLIFF files? The translation files are part of the app package; they are not loaded dynamically from the file system on the server. You must deploy the updated app package to the Business Central environment.
  • Check for Syntax Errors: An error in the XML structure of your XLIFF file can cause the entire translation file to be ignored by the compiler. Use an XML validator if you are unsure about the structure of your file.
  • Verify the translate attribute: Ensure that the translate attribute in the <trans-unit> tag is set to yes. If it is set to no, the platform will ignore that string during the translation process.

Not read yet

Frequently Asked Questions (FAQ)

Q: Can I use machine translation for my XLIFF files? A: Yes, you can use automated tools to pre-translate your XLIFF files. However, always have a native speaker review the translations. Machine translation often misses the context of business software and can produce confusing or unprofessional results.

Q: What happens if a user sets their language to one I don't support? A: Business Central will default to the primary language defined in your app's manifest. If that is also not available, it will fall back to the language of the base application.

Q: How do I handle translations for reports? A: Reports are handled similarly to pages. Use the Caption property for labels and headers in the report layout. If you are using Word layouts, the captions are automatically passed to the Word document, where they can be translated.

Q: Should I put all my translations in one giant XLIFF file? A: No, keep them organized by object or feature. This makes it much easier to find and update specific strings when requirements change.

Q: How do I test translations without installing the app on a production server? A: Always use a sandbox environment. Create a user with a specific locale, log in, and verify that all your custom fields and actions appear in the correct language.

Not read yet

Key Takeaways for Global Development

  1. Decoupling is Essential: Always separate your strings from your code by using Caption and Label objects. This allows for clean, maintainable, and localizable applications.
  2. XLIFF is the Standard: Embrace the XLIFF format. It is the language of professional translation and ensures that your app can be localized by any professional service without requiring access to your source code.
  3. Context is Everything: Use the Comment property in your Label objects to provide context to translators. A well-commented label is the difference between a high-quality translation and a confusing one.
  4. Placeholders for Dynamic Data: Never construct sentences by concatenating strings. Use placeholders (%1, %2) to allow for correct grammar and word order in different languages.
  5. Test, Test, Test: Language support is a feature that must be verified. Always test your app in different locales within a sandbox environment to ensure that translations, date formats, and regional settings are correct.
  6. Think Beyond Translation: Remember that localization includes regional formatting, address structures, and local business terminology. A truly global app respects these cultural differences.
  7. Automate the Workflow: Integrate the generation and validation of translation files into your build pipeline. This prevents "translation debt," where your app falls behind in its support for new features.

By following these principles, you will be able to build Dynamics 365 Business Central extensions that are truly global, providing a consistent and professional experience for users in any country. Multilanguage development is a journey of continuous improvement, and by building a robust framework today, you ensure your extensions are ready for the global market of tomorrow.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.