[i18n] Translate ML - items grid and item select (#28236)

* Translate item_select

* Translate items_grid
This commit is contained in:
Nox911 2019-01-09 10:53:21 +03:00 committed by GitHub
parent 0c85bef82b
commit 7c4710b7e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 4 deletions

View file

@ -14,7 +14,7 @@
<ui-select-choices
repeat="item in mlItemSelect.allItems | filter: { id: $select.search }"
>
<div ng-if="item.isTag" class="select-item" ng-bind-html="(item.id | highlight: $select.search) +' <small>'+ (mlItemSelect.taggingText === undefined ? '(new item)' : mlItemSelect.taggingText) +'</small>'"></div>
<div ng-if="item.isTag" class="select-item" ng-bind-html="(item.id | highlight: $select.search) +' <small>'+ (mlItemSelect.taggingText === undefined ? mlItemSelect.newItemLabel : mlItemSelect.taggingText) +'</small>'"></div>
<div ng-if="!item.isTag" class="select-item" >
<div ng-bind-html="item.id | highlight: $select.search"></div>
<small ng-if="item.extra!==undefined">

View file

@ -10,6 +10,7 @@ import template from './item_select.html';
import { InitAfterBindingsWorkaround } from 'ui/compat';
import { uiModules } from 'ui/modules';
import { i18n } from '@kbn/i18n';
const module = uiModules.get('apps/ml');
module.directive('mlItemSelect', function () {
@ -28,6 +29,10 @@ module.directive('mlItemSelect', function () {
controllerAs: 'mlItemSelect',
bindToController: true,
controller: class MlItemSelectController extends InitAfterBindingsWorkaround {
constructor() {
this.newItemLabel = i18n.translate('xpack.ml.itemSelect.newItemLabel', { defaultMessage: '(new item)' });
}
initAfterBindings($scope) {
this.$scope = $scope;
this.selectedItems = [];

View file

@ -22,6 +22,8 @@ import {
import { ItemsGridPagination } from './items_grid_pagination';
import { FormattedMessage } from '@kbn/i18n/react';
export function ItemsGrid({
numberColumns,
totalItemCount,
@ -39,7 +41,18 @@ export function ItemsGrid({
<EuiFlexGroup justifyContent="spaceAround">
<EuiFlexItem grow={false}>
<EuiText>
<h4>{(totalItemCount === 0) ? 'No items have been added' : 'No matching items'}</h4>
<h4>{(totalItemCount === 0) ? (
<FormattedMessage
id="xpack.ml.itemsGrid.noItemsAddedTitle"
defaultMessage="No items have been added"
/>
) : (
<FormattedMessage
id="xpack.ml.itemsGrid.noMatchingItemsTitle"
defaultMessage="No matching items"
/>
)}
</h4>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>

View file

@ -24,6 +24,8 @@ import {
EuiPopover,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
function getContextMenuItemIcon(menuItemSetting, itemsPerPage) {
return (menuItemSetting === itemsPerPage) ? 'check' : 'empty';
@ -77,7 +79,11 @@ export class ItemsGridPagination extends Component {
iconSide="right"
onClick={this.onButtonClick}
>
Items per page: {itemsPerPage}
<FormattedMessage
id="xpack.ml.itemsGrid.itemsPerPageButtonLabel"
defaultMessage="Items per page: {itemsPerPage}"
values={{ itemsPerPage }}
/>
</EuiButtonEmpty>
);
@ -90,7 +96,11 @@ export class ItemsGridPagination extends Component {
icon={getContextMenuItemIcon(pageSize, itemsPerPage)}
onClick={() => {this.onChangeItemsPerPage(pageSize);}}
>
{pageSize} items
<FormattedMessage
id="xpack.ml.itemsGrid.itemsCountLabel"
defaultMessage="{pageSize} items"
values={{ pageSize }}
/>
</EuiContextMenuItem>
);
});