Get Free Trial

How to add localization support for newly added button on the toolbar

Sohan asked on March 31, 2017

I have added new button on the toolbar

id: "fm-tab-expand",
title: toolbar.Label.expand_all,
handler: expandAllData

Now I have to add the value of this label, I dont want to provide the hardcoded value here because we will be supporting multiple languages.
So I read the localization document, which says English values comes by default, But looks like these values are there in the javascript code and not in json. Because I have not yet loaded the flex pivot with en.json.
Now I got en.json file and added expand_all key under toolbar. and initialized the pivot as below.

pivotFlex = $("#"+$scope.pivotId+"_pivotGrid").flexmonster({
global: {
localization: "loc/en.json"

But looks like Flex is looking for this key in its own file and not referring the the provided en.json while looking for the new key.
In en.json file if I change the label of any existing key for e.g. Grid to Grid1, it shows the label as Grid1 on the screen, so I am sure en.json is getting referred – but only for existing keys.
Can you please help me here ?

2 answers

Tanya Gryshko Tanya Gryshko Flexmonster March 31, 2017

Hello Sohan,
Thank you for your question. Your approach is correct but you need to override one more method – toolbar.updateLabels. Please have a look at the following example on JSFiddle demonstrating how this should be done. Please let us know if you have any questions.

Sohan April 3, 2017

That helped. Thanks Tanya !

Please login or Register to Submit Answer