forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add draft implementation of I18n engine (elastic#19555)
* Add draft implementation of I18n engine * Add i18n loader * kbn-i18n refactoring * Fix react i18n context and update doc * i18n engine refactoring * Fix locales data loading and add more jsdoc comments * Fix verify_translations task * I18n tests refactoring * Add build scripts to kbn-i18n package * Fix some bugs * Move uiI18nMixin into ui_i18n folder * Add 'browser' field to kbn-i18n package.json * Get rid of "showError" method * Make i18n and i18nLoader a singleton object * Add default locale as fallback if translation files were not registered * Update yarn.lock * kbn-i18n fix * Add default formats * Try to fix build * Add more examples into kbn-i18n/README.md * kbn-i18n fix * Fix app_bootstrap tests * Add links to issues in TODO comments
- Loading branch information
1 parent
3ea4c3e
commit f522b31
Showing
42 changed files
with
3,478 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"env": { | ||
"web": { | ||
"presets": ["@kbn/babel-preset/webpack_preset"] | ||
}, | ||
"node": { | ||
"presets": ["@kbn/babel-preset/node_preset"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@kbn/i18n", | ||
"browser": "./target/web/browser.js", | ||
"main": "./target/node/index.js", | ||
"module": "./src/index.js", | ||
"version": "1.0.0", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "yarn build:web && yarn build:node", | ||
"build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web", | ||
"build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node", | ||
"kbn:bootstrap": "yarn build", | ||
"kbn:watch": "yarn build --watch" | ||
}, | ||
"devDependencies": { | ||
"@kbn/babel-preset": "link:../kbn-babel-preset", | ||
"@kbn/dev-utils": "link:../kbn-dev-utils", | ||
"babel-cli": "^6.26.0", | ||
"cross-env": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"accept-language-parser": "^1.5.0", | ||
"intl-format-cache": "^2.1.0", | ||
"intl-messageformat": "^2.2.0", | ||
"intl-relativeformat": "^2.1.0", | ||
"json5": "^1.0.1", | ||
"prop-types": "^15.5.8", | ||
"react": "^16.3.0", | ||
"react-intl": "^2.4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export function i18nDirective(i18n) { | ||
return { | ||
restrict: 'A', | ||
scope: { | ||
id: '@i18nId', | ||
defaultMessage: '@i18nDefaultMessage', | ||
values: '=i18nValues', | ||
}, | ||
link: function($scope, $element) { | ||
$scope.$watchGroup(['id', 'defaultMessage', 'values'], function([ | ||
id, | ||
defaultMessage = '', | ||
values = {}, | ||
]) { | ||
$element.html( | ||
i18n(id, { | ||
values, | ||
defaultMessage, | ||
}) | ||
); | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export function i18nFilter(i18n) { | ||
return function(id, { defaultMessage = '', values = {} } = {}) { | ||
return i18n(id, { | ||
values, | ||
defaultMessage, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { i18nProvider } from './provider'; | ||
export { i18nFilter } from './filter'; | ||
export { i18nDirective } from './directive'; |
Oops, something went wrong.