Providing a localized user experience is crucial. For Business Central developers, this often means ensuring that control add-ins are translated into multiple languages. In this post, we’ll explore how to pull translations for a control add-in from a Business Central extension.


There are definitely more ways how you can accomplish, and all are basically right, but also depending on your AddIn structure and code.

Update captions on AddIn Initialize

To initialize the Add-In in JavaScript, you need to raise an AL event OnInitilizeAddIn.

Additionally, you should define a procedure in JavaScript for the initialization of the Add-In InitilizeAddInHtml. This procedure must be called to perform the initialization.

The Control Add-In file should be structured as follows:

In this file, we declare one event and one procedure. With these declarations in place, we can proceed to create a user control within the extension.

You can define the trigger declared on the Control Add-In as well call the procedure to Initialization. Firstly, trigger will be activated, and within this trigger, you can generate captions and send them back to JavaScript trough procedure.

All the captions defined in the trigger as Labels will be visible in xlf file for translation:

Update captions on after AddIn Initialize

First, call the procedure to initialize the Add-In. After the initialization is complete, declare an AL event in JavaScript that will be triggered post-initialization.

The Control Add-In file should be structured as follows:

With these declarations in place, we can proceed to create a user control within the extension.

Once the initialization is complete, the OnAfterInitialize trigger will be called from JavaScript. This trigger allows us to call a JavaScript procedure that retrieves the necessary elements and updates their inner text with translated labels.


As said before, there are many ways to accomplish this. You can at any moment call trigger from JavaScript AddIn and also JavaScript procedure from AL extension. You could play around and find the way which works best for your AddIn and extension.


Conclusion

Pulling translations for a control add-in from a Business Central extension is a straightforward process that can significantly enhance the user experience. By following the steps outlined above, you can ensure that your control add-ins are accessible to a global audience.

Feel free to leave your comments and feedback below. Happy coding!

Categorized in: