Remove angular-translate (#13066)

* remove angular translate

* remove angular-translate deps from yarn.lock
This commit is contained in:
Court Ewing 2018-01-12 09:13:42 -05:00 committed by GitHub
parent 7431ec1538
commit 61c7f21111
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 244 deletions

View file

@ -1,186 +0,0 @@
[[translating-kibana]]
Translating Kibana
------------------
[[background]]
Background
~~~~~~~~~
Please see https://github.com/elastic/kibana/issues/6515[kibana#6515]
for background discussion on the Kibana translation work.
[[prerequisites]]
Prerequisites
~~~~~~~~~~~~
Kibana must be installed and operational, see README.md
[[audience]]
Audience
~~~~~~~
There are three audiences for this document:
* those that want to contribute language packs to Kibana
* those that want to enable translations in existing Kibana plugins
* those that want to create a new Kibana Plugin
[[contributing-language-packs]]
Contributing Language Packs
~~~~~~~~~~~~~~~~~~~~~~~~~~
For this example, we will demonstrate translation into Maltese (Language
code `mt`). Add-on functionality for Kibana is implemented with plug-in modules.
Refer to
<<kibana-plugins, Kibana Plugins>> for more details.
* Fork the `kibana` source, and ensure you have an up to date copy of
the source.
* Ensure you have signed the agreement as in CONTRIBUTING.md
* Choose the right link:[bcp47] language code for your work. In this
example, we will use the `kibana` plugin for translating and `mt` for
Maltese. Other examples might be `zh-Hans` for Chinese using Simplified
characters, or `az-Cyrl` for Azerbaijani using Cyrillic characters. The
following links can help:
* https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes[List of ISO
639-1 codes]
*
http://cldr.unicode.org/index/cldr-spec/picking-the-right-language-code[“Picking
the right language code”]
* Create a new branch for your work:
+
git checkout -b translate-mt
* For each translation scope (see link:#Enabling%20Translations%20on%20Existing%20Plugins[Enabling Translations on Existing Plugins], below), generate a Kibana plugin with name _plugin_-_languagecode_ using the https://github.com/elastic/generator-kibana-plugin[Kibana Plugin Yeoman Generator]:
+
* Replace the the `es.json` translation file with _languagecode_`.json`:
`mv src/plugins/kibana-mt/translations/es.json src/plugins/kibana-mt/translations/mt.json`
* Translate the `mt.json` file in a JSON editor
* Edit index file (`kibana-mt/index.js`), updating the
'translations' item in 'uiExports' as per your plugin translation file(s)
* Copy translations plugin (`kibana-mt/`) to the Kibana plugins (`<kibana_root>/plugins`) directory
* Start up Kibana and verify the translation works as expected
* Ensure Kibana tests pass
* Commit the `kibana-mt` directory and files, and push them to your own
fork of `kibana`
* Open a pull request titled `Translation: Maltese (mt)`
[[enabling-ranslations-on-existing-plugins]]
Enabling Translations on Existing Plugins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kibana translates according to plugin scope, so there is a `.json` file
in `translations` subdirectory for each plugin.
[[enabling-translation-of-an-angular-view]]
Enabling Translation of an Angular view
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Determine which views share a plugin scope. In this example, `create`
and `edit` will share scope.
* If it does not already exist, Create the appropriate `translation`
directory and the new translation file `en.json` inside it. In the above
example, it would be: `src/core_plugins/kibana/translations/en.json`
* If it does not exist add 'translations' item to the 'uiExports' in the plugin creation (`src/core_plugins/kibana/translations/en.json`) as follows:
-------------------------------------------------------------------------
uiExports {
translations: [
resolve(__dirname, './translations/en.json')
], ….
}
-------------------------------------------------------------------------
* In the view (HTML) file, such as
`src/core_plugins/kibana/public/management/sections/indices/_create.html`
Replace English text with translation keys, and copy the English text
into the `en.json` file appropriately. Note that loose text was put into
a `<p></p>` tag for translation purposes. Also note the prefix `KIBANA-`
matching the plugin being translated.
[[before]]
Before
++++++
`_create.html`
-----------------------------------------------------------------------------------------------------
<h1>Configure an index pattern</h1>
In order to use Kibana you must configure at least one index pattern…
<kbn-info info="This field will be used to filter events with the global time filter"></kbn-info>
-----------------------------------------------------------------------------------------------------
[[after]]
After
+++++
`_create.html`
-------------------------------------------------------------------------------------------
<h1 translate="KIBANA-CONFIGURE_INDEX_PATTERN"</h1>
<p translate="KIBANA-MUST_CONFIGURE_INDEX_PATTERN"</p>
<kbn-info info="{{ 'KIBANA-FIELD_FILTER_EVENTS_GLOBAL_TIME' | translate }}"></kbn-info>
-------------------------------------------------------------------------------------------
* In the view (JS) file, such as
`src/core_plugins/kibana/public/management/sections/indices/_create.js`
As above, replace English text with translation keys, and copy the English text
into the `en.json` file appropriately. Note that some strings may not be user facing
and do not need to be replaced then. Also note the prefix `KIBANA-` matching the plugin
being translated.
[[before]]
Before
++++++
`_create.js`
--------------------------------------------------------------------------------------------------------------
notify.error('Could not locate any indices matching that pattern. Please add the index to Elasticsearch');
--------------------------------------------------------------------------------------------------------------
[[after]]
After
+++++
`_create.js`
-------------------------------------------------------------------------------------------
notify.error($translate.instant('KIBANA-NO_INDICES_MATCHING_PATTERN'));
-------------------------------------------------------------------------------------------
`en.json`
-----------------------------------------------------------------------------------------------------------------------------------------
{
"KIBANA-CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-MUST_CONFIGURE_INDEX_PATTERN": "In order to use Kibana you must…",
"KIBANA-FIELD_FILTER_EVENTS_GLOBAL_TIME" : "This field will be used to filter events with the global time filter",
"KIBANA-NO_INDICES_MATCHING_PATTERN": "Could not locate any indices matching that pattern. Please add the index to Elasticsearch",
}
-----------------------------------------------------------------------------------------------------------------------------------------
* Refresh the Kibana page and verify the UI looks the same.
* Refer to Kibana core plugin (`src/core_plugins/kibana/`) for examples.
[[new-plugin-authors]]
New Plugin Authors
~~~~~~~~~~~~~~~~~
Add-on functionality for Kibana is implemented with plug-in modules.
Refer to
<<kibana-plugins, Kibana
Plugins>> for more details. It is recommended that when creating a plugin
you enable translations (see link:#Enabling%20Translations%20on%20Existing%20Plugins[Enabling Translations on Existing Plugins], above).
[[enabling-translation-in-a-plugin]]
Enabling Translation in a New Plugin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Generate a Kibana plugin using the https://github.com/elastic/generator-kibana-plugin[Kibana Plugin Yeoman Generator]. In this
example, `plugin1`
* Add the translation IDs to the views
* Add the corresponding translation IDs and text to the default translation file (`translations/en.json`)
* Refer to link:#Enabling%20Translations%20on%20Existing%20Plugins[Enabling Translations on Existing Plugins] for more
details on enabling translation in your plugin views and refer to Kibana
core plugin (`src/core_plugins/kibana/`) for an example.

View file

@ -88,7 +88,6 @@
"angular-route": "1.4.7",
"angular-sanitize": "1.5.7",
"angular-sortable-view": "0.0.15",
"angular-translate": "2.13.1",
"autoprefixer": "6.5.4",
"babel-core": "6.21.0",
"babel-jest": "21.0.0",
@ -243,7 +242,6 @@
"faker": "1.1.0",
"getopts": "2.0.0",
"grunt": "1.0.1",
"grunt-angular-translate": "0.3.0",
"grunt-aws-s3": "0.14.5",
"grunt-babel": "6.0.0",
"grunt-cli": "0.1.13",

View file

@ -16,9 +16,6 @@ function init() {
debounce = $injector.get('debounce');
debounceFromProvider = Private(DebounceProvider);
// ensure there is a clean slate before testing deferred tasks
$timeout.flush();
});
}

