Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
thomasnelissen
Participant
Dear Fiori Friends,

The default Fiori Launchpad does not allow a user to switch languages, without having to log off/on. It is possible to see the language you are logged in with by opening the user menu and navigating to "User Preferences". It is however not possible to change the language in this menu.



To allow users to switch languages while working in the Fiori Launchpad I added a UI-plugin to the that allows users to switch languages while working, without having to log off/on. The browser built-in navigation API is used for changing the value of URL parameter "sap-language". In my example I will allow the users to switch between English and Dutch.


UI Plugins


UI Plugins in the Fiori Launchpad allow you to add UI elements to the Fiori launchpad page. You could call them extension poins for the Fiori Launchpad. Follow this step-by-step guide to find out how you can add your own UI plugin that will allow users to switch languages.

Step 1: create a UI Plugin in the SAP Web IDE


Create a new project in the Web IDE, do not start from a template, you just need to create a new folder in the "Workspace" folder. Give the folder a meaningful name, UIPlugin for example



 

Create a new file in your new project and call it Component.js, place the following code in it, it will define an empty SAPUI5 component.
sap.ui.define([
"sap/ui/core/Component"
], function(Component) {

return Component.extend("com.example.FLPPlugins.Component", {

init: function() {

}
});
});

Let's implement the init function. In this function we will first get a reference to the sap.ushell.renderers.fiori2.Renderer object. With this object we can add UI elements to the default Fiori Launchpad, for example by adding a button to the end of the header section. Place the following code in the init function:
var renderer = sap.ushell.Container.getRenderer("fiori2");
renderer.addHeaderEndItem("sap.ushell.ui.shell.ShellHeadItem", {
id: "headerEnd",
icon: "sap-icon://world",
press: this._showLanguageMenu.bind(this)
}, true, false);

You can find all possible UI Plugins on the API reference page of the fiori2.renderer:
https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ushell.renderers.fiori2.Renderer.html

In this example an ActionSheet popover menu will show up when we click the button, we need to create 2 new functions: _createMenu and _showLanguageMenu. In these functions will create and open a new sap.m.ActionSheet element.
sap.ui.define([
"sap/ui/core/Component",
"sap/m/Button",
"sap/m/ActionSheet"
], function(Component, Button, ActionSheet) {

return Component.extend("com.example.FLPPlugins.Component", {

init: function() {
var renderer = sap.ushell.Container.getRenderer("fiori2");
renderer.addHeaderEndItem("sap.m.Button", {
id: "headerEnd",
icon: "sap-icon://world",
type: "Transparent",
press: this._showLanguageMenu.bind(this)
}, true, false);
},

_showLanguageMenu: function(oEvent) {
var oButton = oEvent.getSource();
if (!this._oMenu) {
this._oMenu = this._createMenu();
}
// var oDock = sap.ui.core.Popup.Dock;
// this._oMenu.open(false, oButton, oDock.BeginTop, oDock.BeginBottom, oButton);
this._oMenu.openBy(oButton);
},

_createMenu: function() {
var oMenu = new ActionSheet({
showCancelButton: false,
buttons: [
new Button({
text: "English",
press: function() {
window.location.search = "sap-language=EN";
}
}),
new Button({
text: "Nederlands",
press: function() {
window.location.search = "sap-language=NL";
}
})
]
});
return oMenu;
}
});
});

Step 2: Deploy the UI Plugin to your ABAP Front-End System


Right-click your project and navigate to Deploy -> Deploy to SAPUI5 ABAP Repository



Select the target system, and enter a name for the application, Z_FLP_PLUGINS for example:



Click Finish to start the deploy process.

Step 3: Activate the UI Plugin on the ABAP front-end system


Open transaction /n/UI2/FLPD_CUST to open the Fiori Launchpad Configuration tool and create a new catalog. Make sure the catalogs tab is selected in the top left corner and click the "+"-button in the bottom left corner:



Give the new catalog a meaningful name, FLP Plugins and Z_FLP_PLUGINS for example.

Now navigate to the "Target Mappings" tab, and create a new Target Mapping:



Enter the following data for your Target Mapping and Save it:

Sematic Object: Shell
Action: plugin
Application Type SAPUI5 Fiori App
Title: FLP Plugins
URL: /sap/bc/ui5_ui5/sap/Z_FLP_PLUGINS
ID: com.example.FLPPlugins


Step 4: Create a role on the ABAP front-end server


Open transaction PFCG and create a new single role, z_flp_plugins for example. Give it a meaningful description.

Save the role and go to the "Menu" tab, insert a Fiori Catalo to the menu:



Assign the role to your user and save it. Open the Fiori Launchpad an check out your Fiori Launchpad UI Plugin!

Good luck!
19 Comments
saurabh_vakil
Active Contributor
Thanks for this awesome blog! This is surely a very good to have feature since it is not available on the Fiori launchpad out-of-the-box.
thomasnelissen
Participant
0 Kudos
Thanks Saurabh!
0 Kudos
Hey Thomas,

thanks for this post. This helps me a lot, but I don't get the plugin running on my gateway. I developed it in the SAP Web-IDE. I used a UI5-App Template for being able to test the plugin in the Fiori-Launchpad Sandbox. After developing I copied the Component.js to my Plugin-Project. In the Sandbox all is up and running as expected, but on my Gateway nothing happens. No Console-Error in Chrome or sth. to see. Just nothing. Do you know any pitfalls or sth. I'm maybe missing? Did all points of your articel.

