From 773aaf056f100b165d62fdcbc0fb0697f5ef3a74 Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Wed, 19 Oct 2016 22:30:56 +0100 Subject: [PATCH] Add a Kibana translation plugin structure Based on https://github.com/Bargs/management-es. Thanks @Bargs. --- .../i18n/server/tool/template/README.md | 19 +++++++++++++++++++ .../i18n/server/tool/template/i18n/es.json | 4 ++++ .../i18n/server/tool/template/index.js | 11 +++++++++++ .../i18n/server/tool/template/package.json | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 src/core_plugins/i18n/server/tool/template/README.md create mode 100644 src/core_plugins/i18n/server/tool/template/i18n/es.json create mode 100644 src/core_plugins/i18n/server/tool/template/index.js create mode 100644 src/core_plugins/i18n/server/tool/template/package.json diff --git a/src/core_plugins/i18n/server/tool/template/README.md b/src/core_plugins/i18n/server/tool/template/README.md new file mode 100644 index 000000000000000..add996854544967 --- /dev/null +++ b/src/core_plugins/i18n/server/tool/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/core_plugins/i18n/server/tool/template/i18n/es.json b/src/core_plugins/i18n/server/tool/template/i18n/es.json new file mode 100644 index 000000000000000..2bd3529652d2697 --- /dev/null +++ b/src/core_plugins/i18n/server/tool/template/i18n/es.json @@ -0,0 +1,4 @@ +{ + "management-title": "administraciĆ³n", + "management-version": "versiĆ³n" +} diff --git a/src/core_plugins/i18n/server/tool/template/index.js b/src/core_plugins/i18n/server/tool/template/index.js new file mode 100644 index 000000000000000..d2d1bacd37a2981 --- /dev/null +++ b/src/core_plugins/i18n/server/tool/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/core_plugins/i18n/server/tool/template/package.json b/src/core_plugins/i18n/server/tool/template/package.json new file mode 100644 index 000000000000000..52479fcd44ba36c --- /dev/null +++ b/src/core_plugins/i18n/server/tool/template/package.json @@ -0,0 +1,4 @@ +{ + "name": "management-es", + "version": "kibana" +}