SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Add Localization to Luigi UI5 Micro-Frontend

Enable your micro-frontend to be displayed in multiple languages using the Luigi localization features.

Overview

🎓 beginner ⏱ 5 min. User InterfaceBeginnerJavascript

You will learn

  • ✔How to add localization to your UI5 micro-frontend
Johannes Doberer J Johannes Doberer November 17, 2026
Created on December 10, 2024
Contributors

More from Johannes Doberer

See all 7 tutorials by Johannes Doberer →

Prerequisites

Steps

Intro

In this tutorial, you will add German localization to the UI5 micro-frontend by reading the current language from the Luigi Client and providing translated content for the “Order History” view.

Step 1 Update current language with Luigi Client
—

In this step, you will add a function to get the current language from Luigi Client and then update it, so that the language of the UI5 micro-frontend can be changed accordingly.

  1. Open the ui5-mf/webapp/controller/Main.controller.js file and replace its content with the code below:
JavaScript
sap.ui.define([
    "luigi/ui5/controller/BaseController",
    "sap/ui/model/json/JSONModel",
    "sap/base/i18n/Localization"
], function (Controller, JSONModel, Localization) {
    "use strict";

    return Controller.extend("luigi.ui5.controller.Main", {
        onInit: function () {
            const oModel = new JSONModel();

            oModel.loadData(sap.ui.require.toUrl("luigi/ui5/model/products.json"));
            this.getView().setModel(oModel);

            const updateCurrentLanguage = () => {
                const currentLanguage = LuigiClient.uxManager().getCurrentLocale();
                Localization.setLanguage(currentLanguage || "en-US");
            };
            this._initListener = LuigiClient.addInitListener(updateCurrentLanguage);
            this._contextUpdateListener = LuigiClient.addContextUpdateListener(updateCurrentLanguage);
        },

        onExit: function () {
            LuigiClient.removeInitListener(this._initListener);
            LuigiClient.removeContextUpdateListener(this._contextUpdateListener);
        },

        onListItemPress: async function (oEvent) {
            const id = oEvent.getSource().getBindingContext().getProperty("id");
            // Works with both synchronous and asynchronous ResourceModels.
            const bundle = await this.getView().getModel("i18n").getResourceBundle();
            const title = bundle.getText("ModalText");

            LuigiClient.linkManager().openAsModal('/home/products/' + id, { title: title, size: 'm' });
        }
    });
});
Step 2 Add files with multi-language content
+
Step 3 Add default language to index.html
+
Step 4 Provide translation in UI5
+
Step 5 Run completed app
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 6
1. Update current language with Luigi Client 2. Add files with multi-language content 3. Add default language to index.html 4. Provide translation in UI5 5. Run completed app 6. Tutorial navigation