From 5c53976b0d404bd07c6f50287484ec2f75621f91 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:27:12 +0100 Subject: [PATCH 1/6] Update i18n.properties Added i18n texts --- .../newwebapp/templates/uimodule/webapp/i18n/i18n.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n.properties b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n.properties index b283194..d0fce5a 100644 --- a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n.properties +++ b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n.properties @@ -1,2 +1,5 @@ pluginTitle=<%=projectname%> -pluginDescription=<%=projectname%> \ No newline at end of file +pluginDescription=<%=projectname%> +buttonText=Help for FLP page +msgMeAreaText=You pressed the button that opens a help page. +msgMeAreaTextApp=You pressed the button that opens a help for apps page. From 81d916a10f4e8e90efebe3103e52b4129ab5d930 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:27:38 +0100 Subject: [PATCH 2/6] Update i18n_en.properties --- .../templates/uimodule/webapp/i18n/i18n_en.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en.properties b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en.properties index b283194..d0fce5a 100644 --- a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en.properties +++ b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en.properties @@ -1,2 +1,5 @@ pluginTitle=<%=projectname%> -pluginDescription=<%=projectname%> \ No newline at end of file +pluginDescription=<%=projectname%> +buttonText=Help for FLP page +msgMeAreaText=You pressed the button that opens a help page. +msgMeAreaTextApp=You pressed the button that opens a help for apps page. From 3adba2050819173675f7e5ff4f1505c2f7fb7ac2 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:27:59 +0100 Subject: [PATCH 3/6] Update i18n_en_US.properties --- .../templates/uimodule/webapp/i18n/i18n_en_US.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en_US.properties b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en_US.properties index b283194..d0fce5a 100644 --- a/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en_US.properties +++ b/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en_US.properties @@ -1,2 +1,5 @@ pluginTitle=<%=projectname%> -pluginDescription=<%=projectname%> \ No newline at end of file +pluginDescription=<%=projectname%> +buttonText=Help for FLP page +msgMeAreaText=You pressed the button that opens a help page. +msgMeAreaTextApp=You pressed the button that opens a help for apps page. From fbbe05a0dce15a701589de14907bcb19934300c8 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:29:25 +0100 Subject: [PATCH 4/6] Update manifest.json add reference to i18n model --- .../newwebapp/templates/uimodule/webapp/manifest.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/manifest.json b/generators/newwebapp/templates/uimodule/webapp/manifest.json index 6602cc8..fd0ebb8 100644 --- a/generators/newwebapp/templates/uimodule/webapp/manifest.json +++ b/generators/newwebapp/templates/uimodule/webapp/manifest.json @@ -39,6 +39,14 @@ "compact": true, "cozy": false }, + "models": { + "i18n": { + "type": "sap.ui.model.resource.ResourceModel", + "settings": { + "bundleName": "<%=appId%>.i18n.i18n" + } + } + }, "dependencies": { "minUI5Version": "1.38.1", "libs": { @@ -56,4 +64,4 @@ "type": "plugin", "config": {} } -} \ No newline at end of file +} From 670914ee1966b05aa679b960f3dbf9af126291e6 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:31:38 +0100 Subject: [PATCH 5/6] Update Component.js make plugin use i18n texts for button and message toast in me area --- .../newwebapp/templates/uimodule/webapp/Component.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/Component.js b/generators/newwebapp/templates/uimodule/webapp/Component.js index e606e9b..236cc6b 100644 --- a/generators/newwebapp/templates/uimodule/webapp/Component.js +++ b/generators/newwebapp/templates/uimodule/webapp/Component.js @@ -14,6 +14,7 @@ sap.ui.define([ init: function () { var rendererPromise = this._getRenderer(); + var oResourceBundle = this.getModel("i18n").getResourceBundle(); // This is example code. Please replace with your implementation! <% if (features.includes("Add button to launchpad header")) { %> @@ -52,12 +53,13 @@ sap.ui.define([ * The first button is only visible if the Home page of SAP Fiori launchpad is open. */ rendererPromise.then(function (oRenderer) { + var _oResourceBundle = oResourceBundle; oRenderer.addActionButton("sap.m.Button", { id: "myHomeButton", icon: "sap-icon://sys-help-2", - text: "Help for FLP page", + text: oResourceBundle.getText("buttonText"), press: function () { - MessageToast.show("You pressed the button that opens a help page."); + MessageToast.show(_oResourceBundle.getText("msgMeAreaText")); } }, true, false, [sap.ushell.renderers.fiori2.RendererExtensions.LaunchpadState.Home]); @@ -67,12 +69,12 @@ sap.ui.define([ oRenderer.addActionButton("sap.m.Button", { id: "myAppButton", icon: "sap-icon://sys-help", - text: "Help for App page", + text: oResourceBundle.getText("buttonText"), press: function () { - MessageToast.show("You pressed the button that opens a help for apps page."); + MessageToast.show(_oResourceBundle.getText("msgMeAreaTextApp")); } }, true, false, [sap.ushell.renderers.fiori2.RendererExtensions.LaunchpadState.App]); - }); + }.bind(this)); <% } %> }, From 3fdb64095ebf913f7d8a07be51ee35331ed0e944 Mon Sep 17 00:00:00 2001 From: Tobias Hofmann Date: Tue, 28 Feb 2023 11:34:18 +0100 Subject: [PATCH 6/6] Update Component.js Use the local _oResourceBundle object --- generators/newwebapp/templates/uimodule/webapp/Component.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/newwebapp/templates/uimodule/webapp/Component.js b/generators/newwebapp/templates/uimodule/webapp/Component.js index 236cc6b..5da60d5 100644 --- a/generators/newwebapp/templates/uimodule/webapp/Component.js +++ b/generators/newwebapp/templates/uimodule/webapp/Component.js @@ -57,7 +57,7 @@ sap.ui.define([ oRenderer.addActionButton("sap.m.Button", { id: "myHomeButton", icon: "sap-icon://sys-help-2", - text: oResourceBundle.getText("buttonText"), + text: _oResourceBundle.getText("buttonText"), press: function () { MessageToast.show(_oResourceBundle.getText("msgMeAreaText")); } @@ -69,7 +69,7 @@ sap.ui.define([ oRenderer.addActionButton("sap.m.Button", { id: "myAppButton", icon: "sap-icon://sys-help", - text: oResourceBundle.getText("buttonText"), + text: _oResourceBundle.getText("buttonText"), press: function () { MessageToast.show(_oResourceBundle.getText("msgMeAreaTextApp")); }