Illustration of flags and translated labels being assembled around a large gear with a locking mechanism, with people working together, illustrating pulling translations for a control add-in.

Pull translations for Control Add-in from Business Central extension

2 min read

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.

JavaScript call to Microsoft.Dynamics.NAV.InvokeExtensibilityMethod raising the OnInitilizeAddIn event.

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.

JavaScript function InitializeAddInHtml receiving localized text parameters and building drag-and-drop upload HTML.

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

AL controladdin definition for Drag And Drop with OnInitilizeAddIn event and InitializeAddInHtml procedure.

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.

AL page usercontrol trigger OnInitilizeAddIn defining label captions and calling InitializeAddInHtml.

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:

XLF translation file showing generated label text entries such as 'Waiting for upload...'.

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.

JavaScript initializing the control add-in and invoking the OnAfterInitialize extensibility event.

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

AL controladdin Text Editor definition with event OnAfterInitialize and procedure SetButtonCaptions.

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

AL page usercontrol trigger OnAfterInitialize calling SetButtonCaptions with Add Lines and Reset labels.

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.

JavaScript function SetButtonCaptions setting innerText for pars and resetArea button elements.


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!

Related posts

Comments

    Leave a comment

    Reviewed before it appears.