Skip to content

Kibana Globalization - Phase 2#8766

Merged
Bargs merged 18 commits intoelastic:masterfrom
hickeyma:i18n_phase2
Mar 20, 2017
Merged

Kibana Globalization - Phase 2#8766
Bargs merged 18 commits intoelastic:masterfrom
hickeyma:i18n_phase2

Conversation

@hickeyma
Copy link
Contributor

@hickeyma hickeyma commented Oct 19, 2016

Phase 2

Purpose

  • Integrate angular-translate globalization framework with i18n engine (from phase 1)
  • Provide template for enabling translations in an AngularJS view by translating a view
  • Implement a tool to generate the translation plugin
  • Documentation

Translations Available Client Side

  • Make the translations available on the client side by:
    • Embedding the translations in the initial HTML payload:
      • Reduces complexity and removes a round trip
      • Evaluation required to test if it performs well and does not create a large payload
    • If the evaluation of HTML payload is non performant, then the following approaches should be investigated in this order:
      1. Use current bundle mechanism:
        • (Kibana Jade template) to call API and generate the bundle which will be loaded during start-up
        • The JavaScript 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
      2. Client side directly calls REST API and loads the JSON payload:
        • 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
        • GET /i18n/translationsForDefaultLocale ==> returns the default locale translations
    • All approaches will decide the language to be served up by using the language deciding algorithm (from Phase 1)
      hose that want to enable translation in Kibana
      those that want to contribute translations to Kibana
      those that want to create a Kibana Plugin

Translation Identifiers Added to Kibana UI

  • Ids are added to the relevant view with Angular and HTML content
  • English (en) translation file is generated for the Ids defined
  • Approach for translating UI content:
    • Angular UI portion:
      • Use angular-translate for simplicity of the UI template resources, taking advantage of angular idioms.

BEFORE (HTML)

    <div class="sidebar-list"><div class="sidebar-list-header">
        <h5>Selected Fields</h5>
    </div>

AFTER (HTML)

    <div class="sidebar-list"><div class="sidebar-list-header">
        <h5 translate="FIELDS_SELECTEDFIELDS"></h5>
    </div>

Tool for Verifying All Translations have Translatable Strings (Update)

  • Verify translation IDs in Angular templates
  • Possible solutions are:
    • Use grunt-angular-translate . Searches all view and JS scripts to find angular-translate calls and extracts keys to file
    • Update current verification tool to search for angular-translate pattern in code and extract the keys
  • The keys in the key file(s) would then be checked against the language translation files registered

Translation Plugin Generator

  • Tool which generates a translation plugin
  • Localization engineer should only need to add translation file(s) within the plugin directory, refernce the file(s) in the 'uiExports' plugin extension, and add plugin to Kibana
  • All integration with Kibana works OOTB

Deliverable

  • Angular View where globalization is enabled showing the pattern to use
  • Verification tool updated to check translations in angular-translate constructs
  • [Elastic] Translatation and verification of xplugins (React)
  • A generator that localization engineers can use to produce language translations and integrate them in Kibana in an easy manner
  • Documentation relevant for the following stakeholders:
    • those that want to enable translation in Kibana
    • those that want to contribute translations to Kibana
    • those that want to create a Kibana Plugin

@elasticmachine
Copy link
Contributor

Can one of the admins verify this patch?

@hickeyma hickeyma changed the title Kibana Globalization - Phase 2 [WIP] Kibana Globalization - Phase 2 Oct 20, 2016
@hickeyma
Copy link
Contributor Author

Dependent on #7545

@elasticmachine
Copy link
Contributor

Can one of the admins verify this patch?

@hickeyma hickeyma force-pushed the i18n_phase2 branch 5 times, most recently from 3a33bff to a6cd076 Compare January 16, 2017 10:56
@epixa epixa added the Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// label Jan 26, 2017
@hickeyma hickeyma force-pushed the i18n_phase2 branch 5 times, most recently from c6830ec to cc72df8 Compare February 8, 2017 17:09
@hickeyma hickeyma changed the title [WIP] Kibana Globalization - Phase 2 Kibana Globalization - Phase 2 Feb 8, 2017
@hickeyma
Copy link
Contributor Author

hickeyma commented Feb 8, 2017

@spalger PR ready for review.

@spalger spalger added the review label Feb 8, 2017
@spalger
Copy link
Contributor

spalger commented Feb 8, 2017

jenkins, test this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the ['$translateProvider', ...] wrapper around this provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the language is not variable at this point, so perhaps we could simplify this (and remove the translationLoader factory) by just using $translateProvider.translations('default', chrome.getTranslations())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks, Means I can now remove the custom loader.

src/ui/index.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not be necessary, but if angular-translate requires the language code for the translations it's providing, perhaps we could update getTranslationsForRequest to return the resolved language code as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point but unnecessary now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is specifically for the ui-bootstrap dependency. I think it would be better if we moved the new logic into src/ui/public/chrome/api/translations.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to loading the translations directly with angular-translate then the custom loader factory function is now obsolete.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to override the default import. We minify the distributable and prefer non-minified code for development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sure. Removed.

TRANSLATION.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this into docs/development/plugin/development-internationalization.asciidoc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll hold back my review of the docs until we move them there, since the transition will wipe out all comments anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, moved and converted to an asciidoc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the intention here, but I'm not a fan of having an unused template as a part of the source. Fixtures are for tests, so if we wanted to make use of them that way I would feel better about it, but this would be best as a pull-request to generator-kibana-plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aim to amuse! :) I have made changes in the other repo as elastic/generator-kibana-plugin#45

hickeyma added a commit to hickeyma/generator-kibana-plugin that referenced this pull request Feb 10, 2017
This commit is part og Kibana globalization and PR
elastic/kibana#8766
@hickeyma
Copy link
Contributor Author

@spalger Thanks for #8766 (review) . Comments updated and ready for review again.

@hickeyma
Copy link
Contributor Author

hickeyma commented Mar 6, 2017

lol @Bargs. Added strings to the translation file and then got distracted! Committed the changes now.

@Bargs
Copy link
Contributor

Bargs commented Mar 20, 2017

jenkins, test this

@Bargs Bargs merged commit 3aa5938 into elastic:master Mar 20, 2017
Bargs pushed a commit that referenced this pull request Mar 20, 2017
* Integrate angular-translate globalization framework with i18n engine
* Provide template for enabling translations in an AngularJS view by translating a view
* Verification tool for translation keys used in angular-translate
* Documentation
@hickeyma
Copy link
Contributor Author

Thanks @Bargs, @posijon and @spalger for all the work on phase 2.

Bargs pushed a commit that referenced this pull request Mar 20, 2017
* Integrate angular-translate globalization framework with i18n engine
* Provide template for enabling translations in an AngularJS view by translating a view
* Verification tool for translation keys used in angular-translate
* Documentation
@lukasolson lukasolson mentioned this pull request Apr 18, 2017
weishionshi pushed a commit to weishionshi/kibana that referenced this pull request May 15, 2017
…38daaefc30e21bdd18d1ce2263923cfe12a

* Integrate angular-translate globalization framework with i18n engine
* Provide template for enabling translations in an AngularJS view by translating a view
* Verification tool for translation keys used in angular-translate
* Documentation
# Conflicts:
#	src/core_plugins/kibana/public/management/sections/indices/_create.html
#	src/ui/public/chrome/chrome.js
#	tasks/build/verify_translations.js
#	tasks/utils/i18n_verify_keys.js
@hickeyma hickeyma deleted the i18n_phase2 branch May 15, 2017 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v5.4.0 v6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants