Internationalization: Translate VariableInput and VariableOptions components (#58748)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
|
import { t } from 'app/core/internationalization';
|
||||||
|
|
||||||
import { NavigationKey } from '../types';
|
import { NavigationKey } from '../types';
|
||||||
|
|
||||||
export interface Props extends Omit<React.HTMLProps<HTMLInputElement>, 'onChange' | 'value'> {
|
export interface Props extends Omit<React.HTMLProps<HTMLInputElement>, 'onChange' | 'value'> {
|
||||||
@@ -37,7 +39,7 @@ export class VariableInput extends PureComponent<Props> {
|
|||||||
value={value ?? ''}
|
value={value ?? ''}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
placeholder="Enter variable value"
|
placeholder={t('variable.picker.input', 'Enter variable value')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import React, { FC, MouseEvent, useCallback } from 'react';
|
|||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Icon, Tooltip, useStyles2 } from '@grafana/ui';
|
import { Icon, Tooltip, useStyles2 } from '@grafana/ui';
|
||||||
|
import { t } from 'app/core/internationalization';
|
||||||
|
|
||||||
|
import { ALL_VARIABLE_TEXT } from '../../constants';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
@@ -65,7 +68,11 @@ interface VariableLinkTextProps {
|
|||||||
|
|
||||||
const VariableLinkText: FC<VariableLinkTextProps> = ({ text }) => {
|
const VariableLinkText: FC<VariableLinkTextProps> = ({ text }) => {
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
return <span className={styles.textAndTags}>{text}</span>;
|
return (
|
||||||
|
<span className={styles.textAndTags}>
|
||||||
|
{text === ALL_VARIABLE_TEXT ? t('variable.picker.link-all', 'All') : text}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const LoadingIndicator: FC<Pick<Props, 'onCancel'>> = ({ onCancel }) => {
|
const LoadingIndicator: FC<Pick<Props, 'onCancel'>> = ({ onCancel }) => {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import React, { PureComponent } from 'react';
|
|||||||
|
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Tooltip, Themeable2, withTheme2, clearButtonStyles } from '@grafana/ui';
|
import { Tooltip, Themeable2, withTheme2, clearButtonStyles } from '@grafana/ui';
|
||||||
|
import { Trans, t } from 'app/core/internationalization';
|
||||||
|
|
||||||
|
import { ALL_VARIABLE_VALUE } from '../../constants';
|
||||||
import { VariableOption } from '../../types';
|
import { VariableOption } from '../../types';
|
||||||
|
|
||||||
export interface Props extends React.HTMLProps<HTMLUListElement>, Themeable2 {
|
export interface Props extends React.HTMLProps<HTMLUListElement>, Themeable2 {
|
||||||
@@ -62,6 +64,8 @@ class VariableOptions extends PureComponent<Props> {
|
|||||||
const selectClass = option.selected ? 'variable-option pointer selected' : 'variable-option pointer';
|
const selectClass = option.selected ? 'variable-option pointer selected' : 'variable-option pointer';
|
||||||
const highlightClass = index === highlightIndex ? `${selectClass} highlighted` : selectClass;
|
const highlightClass = index === highlightIndex ? `${selectClass} highlighted` : selectClass;
|
||||||
|
|
||||||
|
const isAllOption = option.value === ALL_VARIABLE_VALUE;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={`${option.value}`}>
|
<li key={`${option.value}`}>
|
||||||
<button
|
<button
|
||||||
@@ -73,7 +77,7 @@ class VariableOptions extends PureComponent<Props> {
|
|||||||
>
|
>
|
||||||
<span className="variable-option-icon"></span>
|
<span className="variable-option-icon"></span>
|
||||||
<span data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(`${option.text}`)}>
|
<span data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(`${option.text}`)}>
|
||||||
{option.text}
|
{isAllOption ? t('variable.picker.option-all', 'All') : option.text}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
@@ -87,8 +91,10 @@ class VariableOptions extends PureComponent<Props> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tooltipContent = () => <Trans i18nKey="variable.picker.option-tooltip">Clear selections</Trans>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip content={'Clear selections'} placement={'top'}>
|
<Tooltip content={tooltipContent} placement={'top'}>
|
||||||
<button
|
<button
|
||||||
className={`${
|
className={`${
|
||||||
selectedValues.length > 1
|
selectedValues.length > 1
|
||||||
@@ -102,7 +108,7 @@ class VariableOptions extends PureComponent<Props> {
|
|||||||
data-placement="top"
|
data-placement="top"
|
||||||
>
|
>
|
||||||
<span className="variable-option-icon"></span>
|
<span className="variable-option-icon"></span>
|
||||||
Selected ({selectedValues.length})
|
<Trans i18nKey="variable.picker.option-selected-values">Selected</Trans> ({selectedValues.length})
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "Sitzungen werden geladen …"
|
"loading": "Sitzungen werden geladen …"
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "",
|
||||||
|
"link-all": "",
|
||||||
|
"option-all": "",
|
||||||
|
"option-selected-values": "",
|
||||||
|
"option-tooltip": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "Loading sessions..."
|
"loading": "Loading sessions..."
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "Enter variable value",
|
||||||
|
"link-all": "All",
|
||||||
|
"option-all": "All",
|
||||||
|
"option-selected-values": "Selected",
|
||||||
|
"option-tooltip": "Clear selections"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "Cargando sesiones..."
|
"loading": "Cargando sesiones..."
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "",
|
||||||
|
"link-all": "",
|
||||||
|
"option-all": "",
|
||||||
|
"option-selected-values": "",
|
||||||
|
"option-tooltip": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "Chargement des sessions..."
|
"loading": "Chargement des sessions..."
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "",
|
||||||
|
"link-all": "",
|
||||||
|
"option-all": "",
|
||||||
|
"option-selected-values": "",
|
||||||
|
"option-tooltip": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "Ŀőäđįʼnģ şęşşįőʼnş..."
|
"loading": "Ŀőäđįʼnģ şęşşįőʼnş..."
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "Ēʼnŧęř väřįäþľę väľūę",
|
||||||
|
"link-all": "Åľľ",
|
||||||
|
"option-all": "Åľľ",
|
||||||
|
"option-selected-values": "Ŝęľęčŧęđ",
|
||||||
|
"option-tooltip": "Cľęäř şęľęčŧįőʼnş"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,5 +492,14 @@
|
|||||||
},
|
},
|
||||||
"user-sessions": {
|
"user-sessions": {
|
||||||
"loading": "正在加载会话..."
|
"loading": "正在加载会话..."
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"picker": {
|
||||||
|
"input": "",
|
||||||
|
"link-all": "",
|
||||||
|
"option-all": "",
|
||||||
|
"option-selected-values": "",
|
||||||
|
"option-tooltip": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user