I18n: Mark up explore/table for translations (#74368)

* added Internationalization to table container

* reduce level for label of explore table

* lint

* restore translations

* refactor getTableTitle logic to not require duplicate t phrases

* Update public/app/features/explore/Table/TableContainer.tsx

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

---------

Co-authored-by: Deepali Gupta <90255953+Deepali1211@users.noreply.github.com>
Co-authored-by: joshhunt <josh@trtr.co>
Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
michiboo
2023-09-28 12:51:37 +03:00
committed by GitHub
co-authored by Piotr Jamróz Deepali Gupta joshhunt Josh Hunt
parent f9edaa5d78
commit bfdcfa8cc3
7 changed files with 38 additions and 6 deletions
@@ -5,6 +5,7 @@ import { applyFieldOverrides, TimeZone, SplitOpen, DataFrame, LoadingState, Fiel
import { getTemplateSrv } from '@grafana/runtime'; import { getTemplateSrv } from '@grafana/runtime';
import { Table, AdHocFilterItem, PanelChrome } from '@grafana/ui'; import { Table, AdHocFilterItem, PanelChrome } from '@grafana/ui';
import { config } from 'app/core/config'; import { config } from 'app/core/config';
import { t } from 'app/core/internationalization';
import { import {
hasDeprecatedParentRowIndex, hasDeprecatedParentRowIndex,
migrateFromParentRowIndexToNestedFrames, migrateFromParentRowIndexToNestedFrames,
@@ -51,11 +52,12 @@ export class TableContainer extends PureComponent<Props> {
} }
getTableTitle(dataFrames: DataFrame[] | null, data: DataFrame, i: number) { getTableTitle(dataFrames: DataFrame[] | null, data: DataFrame, i: number) {
let title = data.name ? `Table - ${data.name}` : 'Table'; let name = data.name;
if (dataFrames && dataFrames.length > 1) { if (!name && (dataFrames?.length ?? 0) > 1) {
title = `Table - ${data.name || data.refId || i}`; name = data.refId || `${i}`;
} }
return title;
return name ? t('explore.table.title-with-name', 'Table - {{name}}', { name }) : t('explore.table.title', 'Table');
} }
render() { render() {
@@ -87,8 +89,8 @@ export class TableContainer extends PureComponent<Props> {
return ( return (
<> <>
{frames && frames.length === 0 && ( {frames && frames.length === 0 && (
<PanelChrome title={'Table'} width={width} height={200}> <PanelChrome title={t('explore.table.title', 'Table')} width={width} height={200}>
{() => <MetaInfoText metaItems={[{ value: '0 series returned' }]} />} {() => <MetaInfoText metaItems={[{ value: t('explore.table.no-data', '0 series returned') }]} />}
</PanelChrome> </PanelChrome>
)} )}
{frames && {frames &&
+5
View File
@@ -225,6 +225,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "", "add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": { "toolbar": {
"aria-label": "", "aria-label": "",
"copy-shortened-link": "", "copy-shortened-link": "",
+5
View File
@@ -225,6 +225,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "Add to dashboard", "add-to-dashboard": "Add to dashboard",
"table": {
"no-data": "0 series returned",
"title": "Table",
"title-with-name": "Table - {{name}}"
},
"toolbar": { "toolbar": {
"aria-label": "Explore toolbar", "aria-label": "Explore toolbar",
"copy-shortened-link": "Copy shortened link", "copy-shortened-link": "Copy shortened link",
+5
View File
@@ -230,6 +230,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "", "add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": { "toolbar": {
"aria-label": "", "aria-label": "",
"copy-shortened-link": "", "copy-shortened-link": "",
+5
View File
@@ -230,6 +230,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "", "add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": { "toolbar": {
"aria-label": "", "aria-label": "",
"copy-shortened-link": "", "copy-shortened-link": "",
@@ -225,6 +225,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "Åđđ ŧő đäşĥþőäřđ", "add-to-dashboard": "Åđđ ŧő đäşĥþőäřđ",
"table": {
"no-data": "0 şęřįęş řęŧūřʼnęđ",
"title": "Ŧäþľę",
"title-with-name": "Ŧäþľę - {{name}}"
},
"toolbar": { "toolbar": {
"aria-label": "Ēχpľőřę ŧőőľþäř", "aria-label": "Ēχpľőřę ŧőőľþäř",
"copy-shortened-link": "Cőpy şĥőřŧęʼnęđ ľįʼnĸ", "copy-shortened-link": "Cőpy şĥőřŧęʼnęđ ľįʼnĸ",
+5
View File
@@ -220,6 +220,11 @@
}, },
"explore": { "explore": {
"add-to-dashboard": "", "add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": { "toolbar": {
"aria-label": "", "aria-label": "",
"copy-shortened-link": "", "copy-shortened-link": "",