Skip to content

Commit

Permalink
Add angular-translate as the Angular globalization framework
Browse files Browse the repository at this point in the history
The angular-translate framework integrates with the Kibana i18n engine whereby it
consumes translations from the i18n engine and not the translations directly.
This is achieved by using a custom loader which calls the client side getTranslations()
method. This method return the translations loaded by the i18n engine during instantation
of Kibana server instance.
  • Loading branch information
hickeyma committed Mar 6, 2017
1 parent d2fc0c4 commit 0ab48f0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"angular-route": "1.4.7",
"angular-sanitize": "1.5.7",
"angular-sortable-view": "0.0.15",
"angular-translate": "2.13.1",
"ansicolors": "0.3.2",
"autoprefixer": "6.5.4",
"autoprefixer-loader": "2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<kbn-management-indices>
<div ng-controller="managementIndicesCreate" class="kbn-management-indices-create">
<div class="page-header">
<h1>Configure an index pattern</h1>
<h1 translate>KIBANA-H1_CONFIGURE_INDEX_PATTERN</h1>
In order to use Kibana you must configure at least one index pattern. Index patterns are
used to identify the Elasticsearch index to run search and analytics against. They are also
used to configure fields.
Expand Down
3 changes: 2 additions & 1 deletion src/core_plugins/kibana/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"UI-WELCOME_MESSAGE": "Loading Kibana",
"UI-WELCOME_ERROR": "Kibana did not load properly. Check the server output for more information."
"UI-WELCOME_ERROR": "Kibana did not load properly. Check the server output for more information.",
"KIBANA-H1_CONFIGURE_INDEX_PATTERN": "Configure an index pattern"
}
3 changes: 2 additions & 1 deletion webpackShims/angular.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require('jquery');
require('node_modules/angular/angular');
require('node_modules/angular-translate/dist/angular-translate.min');
module.exports = window.angular;

require('node_modules/angular-elastic/elastic');

require('ui/modules').get('kibana', ['monospaced.elastic']);
require('ui/modules').get('kibana', ['monospaced.elastic', 'pascalprecht.translate']);
20 changes: 18 additions & 2 deletions webpackShims/ui-bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
define(function (require) {
require('angular');
require('ui/angular-bootstrap/index');
const chrome = require('../src/ui/public/chrome/chrome');

return require('ui/modules')
.get('kibana', ['ui.bootstrap'])
.get('kibana', ['ui.bootstrap', 'pascalprecht.translate'])
.config(function ($tooltipProvider) {
$tooltipProvider.setTriggers({ 'mouseenter': 'mouseleave click' });
});
})
.factory('translationsLoader', function ($q) {
return function (options) {
var deferred = $q.defer();
const translations = chrome.getTranslations();
deferred.resolve(translations);
return deferred.promise;
};
})
.config(['$translateProvider', function ($translateProvider) {
$translateProvider.preferredLanguage('en');
$translateProvider.useLoader('translationsLoader');
// Enable escaping of HTML
// issue in https://angular-translate.github.io/docs/#/guide/19_security
$translateProvider.useSanitizeValueStrategy('escape');
}]);

});

0 comments on commit 0ab48f0

Please sign in to comment.