From 813ebf988d354bf23e981e00c9c8458995774c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Thu, 3 Nov 2022 16:03:28 +0100 Subject: [PATCH] Internationalization: Translate TimePickerTitle component (#57909) --- contribute/internationalization.md | 2 +- .../RelativeTimeRangePicker.tsx | 7 +++++-- .../TimeRangePicker/CalendarHeader.tsx | 5 ++++- public/locales/de-DE/grafana.json | 7 +++++++ public/locales/en-US/grafana.json | 7 +++++++ public/locales/es-ES/grafana.json | 7 +++++++ public/locales/fr-FR/grafana.json | 15 +++++++++++---- public/locales/pseudo-LOCALE/grafana.json | 7 +++++++ public/locales/zh-Hans/grafana.json | 7 +++++++ 9 files changed, 56 insertions(+), 8 deletions(-) diff --git a/contribute/internationalization.md b/contribute/internationalization.md index 9f0aa1bba75..900573d5bc8 100644 --- a/contribute/internationalization.md +++ b/contribute/internationalization.md @@ -30,7 +30,7 @@ const SearchTitle = ({ term }) => ( Prefer using `` for JSX children, and `t()` for props and other javascript usage. -When translating in grafana-ui, import `` and `t()` from `src/utils/i18n`. +When translating in grafana-ui, use a relative path to import `` and `t()` from `src/utils/i18n`. Note that our tooling must be able to statically analyse the code to extract the phrase, so the `i18nKey` can not be dynamic. e.g. the following will not work: diff --git a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx index 37af429b70d..77c08d13510 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx @@ -4,6 +4,7 @@ import React, { FormEvent, useCallback, useState } from 'react'; import { RelativeTimeRange, GrafanaTheme2, TimeOption } from '@grafana/data'; import { useStyles2 } from '../../../themes'; +import { Trans, t } from '../../../utils/i18n'; import { Button } from '../../Button'; import { ClickOutsideWrapper } from '../../ClickOutsideWrapper/ClickOutsideWrapper'; import CustomScrollbar from '../../CustomScrollbar/CustomScrollbar'; @@ -111,7 +112,7 @@ export function RelativeTimeRangePicker(props: RelativeTimeRangePickerProps) {
} placement="bottom" theme="info">
- Specify time range + + Specify time range +
diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/CalendarHeader.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/CalendarHeader.tsx index e8ea6d9a0cf..08782cbd493 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/CalendarHeader.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker/CalendarHeader.tsx @@ -5,6 +5,7 @@ import { GrafanaTheme2 } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { useStyles2 } from '../../../themes'; +import { Trans } from '../../../utils/i18n'; import { Button } from '../../Button'; import { TimePickerCalendarProps } from './TimePickerCalendar'; @@ -15,7 +16,9 @@ export function Header({ onClose }: TimePickerCalendarProps) { return (
- Select a time range + + Select a time range +