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 11:51:37 +02:00 committed by GitHub
parent f9edaa5d78
commit bfdcfa8cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import { applyFieldOverrides, TimeZone, SplitOpen, DataFrame, LoadingState, Fiel
import { getTemplateSrv } from '@grafana/runtime';
import { Table, AdHocFilterItem, PanelChrome } from '@grafana/ui';
import { config } from 'app/core/config';
import { t } from 'app/core/internationalization';
import {
hasDeprecatedParentRowIndex,
migrateFromParentRowIndexToNestedFrames,
@ -51,11 +52,12 @@ export class TableContainer extends PureComponent<Props> {
}
getTableTitle(dataFrames: DataFrame[] | null, data: DataFrame, i: number) {
let title = data.name ? `Table - ${data.name}` : 'Table';
if (dataFrames && dataFrames.length > 1) {
title = `Table - ${data.name || data.refId || i}`;
let name = data.name;
if (!name && (dataFrames?.length ?? 0) > 1) {
name = data.refId || `${i}`;
}
return title;
return name ? t('explore.table.title-with-name', 'Table - {{name}}', { name }) : t('explore.table.title', 'Table');
}
render() {
@ -87,8 +89,8 @@ export class TableContainer extends PureComponent<Props> {
return (
<>
{frames && frames.length === 0 && (
<PanelChrome title={'Table'} width={width} height={200}>
{() => <MetaInfoText metaItems={[{ value: '0 series returned' }]} />}
<PanelChrome title={t('explore.table.title', 'Table')} width={width} height={200}>
{() => <MetaInfoText metaItems={[{ value: t('explore.table.no-data', '0 series returned') }]} />}
</PanelChrome>
)}
{frames &&

View File

@ -225,6 +225,11 @@
},
"explore": {
"add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": {
"aria-label": "",
"copy-shortened-link": "",

View File

@ -225,6 +225,11 @@
},
"explore": {
"add-to-dashboard": "Add to dashboard",
"table": {
"no-data": "0 series returned",
"title": "Table",
"title-with-name": "Table - {{name}}"
},
"toolbar": {
"aria-label": "Explore toolbar",
"copy-shortened-link": "Copy shortened link",

View File

@ -230,6 +230,11 @@
},
"explore": {
"add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": {
"aria-label": "",
"copy-shortened-link": "",

View File

@ -230,6 +230,11 @@
},
"explore": {
"add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": {
"aria-label": "",
"copy-shortened-link": "",

View File

@ -225,6 +225,11 @@
},
"explore": {
"add-to-dashboard": "Åđđ ŧő đäşĥþőäřđ",
"table": {
"no-data": "0 şęřįęş řęŧūřʼnęđ",
"title": "Ŧäþľę",
"title-with-name": "Ŧäþľę - {{name}}"
},
"toolbar": {
"aria-label": "Ēχpľőřę ŧőőľþäř",
"copy-shortened-link": "Cőpy şĥőřŧęʼnęđ ľįʼnĸ",

View File

@ -220,6 +220,11 @@
},
"explore": {
"add-to-dashboard": "",
"table": {
"no-data": "",
"title": "",
"title-with-name": ""
},
"toolbar": {
"aria-label": "",
"copy-shortened-link": "",