Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations for ui/vis #23694

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
692ddac
Translate default editor
maryia-lapata Oct 1, 2018
4c3277a
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 2, 2018
beb0a49
Translate aria-labels, update ids
maryia-lapata Oct 2, 2018
674a9ba
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 3, 2018
06612b0
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 5, 2018
6aebed2
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 8, 2018
e1cd183
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 9, 2018
7f73af8
Fix review comments
maryia-lapata Oct 9, 2018
cd83bfb
Revert deletion of NOT
maryia-lapata Oct 9, 2018
dfcc649
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 10, 2018
dfca524
Use one-time binding
maryia-lapata Oct 10, 2018
ef55807
Translations for ui/vis
maryia-lapata Oct 11, 2018
e81d903
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 16, 2018
9dd7151
Revert changes
maryia-lapata Oct 16, 2018
372ff76
Fix a typo
maryia-lapata Oct 16, 2018
3d54ab1
Merge pull request #4 from maryia-lapata/feature/translations/vis_ui
maryia-lapata Oct 16, 2018
0db8bd5
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 17, 2018
c7e5a90
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 19, 2018
13782d8
Refactoring
maryia-lapata Oct 19, 2018
de6a100
Revert translations since they aren't displayed on ui
maryia-lapata Oct 19, 2018
76fd1ef
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 23, 2018
6a8d5f6
Merge branch 'master' into feature/translations/vis_metric_panel
maryia-lapata Oct 25, 2018
e5c02b7
Merge branch 'master' into feature/translations/vis_metric_panel
pavel06081991 Nov 5, 2018
31d535b
resolve review comments
pavel06081991 Nov 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ui/public/fancy_forms/kbn_form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

