From 9ac08785a2e2baa7d921eb83a8451cd8c2dcd963 Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Thu, 15 Dec 2016 18:39:17 +0000 Subject: [PATCH] Add boilerplate plugin --- src/fixtures/i18n_plugin_template/README.md | 19 +++++++++++++++++++ .../i18n_plugin_template/i18n/es.json | 4 ++++ src/fixtures/i18n_plugin_template/index.js | 11 +++++++++++ .../i18n_plugin_template/package.json | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 src/fixtures/i18n_plugin_template/README.md create mode 100644 src/fixtures/i18n_plugin_template/i18n/es.json create mode 100644 src/fixtures/i18n_plugin_template/index.js create mode 100644 src/fixtures/i18n_plugin_template/package.json diff --git a/src/fixtures/i18n_plugin_template/README.md b/src/fixtures/i18n_plugin_template/README.md new file mode 100644 index 00000000000000..add99685454496 --- /dev/null +++ b/src/fixtures/i18n_plugin_template/README.md @@ -0,0 +1,19 @@ +# management-es + +A Kibana translation plugin structure. + +The main goal is to keep the plugin extremely simple so non-technical translators will have no trouble +creating new translations for Kibana. Everything except for the translations themselves can be generated +automatically with some enhancements to the Kibana plugin generator. The generator would only need a +plugin name and a list of one or more languages the user wants to create translations for. + +The default plugin init function will register all translation files in the plugin's root level i18n directory. +For more advanced plugins that might have a different directory structure, this default is configurable by modifying +the init function. + +Translation files are broken up by language and must have names that match IETF BCP 47 language codes. +Each translation file contains a single flat object with translation strings matched to their unique keys. Keys are +prefixed with plugin names and a dash to ensure uniqueness between plugins. A translation plugin is not restricted to +providing translations only for itself, the provided translations can cover other plugins as well. +For example, this plugin shows how a third party plugin might provide spanish translations for the Kibana core "management" +app, which is itself a separate plugin. diff --git a/src/fixtures/i18n_plugin_template/i18n/es.json b/src/fixtures/i18n_plugin_template/i18n/es.json new file mode 100644 index 00000000000000..2bd3529652d269 --- /dev/null +++ b/src/fixtures/i18n_plugin_template/i18n/es.json @@ -0,0 +1,4 @@ +{ + "management-title": "administraciĆ³n", + "management-version": "versiĆ³n" +} diff --git a/src/fixtures/i18n_plugin_template/index.js b/src/fixtures/i18n_plugin_template/index.js new file mode 100644 index 00000000000000..d2d1bacd37a298 --- /dev/null +++ b/src/fixtures/i18n_plugin_template/index.js @@ -0,0 +1,11 @@ +import { resolve } from 'path'; + +export default function (kibana) { + return new kibana.Plugin({ + require: ['i18n'], + + init(server, options) { + server.plugins.i18n.registerTranslations(resolve(__dirname, 'i18n')); + } + }); +}; diff --git a/src/fixtures/i18n_plugin_template/package.json b/src/fixtures/i18n_plugin_template/package.json new file mode 100644 index 00000000000000..52479fcd44ba36 --- /dev/null +++ b/src/fixtures/i18n_plugin_template/package.json @@ -0,0 +1,4 @@ +{ + "name": "management-es", + "version": "kibana" +}