diff --git a/src/ui/public/chrome/api/translations.js b/src/ui/public/chrome/api/translations.js deleted file mode 100644 index 589565a46e98e5..00000000000000 --- a/src/ui/public/chrome/api/translations.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// eslint-disable-next-line @elastic/kibana-custom/no-default-export -export default function (chrome, internals) { - /** - * ui/chrome Translations API - * - * Translations - * Returns the translations which have been loaded by the Kibana server instance - */ - - /** - * @return {Object} - Translations - */ - chrome.getTranslations = function () { - return internals.translations || []; - }; -} diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index 257224e08baed2..cfae977feb0f19 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -37,7 +37,6 @@ import controlsApi from './api/controls'; import { initChromeNavApi } from './api/nav'; import templateApi from './api/template'; import themeApi from './api/theme'; -import translationsApi from './api/translations'; import { initChromeXsrfApi } from './api/xsrf'; import { initUiSettingsApi } from './api/ui_settings'; import { initLoadingCountApi } from './api/loading_count'; @@ -73,7 +72,6 @@ initAngularApi(chrome, internals); controlsApi(chrome, internals); templateApi(chrome, internals); themeApi(chrome, internals); -translationsApi(chrome, internals); const waitForBootstrap = new Promise(resolve => { chrome.bootstrap = function (targetDomElement) { diff --git a/src/ui/public/i18n/index.js b/src/ui/public/i18n/index.js index d23ff00230b9a3..5def86410e3477 100644 --- a/src/ui/public/i18n/index.js +++ b/src/ui/public/i18n/index.js @@ -18,7 +18,6 @@ */ import { uiModules } from 'ui/modules'; -import { metadata } from 'ui/metadata'; import { I18nProvider, i18nFilter, @@ -28,7 +27,4 @@ import { uiModules.get('i18n') .provider('i18n', I18nProvider) .filter('i18n', i18nFilter) - .directive('i18nId', i18nDirective) - .config((i18nProvider) => { - i18nProvider.init(metadata.translations); - }); + .directive('i18nId', i18nDirective); diff --git a/src/ui/ui_bundles/app_entry_template.js b/src/ui/ui_bundles/app_entry_template.js index 764e70eaa10d0f..90d099ca7ee56a 100644 --- a/src/ui/ui_bundles/app_entry_template.js +++ b/src/ui/ui_bundles/app_entry_template.js @@ -33,10 +33,14 @@ import 'whatwg-fetch'; import 'abortcontroller-polyfill'; import 'childnode-remove-polyfill'; +import { i18n } from '@kbn/i18n'; import { CoreSystem } from '__kibanaCore__' +const injectedMetadata = JSON.parse(document.querySelector('kbn-injected-metadata').getAttribute('data')); +i18n.init(injectedMetadata.legacyMetadata.translations); + new CoreSystem({ - injectedMetadata: JSON.parse(document.querySelector('kbn-injected-metadata').getAttribute('data')), + injectedMetadata, rootDomElement: document.body, requireLegacyFiles: () => { ${bundle.getRequires().join('\n ')} diff --git a/src/ui/ui_render/bootstrap/app_bootstrap.js b/src/ui/ui_render/bootstrap/app_bootstrap.js index 0016773865dbe1..acee86dc7a7010 100644 --- a/src/ui/ui_render/bootstrap/app_bootstrap.js +++ b/src/ui/ui_render/bootstrap/app_bootstrap.js @@ -24,10 +24,9 @@ import { resolve } from 'path'; import { i18n } from '@kbn/i18n'; export class AppBootstrap { - constructor({ templateData, translations }) { + constructor({ templateData }) { this.templateData = templateData; this._rawTemplate = undefined; - i18n.init(translations); } async getJsFile() { diff --git a/src/ui/ui_render/bootstrap/app_bootstrap.test.js b/src/ui/ui_render/bootstrap/app_bootstrap.test.js index 64101b7830b383..a9f6f6a9278cb2 100644 --- a/src/ui/ui_render/bootstrap/app_bootstrap.test.js +++ b/src/ui/ui_render/bootstrap/app_bootstrap.test.js @@ -57,15 +57,6 @@ describe('ui_render/AppBootstrap', () => { expect(contents).toContain('123'); expect(contents).toContain('/foo/bar'); }); - - test('supports i18n', async () => { - expect.assertions(1); - - const bootstrap = new AppBootstrap(mockConfig()); - const contents = await bootstrap.getJsFile(); - - expect(contents).toContain('translated foo'); - }); }); describe('getJsFileHash()', () => { @@ -121,36 +112,11 @@ describe('ui_render/AppBootstrap', () => { expect(hash2).toHaveLength(40); expect(hash2).not.toEqual(hash1); }); - - test('resolves to different 40 character string with different translations', async () => { - expect.assertions(3); - - const bootstrap1 = new AppBootstrap(mockConfig()); - const hash1 = await bootstrap1.getJsFileHash(); - - const config2 = { - ...mockConfig(), - translations: { - locale: 'en', - foo: 'not translated foo' - } - }; - const bootstrap2 = new AppBootstrap(config2); - const hash2 = await bootstrap2.getJsFileHash(); - - expect(typeof hash2).toEqual('string'); - expect(hash2).toHaveLength(40); - expect(hash2).not.toEqual(hash1); - }); }); }); function mockConfig() { return { - translations: { - locale: 'en', - foo: 'translated foo' - }, templateData: { appId: 123, bundlePath: '/foo/bar' diff --git a/src/ui/ui_render/ui_render_mixin.js b/src/ui/ui_render/ui_render_mixin.js index 30ca1357b349e1..dd0848215a0be8 100644 --- a/src/ui/ui_render/ui_render_mixin.js +++ b/src/ui/ui_render/ui_render_mixin.js @@ -75,8 +75,7 @@ export function uiRenderMixin(kbnServer, server, config) { appId: app.getId(), bundlePath, styleSheetPaths, - }, - translations: await server.getUiTranslations() + } }); const body = await bootstrap.getJsFile();