Skip to content

Commit

Permalink
Load translations on the client side
Browse files Browse the repository at this point in the history
Translations need to be loaded on the client side so that they can be used the
globalization frameworks like 'angular-translate'. This translations are made
available by embedding the translations in the initial HTML payload.
  • Loading branch information
hickeyma committed Jan 13, 2017
1 parent fcd4c18 commit 3a33bff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default async (kbnServer, server, config) => {

async function getKibanaPayload({ app, request, includeUserProvidedConfig }) {
const uiSettings = server.uiSettings();
const translations = await uiI18n.getTranslationsForRequest(request);

return {
app: app,
Expand All @@ -76,6 +77,7 @@ export default async (kbnServer, server, config) => {
basePath: config.get('server.basePath'),
serverName: config.get('server.name'),
devMode: config.get('env.dev'),
translations: translations,
uiSettings: await props({
defaults: uiSettings.getDefaults(),
user: includeUserProvidedConfig && uiSettings.getUserProvided(request)
Expand Down
5 changes: 5 additions & 0 deletions src/ui/public/chrome/api/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function (chrome, internals) {
chrome.getTranslations = function () {
return internals.translations || [];
};
}
1 change: 1 addition & 0 deletions src/ui/public/chrome/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require('./api/angular')(chrome, internals);
require('./api/controls')(chrome, internals);
require('./api/template')(chrome, internals);
require('./api/theme')(chrome, internals);
require('./api/translations')(chrome, internals);

chrome.bootstrap = function () {
chrome.setupAngular();
Expand Down

0 comments on commit 3a33bff

Please sign in to comment.