View file

@ -6,13 +6,7 @@ import { collectUiExports } from '../../src/ui';
import { I18n } from '../../src/ui/ui_i18n/i18n';
export default function (grunt) {
grunt.registerTask('_build:verifyTranslations', [
'i18nextract',
'_build:check'
]);
grunt.registerTask('_build:check', async function () {
grunt.registerTask('_build:verifyTranslations', async function () {
const done = this.async();
try {
@ -36,8 +30,7 @@ export default function (grunt) {
}
async function verifyTranslations(uiExports) {
const angularTranslations = require(fromRoot('build/i18n_extract/en.json'));
const keysUsedInViews = Object.keys(angularTranslations);
const keysUsedInViews = [];
// Search files for used translation keys
const translationPatterns = [

View file

@ -1,9 +0,0 @@
export default function () {
return {
default_options: {
src: ['src/**/*.js', 'src/**/*.html'],
lang: ['en'],
dest: 'build/i18n_extract'
}
};
}

View file

@ -1,8 +1,7 @@
require('jquery');
require('../node_modules/angular/angular');
require('../node_modules/angular-translate');
module.exports = window.angular;
require('../node_modules/angular-elastic/elastic');
require('ui/modules').get('kibana', ['monospaced.elastic', 'pascalprecht.translate']);
require('ui/modules').get('kibana', ['monospaced.elastic']);

View file

@ -1,17 +1,9 @@
require('angular');
require('ui/angular-bootstrap');
var uiModules = require('ui/modules').uiModules;
var chrome = require('ui/chrome');
var kibana = uiModules.get('kibana', ['ui.bootstrap', 'pascalprecht.translate']);
var kibana = uiModules.get('kibana', ['ui.bootstrap']);
module.exports = kibana.config(function ($tooltipProvider) {
$tooltipProvider.setTriggers({ 'mouseenter': 'mouseleave click' });
})
.config(function ($translateProvider) {
$translateProvider.translations('default', chrome.getTranslations());
$translateProvider.preferredLanguage('default');
// Enable escaping of HTML
// issue in https://angular-translate.github.io/docs/#/guide/19_security
$translateProvider.useSanitizeValueStrategy('escape');
});
});

View file

@ -306,13 +306,7 @@ angular-sortable-view@0.0.15:
version "0.0.15"
resolved "https://registry.yarnpkg.com/angular-sortable-view/-/angular-sortable-view-0.0.15.tgz#e8463df909db83d641b028f0773a10d50292874f"
angular-translate@2.13.1:
version "2.13.1"
resolved "https://registry.yarnpkg.com/angular-translate/-/angular-translate-2.13.1.tgz#05673eb371986fc11edc151f590299d7e0c46228"
dependencies:
angular ">=1.2.26 <=1.6"
angular@1.6.5, angular@>=1.0.6, "angular@>=1.2.26 <=1.6":
angular@1.6.5, angular@>=1.0.6:
version "1.6.5"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.5.tgz#37f788eebec5ce2e3fa02b17bbcb2a231576a0d6"
@ -4157,12 +4151,6 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"
flat@^1.2.0:
version "1.6.1"
resolved "https://registry.yarnpkg.com/flat/-/flat-1.6.1.tgz#476b9dbb70d5e9340dbbc038bde084a20945921c"
dependencies:
is-buffer "~1.1.2"
flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
@ -4698,14 +4686,6 @@ growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
grunt-angular-translate@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/grunt-angular-translate/-/grunt-angular-translate-0.3.0.tgz#bd0118afa24d8f570231fd8d52d829d808c511b3"
dependencies:
flat "^1.2.0"
json-stable-stringify "^1.0.0"
lodash "~2.4.1"
grunt-aws-s3@0.14.5:
version "0.14.5"
resolved "https://registry.yarnpkg.com/grunt-aws-s3/-/grunt-aws-s3-0.14.5.tgz#f55019acfbeb05b89b245a51ccf1a81dbf868df4"
@ -5588,7 +5568,7 @@ is-binary-path@^1.0.0:
dependencies:
binary-extensions "^1.0.0"
is-buffer@^1.0.2, is-buffer@^1.1.4, is-buffer@^1.1.5, is-buffer@~1.1.2:
is-buffer@^1.0.2, is-buffer@^1.1.4, is-buffer@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
@ -6482,7 +6462,7 @@ json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1:
json-stable-stringify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af"
dependencies: