[Canvas] Expose i18n to Canvas runtime (#27718)

Committing.  If there comes a case where the bundled i18n doesn't suffice, we'll cross that bridge when we arrive.
This commit is contained in:
Clint Andrew Hall 2019-01-02 20:29:11 -06:00 committed by GitHub
parent 1b2a5861b4
commit 59353daedf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -9,6 +9,7 @@
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@kbn/i18n": "1.0.0",
"lodash": "npm:@elastic/lodash@3.10.1-kibana1",
"lodash.clone": "^4.5.0",
"scriptjs": "^2.5.8",
@ -35,4 +36,4 @@
"webpack": "4.23.1",
"webpack-cli": "^3.1.2"
}
}
}

View file

@ -17,6 +17,7 @@
* under the License.
*/
import { i18n } from '@kbn/i18n';
import $script from 'scriptjs';
let resolvePromise = null;
@ -43,6 +44,7 @@ const loadBrowserRegistries = (registries, basePath) => {
const type = remainingTypes.pop();
window.canvas = window.canvas || {};
window.canvas.register = d => registries[type].register(d);
window.canvas.i18n = i18n;
// Load plugins one at a time because each needs a different loader function
// $script will only load each of these once, we so can call this as many times as we need?

View file

@ -17,6 +17,7 @@
* under the License.
*/
import { i18n } from '@kbn/i18n';
import { typesRegistry } from '../common/lib/types_registry';
import { functionsRegistry as serverFunctions } from '../common/lib/functions_registry';
import { getPluginPaths } from './get_plugin_paths';
@ -53,6 +54,7 @@ export const populateServerRegistries = types => {
getPluginPaths(type).then(paths => {
global.canvas = global.canvas || {};
global.canvas.register = d => registries[type].register(d);
global.canvas.i18n = i18n;
paths.forEach(path => {
require(path); // eslint-disable-line import/no-dynamic-require