Thank you in advance 🙂
thomasnelissen
Participant
0 Kudos
Hi Sebastian,

Can you double-check if the target mapping in your Fiori catalog points to the correct component name, and has Shell-plugin as intent?
Did you include the Fiori catalog in a PFCG role on your gateway system?
Is your user assigned to that role?

If all these points are double-checked and you still can't see any difference in your launchpad, try clearing the caches on the gateway system by running SE38 reports:

/UI5/APP_INDEX_CALCULATE
/UI2/INVALIDATE_GLOBAL_CACHES
/UI2/INVALIDATE_CLIENT_CACHES

When you say I copied the Component.js to my plugin project, do you mean that you copied the entire file, of just the necessary lines of code into the empty Component.js of your plugin project?
Former Member
0 Kudos
Dear thomas.nelissen,

 

Greeting of the day.

 

I am having the same requirement and enhanced the Fiori launchpad with WEB IDE by following above steps, but i am facing one issue often icon getting hiding even used time out function still the same and visible once i refresh or once i navigate to some other apps screen.

 

Please can you help me on the same.

 

Regards,

P Premanand

 
prasanstar1986
Participant
0 Kudos
Hello ,

Fantastic . works without error . Thankyou . Solved our customer requirement .

 

Regards,

Prasanna
prasanstar1986
Participant
0 Kudos

Hello Thomas ,

 

We have a requirement to add i18n functionality for the test displaying in the drop down. Any suggestion for the same .

 

Regards,

Prasanna

jakob_straub
Explorer

Hey Prasanna,

you can add i18n functionality like this:

var oResourceModel = new sap.ui.model.resource.ResourceModel({ bundleName:  your.application.namespace.i18n.i18n” });

sap.ui.getCore().setModel(oResourceModel, "i18n");

new Button(text: text: oResourceModel.getResourceBundle().getText(“yourtextid”),

 

Greetings.

jan_nyfeler2
Explorer
0 Kudos
Hi

I just noticed that this does not work with target mapping REFERENCES. You cannot use a reference within a catalog, you have to create a new target mapping otherwise it won't work.
Former Member
0 Kudos
Hi Thomas,

I am also facing the same issue as Sebastian, i am also not able to see the button on my launchpad although i have followed all your steps and did exactly the same way you asked to.

 

Please help.

 
former_member209088
Participant
0 Kudos
So, I did this, and it "worked".  BUT I got the following Deployment Error.  Any ideas how to fix this?  We are using FES 4.0.

"Diagnosis Component IDs have to be unique, but this component ID is contained in Multiple SAPUI5 respositories. This might be caused by copying an app delivered by SAP into a new repository. The SAPUI5 application index cannot unambiously identify the component by its ID. This causes problems when starting the app at runtime (in the worst case, the app does not start at all).
Procedure: Change the component ID or delete redundant SAPUI5 repositories to eliminate the duplicates.
We recommend not to copy apps deliverd by SAP into new SAPUI5 repositories, as this always causes this problem.
If you nevertheless have to copy an app, bear in mind to adapt the ID in the descriptor of the copied app. Procedure for System Administration."

Thanks,

Tim
former_member209088
Participant
0 Kudos
Looks like we did this to ourselves.  One guy created it incorrectly in repository Z_FLP_PLUGINS, and then fixed in repository Z_FLP_LANG_PLUG.

Not sure how to delete repository Z_FLP_PLUGINS, but will figure it out -- I assume.   Sandbox.

Thanks,

Tim
former_member209088
Participant
Fixed.  Deleted first, and Reindex

 
former_member338801
Participant
0 Kudos
Hi Thomas

Thanks for such a nice blog!

Really very helpful. How can we achieve default language for any user according to there location and allow to choose required language once login?

Thank you.

RK
former_member307678
Discoverer
0 Kudos
Hi ,

If possible please post complete sample
0 Kudos

you nailed it.

Many thanks!

former_member466137
Participant
0 Kudos
Thanks a lot for this blog. Really helped.
kiran_jakkaraju
Contributor
0 Kudos
Hi Thomas

Thank you, I know this will work, but lately the window.location has been asked to avoid in SAPUI5 apps and I am trying below code which can update the translations without reloading the FLP, but it is not working.

Any ideas or issues in this code?
	var rendererPromise = this._getRenderer();			
rendererPromise.then(function (oRenderer) {


resources.i18nModel = resources.getTranslationModel(sLangu.toLowerCase());
resources.i18n = resources.i18nModel.getResourceBundle();
oRenderer.shellCtrl.getView().setModel(resources.i18nModel, "i18n");

});
RaminS
Participant

Is there any way to persist this selected language in the user settings in the backend, so the user doesn't have to change their language every time they come in FLP?

Users come into FLP using an SSO and do not get to pick their logon language. So we can't expect them to switch languages every time after reaching the launchpad.

 

The user setting can be changed in the backend using the Bapi:  'BAPI_USER_CHANGE' 

But it needs to be changed in the gateway (in case of on-premise). So we need a model, odata entityset and a function import.

Right?

Any easier way?

Labels in this area