export function decorateFormController($delegate, $injector) {
export function decorateFormController($delegate, $injector, i18n) {
const [directive] = $delegate;
const FormController = directive.controller;

Expand Down Expand Up @@ -52,7 +52,11 @@ export function decorateFormController($delegate, $injector) {

describeErrors() {
const count = this.softErrorCount();
return `${count} Error${count === 1 ? '' : 's'}`;
return i18n('common.ui.fancyForm.errorDescription',
{
defaultMessage: '{count, plural, one {# Error} other {# Errors}}',
values: { count }
});
}

$setTouched() {
Expand Down
8 changes: 6 additions & 2 deletions src/ui/public/vis/agg_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import _ from 'lodash';
import { fieldFormats } from '../registry/field_formats';
import { i18n } from '@kbn/i18n';

class AggConfig {

Expand Down Expand Up @@ -265,8 +266,11 @@ class AggConfig {
}

if (!this.type) return '';
let pre = percentageMode ? 'Percentage of ' : '';
return pre += this.type.makeLabel(this);
return percentageMode ?
i18n.translate('common.ui.vis.aggConfig.percentageOfLabel', {
defaultMessage: 'Percentage of {label}',
values: { label: this.type.makeLabel(this) },
}) : `${this.type.makeLabel(this)}`;
}

getIndexPattern() {
Expand Down
10 changes: 8 additions & 2 deletions src/ui/public/vis/default_feedback_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
* under the License.
*/

export const defaultFeedbackMessage = `Have feedback? Please create an issue in
<a href="https://github.com/elastic/kibana/issues/new" rel="noopener noreferrer" target="_blank">GitHub</a>.`;
import { i18n } from '@kbn/i18n';

export const defaultFeedbackMessage = i18n.translate('common.ui.vis.defaultFeedbackMessage',
{
defaultMessage: 'Have feedback? Please create an issue in {link}.',
values: { link: '<a href="https://github.com/elastic/kibana/issues/new" rel="noopener noreferrer" target="_blank">GitHub</a>' }
}
);
6 changes: 5 additions & 1 deletion src/ui/public/vis/editors/default/advanced_toggle.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div class="eui-textRight">
<a ng-click="advancedToggled = !advancedToggled">
<i aria-hidden="true" class="fa fa-caret-down" ng-class="{'fa-caret-down': advancedToggled, 'fa-caret-left': !advancedToggled}"></i>
Advanced
<span
pavel06081991 marked this conversation as resolved.
Show resolved Hide resolved
i18n-id="common.ui.vis.editors.advancedToggle.advancedLinkLabel"
i18n-default-message="Advanced"
>
</span>
</a>
</div>
23 changes: 12 additions & 11 deletions src/ui/public/vis/editors/default/agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<!-- open/close editor -->
<button
aria-label="Toggle {{agg.schema.title}} editor"
aria-label="{{::'common.ui.vis.editors.agg.toggleEditorButtonAriaLabel' | i18n: { defaultMessage: 'Toggle {schema} editor', values: { schema: agg.schema.title } } }}"
ng-click="editorOpen = !editorOpen"
aria-expanded="{{ !!editorOpen }}"
aria-controls="visAggEditorParams{{agg.id}}"
Expand Down Expand Up @@ -34,8 +34,8 @@
<button
ng-if="agg.enabled && canRemove(agg)"
ng-click="agg.enabled = false"
aria-label="Disable aggregation"
tooltip="Disable aggregation"
aria-label="{{::'common.ui.vis.editors.agg.disableAggButtonAriaLabel' | i18n: { defaultMessage: 'Disable aggregation' } }}"
tooltip="{{::'common.ui.vis.editors.agg.disableAggButtonTooltip' | i18n: { defaultMessage: 'Disable aggregation' } }}"
tooltip-append-to-body="true"
data-test-subj="disableAggregationBtn"
type="button"
Expand All @@ -47,8 +47,8 @@
<button
ng-if="!agg.enabled"
ng-click="agg.enabled = true"
aria-label="Enable aggregation"
tooltip="Enable aggregation"
aria-label="{{::'common.ui.vis.editors.agg.enableAggButtonAriaLabel' | i18n: { defaultMessage: 'Enable aggregation' } }}"
tooltip="{{::'common.ui.vis.editors.agg.enableAggButtonTooltip' | i18n: { defaultMessage: 'Enable aggregation' } }}"
tooltip-append-to-body="true"
data-test-subj="disableAggregationBtn"
type="button"
Expand All @@ -60,25 +60,26 @@
<button
draggable-handle
ng-if="stats.count > 1"
tooltip="Modify Priority by Dragging"
tooltip="{{::'common.ui.vis.editors.agg.modifyPriorityButtonTooltip' | i18n: { defaultMessage: 'Modify Priority by Dragging' } }}"
tooltip-append-to-body="true"
type="button"
keyboard-move="onPriorityReorder(direction)"
class="kuiButton kuiButton--basic kuiButton--small">
<i aria-hidden="true" class="fa fa-arrows-v"></i>
<span class="kuiScreenReaderOnly">
Use up and down key on this button to move this aggregation up and down
in the priority order.
<span class="kuiScreenReaderOnly"
i18n-id="common.ui.vis.editors.howToModifyScreenReaderPriorityDescription"
i18n-default-message="Use up and down key on this button to move this aggregation up and down in the priority order."
>
</span>
</button>

<!-- remove button -->
<button
ng-if="canRemove(agg)"
aria-label="Remove Dimension"
aria-label="{{::'common.ui.vis.editors.agg.removeDimensionButtonAriaLabel' | i18n: { defaultMessage: 'Remove Dimension' } }}"
ng-if="stats.count > stats.min"
ng-click="remove(agg)"
tooltip="Remove Dimension"
tooltip="{{::'common.ui.vis.editors.agg.removeDimensionButtonTooltip' | i18n: { defaultMessage: 'Remove Dimension' } }}"
tooltip-append-to-body="true"
type="button"
class="kuiButton kuiButton--danger kuiButton--small">
Expand Down
18 changes: 14 additions & 4 deletions src/ui/public/vis/editors/default/agg_add.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div ng-show="add.form">
<label>Select {{ groupName }} type</label>
<label
i18n-id="common.ui.vis.editors.aggAdd.selectGroupTypeLabel"
i18n-default-message="Select {groupNameLabel} type"
i18n-values="{ groupNameLabel }"
>
</label>
<ul class="form-group list-group list-group-menu">
<li
tabindex="0"
Expand Down Expand Up @@ -28,23 +33,28 @@
data-test-subj="visualizeEditorAddAggregationButton"
class="kuiButton kuiButton--secondary kuiButton--small"
ng-if="groupName !== 'buckets' || !stats.count && !stats.deprecate"
i18n-id="common.ui.vis.editors.aggAdd.addGroupButtonLabel"
i18n-default-message="Add {groupNameLabel}"
i18n-values="{ groupNameLabel }"
>
Add {{ groupName }}
</button>

<button
data-test-subj="visualizeEditorAddAggregationButton"
class="kuiButton kuiButton--secondary kuiButton--small"
ng-if="groupName === 'buckets' && stats.count > 0 && !stats.deprecate"
i18n-id="common.ui.vis.editors.aggAdd.addSubGroupButtonLabel"
i18n-default-message="Add sub-{groupNameLabel}"
i18n-values="{ groupNameLabel }"
>
Add sub-{{ groupName }}
</button>
</div>

<button
class="kuiButton kuiButton--danger kuiButton--small"
ng-if="add.form"
i18n-id="common.ui.vis.editors.aggAdd.cancelButtonLabel"
i18n-default-message="Cancel"
>
Cancel
</button>
</div>
2 changes: 1 addition & 1 deletion src/ui/public/vis/editors/default/agg_group.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="sidebar-item visEditorAggGroup__wrapper">
<div class="sidebar-item-title visEditorAggGroup__title">
{{ groupName }}
{{ groupNameLabel }}
</div>

<div ng-class="groupName" draggable-container="group" class="visEditorAggGroup">
Expand Down
2 changes: 2 additions & 0 deletions src/ui/public/vis/editors/default/agg_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import './agg_add';
import { uiModules } from '../../../modules';
import aggGroupTemplate from './agg_group.html';
import { move } from '../../../utils/collection';
import { aggGroupNameMaps } from './agg_group_names';

uiModules
.get('app/visualize')
Expand All @@ -35,6 +36,7 @@ uiModules
scope: true,
link: function ($scope, $el, attr) {
$scope.groupName = attr.groupName;
$scope.groupNameLabel = aggGroupNameMaps()[$scope.groupName];
$scope.$bind('group', 'state.aggs.bySchemaGroup["' + $scope.groupName + '"]');
$scope.$bind('schemas', 'vis.type.schemas["' + $scope.groupName + '"]');

Expand Down
25 changes: 25 additions & 0 deletions src/ui/public/vis/editors/default/agg_group_names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.
*/

import { i18n } from '@kbn/i18n';

export const aggGroupNameMaps = () => ({
metrics: i18n.translate('common.ui.vis.editors.aggGroups.metricsText', { defaultMessage: 'metrics' }),
buckets: i18n.translate('common.ui.vis.editors.aggGroups.bucketsText', { defaultMessage: 'buckets' })
});
16 changes: 12 additions & 4 deletions src/ui/public/vis/editors/default/agg_params.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div ng-if="aggIsTooLow" class="form-group">
<p class="visEditorAggParam__error">
"{{ agg.schema.title }}" aggs must run before all other buckets!
<p class="visEditorAggParam__error"
i18n-id="common.ui.vis.editors.aggParams.errors.aggWrongRunOrderErrorMessage"
i18n-default-message="&quot;{schema}&quot; aggs must run before all other buckets!"
i18n-values="{ schema: agg.schema.title }"
>
</p>
<input
type="number"
Expand All @@ -20,8 +23,13 @@
<p ng-show="agg.schema.deprecateMessage" class="visEditorAggParam__error">
{{ agg.schema.deprecateMessage }}
</p>
<p ng-show="!agg.schema.deprecateMessage" class="visEditorAggParam__error">
"{{ agg.schema.title }}" has been deprecated.
<p
ng-show="!agg.schema.deprecateMessage"
class="visEditorAggParam__error"
i18n-id="common.ui.vis.editors.aggParams.errors.schemaIsDeprecatedErrorMessage"
i18n-default-message="&quot;{schema}&quot; has been deprecated."
i18n-values="{ schema: agg.schema.title }"
>
</p>
</div>

Expand Down
22 changes: 18 additions & 4 deletions src/ui/public/vis/editors/default/agg_select.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<div class="form-group">
<div>
<label ng-if="$index < 1 || groupName !== 'buckets'" class="eui-displayInline">Aggregation</label>
<label ng-if="$index >= 1 && groupName === 'buckets'" class="eui-displayInline">Sub Aggregation</label>
<label
ng-if="$index < 1 || groupName !== 'buckets'"
class="eui-displayInline"
i18n-id="common.ui.vis.editors.aggSelect.aggregationLabel"
i18n-default-message="Aggregation"
>
</label>
<label
ng-if="$index >= 1 && groupName === 'buckets'"
class="eui-displayInline"
i18n-id="common.ui.vis.editors.aggSelect.subAggregationLabel"
i18n-default-message="Sub Aggregation"
>
</label>
<a
ng-if="aggHelpLink"
href="{{aggHelpLink}}"
class="pull-right"
target="_blank"
rel="noopener noreferrer"
i18n-id="common.ui.vis.editors.aggSelect.helpLinkLabel"
i18n-default-message="{aggTitle} help"
i18n-values="{ aggTitle: agg.type.title }"
>
{{agg.type.title}} help
</a>
</div>
<div class="euiSpacer euiSpacer--s"></div>
Expand All @@ -20,7 +34,7 @@
data-test-subj="visEditorAggSelect"
ng-model="agg.type"
>
<ui-select-match placeholder="Select an aggregation">
<ui-select-match placeholder="{{ ::'common.ui.vis.editors.aggSelect.selectAggPlaceholder' | i18n: { defaultMessage: 'Select an aggregation' } }}">
{{$select.selected.title}}
</ui-select-match>
<ui-select-choices
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vis/editors/default/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<vis-editor-resizer
class="visEditor__resizer"
tabindex="0"
aria-label="Press left/right to resize the editor"
aria-label="{{::'common.ui.vis.editors.resizeAriaLabels' | i18n: { defaultMessage: 'Press left/right to resize the editor' } }}"
data-test-subj="visualizeEditorResizer"
>&#xFE19;</vis-editor-resizer>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/ui/public/vis/editors/default/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { VisEditorTypesRegistryProvider } from '../../../registry/vis_editor_typ
import { getVisualizeLoader } from '../../../visualize/loader/visualize_loader';


const defaultEditor = function ($rootScope, $compile) {
const defaultEditor = function ($rootScope, $compile, i18n) {
return class DefaultEditor {
static key = 'default';

Expand All @@ -44,7 +44,11 @@ const defaultEditor = function ($rootScope, $compile) {

if (!this.vis.type.editorConfig.optionTabs && this.vis.type.editorConfig.optionsTemplate) {
this.vis.type.editorConfig.optionTabs = [
{ name: 'options', title: 'Options', editor: this.vis.type.editorConfig.optionsTemplate }
{
name: 'options',
title: i18n('common.ui.vis.editors.sidebar.tabs.optionsLabel', { defaultMessage: 'Options' }),
editor: this.vis.type.editorConfig.optionsTemplate,
}
];
}
}
Expand Down
Loading