question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to internationalize title and description of an adf-widget?

See original GitHub issue

Hi, i’am trying to internationalize my adf-widget title and description, but it wont work… is there a way to change title and description in a controller? or is it possible to inject the $filterProvider to translate during the configphase?

tried this:

angular.module('adf.widget.myWidget', ['adf.provider'])
  .config(function(dashboardProvider){
    function getName($filter) { var dcName = $filter('translate')('MYWIDGET.NAME'); return dcName; };
    dashboardProvider
      .widget('myWidget', {
        title: getName(),
        description: 'test',
        templateUrl: '{widgetsPath}/myWidget/src/view.html',
        controller: 'myWidgetCtrl',
        edit: {
          templateUrl: '{widgetsPath}/myWidget/src/edit.html'
        }
      });
  })

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
slc1prbcommented, Dec 9, 2016

You can use addLocale, there are only 2 languages out of the box so you will have to translate the labels yourself and pass in the translation table, see https://github.com/angular-dashboard-framework/angular-dashboard-framework/wiki/Localization

You will also have to have the title label and description before you get this far since during the config phase it won’t be running any functions. You could include it in some dynamically created values. We are using a key value pair that is generated based on the user’s language. This get loaded in the module. You can use the values that are now in scope.

var labels: any = {};

function loadConfig (config) {
    labels = confg.labels;
}

angular.module('adf.widget.myWidget', ['adf.provider'])
  .config(function(dashboardProvider){
    dashboardProvider.addLocale('custom', widgetFrameworkLabels);
    dashboardProvider
      .widget('myWidget', {
        title: labels.title,
        description: lables.description,
        templateUrl: '{widgetsPath}/myWidget/src/view.html',
        controller: 'myWidgetCtrl',
        edit: {
          templateUrl: '{widgetsPath}/myWidget/src/edit.html'
        }
      })
      .run(["dashboard", function(dashboard) {
            dashboard.setLocale("custom");
        }]);
  })
0reactions
Weestdudochnichtcommented, Jan 18, 2017

I believe the easiest was is to fork the Plugin and add some lines of Code. I change the addWidgetDialog function in the angular-dashboard-framework.js to:

` $scope.addWidgetDialog = function(){ var addScope = $scope.$new(); var widgets; if (angular.isFunction(widgetFilter)){ widgets = {}; angular.forEach(dashboard.widgets, function(widget, type){ if (widgetFilter(widget, type)){ widgets[type] = widget; } }); } else { angular.forEach(dashboard.widgets,function(widget){ widget.description = $translate.instant(widget.description ); widget.title = $translate.instant(widget.title); }); widgets = dashboard.widgets; } addScope.widgets = widgets; var opts = { scope: addScope, templateUrl: adfTemplatePath + ‘widget-add.html’ }; var instance = $uibModal.open(opts); addScope.addWidget = function(widget){ var w = { type: widget, config: createConfiguration(widget) }; addScope.model.rows[0].columns[0].widgets.unshift(w); instance.close();

          addScope.$destroy();
        };
        addScope.closeDialog = function(){
          instance.close();
          addScope.$destroy();
        };
      };
    },`

Then Inject $translate in the Controller of angular.module(‘adf’).directive(‘adfDashboard’,…

now u can use translateStrings for title and description. I hope that will help u

Read more comments on GitHub >

github_iconTop Results From Across the Web

Internationalizing Flutter apps
More information about these app properties, the types they depend on, and how internationalized Flutter apps are typically structured, can be found below....
Read more >
How to add widget in the existing page - ServiceNow
Type the name of the widget in "filter widget" and it will display your widget then drag it to the required area. Refer...
Read more >
Widget inside another widget Qt - c++ - Stack Overflow
enter image description here. So, custom your own widget using QGridLayout and set the position of your widget inside it.
Read more >
Widgets inside Graphics View - Game Programming Using Qt ...
First we create a QSpinBox and a QGraphicsProxyWidget element, which act as containers for widgets and indirectly inherit QGraphicsItem.
Read more >
Widgets | Theme Developer Handbook
construct : Set up your widget with a description, name, and display width in your admin. widget : Process the widget options and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found