Skip to content

Instantly share code, notes, and snippets.

@hickeyma
Created July 21, 2016 14:30
Show Gist options
  • Save hickeyma/de2fcc6cd7034fef8668ad991583e35c to your computer and use it in GitHub Desktop.
Save hickeyma/de2fcc6cd7034fef8668ad991583e35c to your computer and use it in GitHub Desktop.
@Bargs @epixa following on from our discussions and investigations, we are going to propose the following for Kibana Globalization. Any errors or omissions are mine!
Kibana Globalization Proposal
=============================
Purpose
-------
- Provide translation readiness on the Kibana web-facing UI
- Delivered in a phased approach
***Phase 1***
-------------
i18n Plugin
-----------
- Manages the language translations for Kibana
- Responsible for loading translated content per language
- API:
- Register translations:
- *registerTranslations(\<absolute_path_to_translation_file\>)*
- The translation file will be bundled into one translation file per language and stored in the Kibana data directory
- Fetch the list of currently supported languages:
- *getRegisteredTranslationLanguages()*
- Returns a list of all languages as language codes for which translations are registered
- Fetch a specific language translated content bundle:
- *getRegisteredLanguageTranslations(\<language\_code\>)*
- Returns a JSON object of all registered translations for the language code specified
- Deliverable:
- Translate the start-up message (“Kibana is loading ...”)in the Jade template
([*https://github.com/elastic/kibana/blob/master/src/ui/views/ui\_app.jade*](https://github.com/elastic/kibana/blob/master/src/ui/views/ui_app.jade))
Tool for Registering Translations
-------------------------------------------------------------
- Tool that takes a path to a translation file as an argument and calls the *registerTranslate* module API
- This tool could be used to register core plugins translations
- Deliverable:
- Register the start-up message (“Kibana is loading ...”)
***Phase 2***
-------------
Kibana Plugin Install Time Hook
-------------------------------
- A plugin install time hook in Kibana which can be called by a pluginduring its installation phase
- This capability can be used by the i18n plugin to set a context which can be called during the installation of the translation plugin
- This enables the i18n plugin to set register translations as the context and therefore means all translation plugins automatically register their translation during install time
- Prototype as follows: [*https://github.com/elastic/kibana/pull/7613*](https://github.com/elastic/kibana/pull/7613)
- Deliverable:
- Translation plugin registers its translations during the plugin installation
i18n Plugin (update)
--------------------
- Set the plugin install context to call register translations
- Deliverable:
- Translation plugin registers its translations during the plugin installation
Translation Plugin Boilerplate
------------------------------
- A boilerplate of a Kibana plugin which contains the minimal of actual code to enable registration of translations with the i18n plugin
- The translation plugin indirectly call the i18n register translations through the install time hook (*bin/kibana-plugin install*)
- A translation plugin can register:
- One language for one Kibana view/plugin
- Multiple languages for one Kibana view/plugin
- One language for multiple Kibana views/plugins
- Multiple languages for multiple Kibana views/plugins
- The translation file are JSON files with a flat keyspace, where the keys are unique. This uniqueness between translation plugins could be achieved by prefixing the keys with the plugin name. The key signifies the translation ID which would be referenced in translatable files (like JS, HTML etc.).
- The key value is the translation string
- An example translation plugin structure :
[*https://github.com/Bargs/management-es*](https://github.com/Bargs/management-es)
- Core Kibana plugins like ‘kibana’ and ‘status\_page’ could come with their own English translations bundled in
- Deliverables:
- A template that localization engineers can use to produce language translations and integrate them in Kibana in an easy manner
- Translation plugin registers its translations during the plugin installation
***Phase 3***
-------------
i18n Plugin (update)
--------------------
- Add REST API for getting all translations for a language:
- GET /i18n/translations ==\> returns the English (or German or whatever) translations negotiated with the browser HTTP header “accept-language” priority list compared against the languages supported
- Deliverable:
- Automated API tests pass
- Integrated into Kibana Jade application:
- ([*https://github.com/elastic/kibana/blob/master/src/ui/views/ui\_app.jade*](https://github.com/elastic/kibana/blob/master/src/ui/views/ui_app.jade)) to generate the bundle and bundle loaded during start-up
- Decide the language to be served up by comparing browser languages against the translation supported languages
- The bundle produced will be of the following format: *i18n\_\<language\>.bundle.js*
- Kibana loads all resource bundles on the client side after starting the single-page application
- View sample of angular constructs can load translations
- Sample HTML View can load translations
***Phase 4***
-------------
Translation Plugin Generator
----------------------------
- Tool which generates a translation plugin
- Localization engineer should only need to add translation file(s) within the plugin directory and call Kibana plugin install
- Deliverable:
- Translation plugin is generated which can be installed as plugin in Kibana with translation files added
Tool for Verifying All Translations have Translatable Strings
-------------------------------------------------------------
- Grunt run task tool that tests all translatable strings have a translation (i.e. all translation IDs have a corresponding translation string)
- This could be run by CI to verify globalization end-to-end capability
- A possible solution:
- [*https://github.com/angular-translate/grunt-angular-translate*](https://github.com/angular-translate/grunt-angular-translate).Searches all view and JS scripts to find angular-translate calls and extracts keys to file
- For non-angular constructs: Enforce a pattern to be used. For example a `translate(<key>)` function in the Jade template. A tool can then be used to find such pattern and extract the keys to file
- The keys in the key file(s) would then be checked against the language translation files registered
- Deliverable:
- Tool can be run by CI to verify translation IDs have a corresponding translation string
Translation Identifiers Added to Kibana UI
------------------------------------------
- Ids are added to the relevant UI content (HTML, JS etc.)
- English (en) translation file(s) are generated for the Ids defined
- Deliverables:
- Tool can be run by CI to verify translation IDs have a corresponding translation string
- Localization engineers can start generating translation plugins for different languages
***Blockers***
--------------
***Open Questions/Issues***
---------------------------
- Translation of user data
Authors
------------------------------------------
- Martin Hickey: @hickeyma
- Shikha Srivastava: @shikhasriva
- Steven R. Loomis: @srl295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment