From f795d6cde95ec0e12c6bc929257c63f675c1fb84 Mon Sep 17 00:00:00 2001 From: VWSCoronaDashboard22 <93981265+VWSCoronaDashboard22@users.noreply.github.com> Date: Mon, 28 Mar 2022 15:46:13 +0200 Subject: [PATCH] Split lokalize texts into common and pages (#4119) * Split lokalize texts into common and pages * Fixed some type issues * More type fixes * Fixed repeating_shot_information_block * Merge branch 'develop' into feature/split-lokalize-text * Fixed types and references * Corrected references * Moved lokalize texts * Renamed some variables for consistency * Fixed text replace vars --- .../app/src/components/article-detail.tsx | 15 +- .../app/src/components/article-teaser.tsx | 4 +- .../components/breadcrumbs/breadcrumbs.tsx | 4 +- .../breadcrumbs/logic/use-breadcrumbs.tsx | 20 +- .../src/components/chart-region-controls.tsx | 24 +- .../src/components/chart-time-controls.tsx | 10 +- .../components/canvas-choropleth-map.tsx | 4 + .../choropleth/components/choropleth-map.tsx | 1 + .../app/src/components/choropleth/index.tsx | 6 +- .../tooltips/choropleth-tooltip.tsx | 4 +- .../components/cms/inline-age-demographic.tsx | 6 +- .../src/components/cms/inline-choropleth.tsx | 12 +- .../src/components/cms/inline-donut-chart.tsx | 10 +- .../app/src/components/cms/inline-kpi.tsx | 6 +- .../cms/inline-time-series-charts.tsx | 26 +- .../src/components/combo-box/combo-box.tsx | 4 +- .../app/src/components/content-teaser.tsx | 7 +- .../data-driven-text/components/metric.tsx | 4 +- .../inline-difference.tsx | 4 +- .../tile-average-difference.tsx | 4 +- .../difference-indicator/tile-difference.tsx | 4 +- .../app/src/components/editorial-detail.tsx | 4 +- .../src/components/error-boundary/index.tsx | 21 +- .../src/components/fullscreen-chart-tile.tsx | 8 +- .../app/src/components/interactive-legend.tsx | 4 +- .../app/src/components/layout/app-content.tsx | 6 +- .../app/src/components/layout/app-footer.tsx | 2 +- .../app/src/components/layout/app-header.tsx | 4 +- .../src/components/layout/components/logo.tsx | 6 +- .../layout/components/top-navigation.tsx | 20 +- packages/app/src/components/loader/loader.tsx | 76 +- .../app/src/components/lokalize-metadata.tsx | 4 +- packages/app/src/components/metadata.tsx | 26 +- .../components/articles.tsx | 4 +- .../components/metadata.tsx | 18 +- .../components/page-links.tsx | 6 +- .../page-information-block.tsx | 6 +- .../rich-content-select.tsx | 4 +- packages/app/src/components/search-input.tsx | 4 +- packages/app/src/components/seo-head.tsx | 8 +- .../components/sitemap/use-data-sitemap.ts | 91 +- .../timeline/components/tooltip-content.tsx | 12 +- .../components/timeline/timeline.tsx | 4 +- .../components/week-numbers.tsx | 6 +- .../time-series-chart/logic/legend.tsx | 6 +- .../time-series-chart/time-series-chart.tsx | 4 +- .../vaccination-coverage-choropleth.tsx | 31 +- .../behavior/behavior-choropleths-tile.tsx | 23 +- .../behavior/behavior-line-chart-tile.tsx | 30 +- .../behavior/behavior-per-age-group-tile.tsx | 18 +- .../domain/behavior/behavior-table-tile.tsx | 13 +- .../behavior/components/behavior-trend.tsx | 14 +- .../behavior/components/more-information.tsx | 19 +- .../behavior/components/select-behavior.tsx | 4 +- .../logic/use-behavior-lookup-keys.ts | 6 +- .../behavior/tooltip/vr-behavior-tooltip.tsx | 12 +- .../escalation-level-banner.tsx | 4 +- .../escalation-level-label.tsx | 8 +- .../admissions-per-age-group.tsx | 13 +- .../components/narrow-infected-table.tsx | 20 +- .../components/wide-infected-table.tsx | 14 +- .../infected-table-tile.tsx | 28 +- .../mult-select-countries-input.tsx | 8 +- .../multi-select-country-results.tsx | 17 +- .../select-country/select-country-input.tsx | 6 +- .../select-country/select-country.tsx | 6 +- .../domain/layout/components/gm-combo-box.tsx | 4 +- .../domain/layout/components/vr-combo-box.tsx | 4 +- packages/app/src/domain/layout/gm-layout.tsx | 10 +- packages/app/src/domain/layout/in-layout.tsx | 4 +- packages/app/src/domain/layout/layout.tsx | 24 +- .../src/domain/layout/logic/use-sidebar.tsx | 8 +- packages/app/src/domain/layout/nl-layout.tsx | 10 +- packages/app/src/domain/layout/vr-layout.tsx | 8 +- .../components/location-tooltip.tsx | 4 +- .../domain/sewer/sewer-chart/sewer-chart.tsx | 4 +- ...tuations-data-coverage-choropleth-tile.tsx | 2 +- .../situations/situations-over-time-chart.tsx | 4 +- .../domain/tested/g-number-bar-chart-tile.tsx | 4 +- .../infected-per-age-group.tsx | 29 +- .../app/src/domain/topical/article-list.tsx | 5 +- .../topical/components/search/context.tsx | 4 +- .../topical/components/search/hit-list.tsx | 16 +- .../components/search/search-input.tsx | 8 +- .../src/domain/topical/highlights-tile.tsx | 5 + .../topical/mini-tile-selector-layout.tsx | 15 +- .../domain/topical/topical-section-header.tsx | 18 +- .../components/narrow-coverage-table.tsx | 8 +- .../components/wide-coverage-table.tsx | 12 +- .../vaccine/components/age-group-select.tsx | 19 +- .../vaccination-coverage-kind-select.tsx | 12 +- .../vaccine/logic/use-agegroup-labels.ts | 4 +- ...e-vaccine-coverage-percentage-formatter.ts | 10 +- .../vaccine/vaccinations-over-time-chart.tsx | 16 +- .../vaccine/vaccinations-over-time-tile.tsx | 23 +- .../vaccinations-third-shot-kpi-section.tsx | 39 + .../vaccine-administrations-kpi-section.tsx | 21 +- ...ne-booster-administrations-kpi-section.tsx | 7 +- .../vaccine-coverage-choropleth-per-gm.tsx | 32 +- .../components/narrow-coverage-table.tsx | 13 +- .../components/wide-coverage-table.tsx | 14 +- .../vaccine-coverage-per-age-group.tsx | 7 +- .../vaccine/vaccine-coverage-toggle-tile.tsx | 16 +- .../vaccine/vaccine-delivery-bar-chart.tsx | 21 +- .../vaccine-stock-per-supplier-chart.tsx | 40 +- .../static-props/get-variant-chart-data.ts | 2 +- .../domain/variants/variants-over-time.tsx | 21 +- .../variants-stacked-area-tile.tsx | 15 +- .../components/narrow-variants-table.tsx | 8 +- .../components/no-percentage-data.tsx | 9 +- .../components/variant-difference.tsx | 18 +- .../components/variant-name-cell.tsx | 5 +- .../components/wide-variants-table.tsx | 3 +- .../logic/use-variant-name-and-description.ts | 52 +- .../variants/variants-table-tile/types.ts | 115 +++ packages/app/src/intl/hooks/use-intl.ts | 8 +- packages/app/src/pages/404.tsx | 8 +- packages/app/src/pages/500.tsx | 8 +- packages/app/src/pages/_app.tsx | 2 +- packages/app/src/pages/_error.tsx | 10 +- .../app/src/pages/actueel/gemeente/[code].tsx | 23 +- .../app/src/pages/actueel/gemeente/index.tsx | 23 +- .../pages/actueel/veiligheidsregio/[code].tsx | 23 +- .../pages/actueel/veiligheidsregio/index.tsx | 27 +- packages/app/src/pages/artikelen/[slug].tsx | 16 +- packages/app/src/pages/artikelen/index.tsx | 17 +- packages/app/src/pages/contact.tsx | 4 +- .../app/src/pages/gemeente/[code]/index.tsx | 7 +- .../[code]/positief-geteste-mensen.tsx | 10 +- .../src/pages/gemeente/[code]/rioolwater.tsx | 16 +- .../app/src/pages/gemeente/[code]/sterfte.tsx | 6 +- .../src/pages/gemeente/[code]/vaccinaties.tsx | 32 +- .../gemeente/[code]/ziekenhuis-opnames.tsx | 10 +- packages/app/src/pages/gemeente/index.tsx | 10 +- packages/app/src/pages/index.tsx | 43 +- .../app/src/pages/internationaal/index.tsx | 4 +- .../positief-geteste-mensen.tsx | 45 +- .../src/pages/internationaal/varianten.tsx | 63 +- .../pages/landelijk/besmettelijke-mensen.tsx | 11 +- .../app/src/pages/landelijk/brononderzoek.tsx | 21 +- .../app/src/pages/landelijk/coronamelder.tsx | 29 +- packages/app/src/pages/landelijk/gedrag.tsx | 65 +- .../src/pages/landelijk/gehandicaptenzorg.tsx | 20 +- packages/app/src/pages/landelijk/index.tsx | 26 +- .../landelijk/intensive-care-opnames.tsx | 15 +- .../app/src/pages/landelijk/maatregelen.tsx | 11 +- .../landelijk/positief-geteste-mensen.tsx | 14 +- .../src/pages/landelijk/reproductiegetal.tsx | 11 +- .../app/src/pages/landelijk/rioolwater.tsx | 26 +- packages/app/src/pages/landelijk/sterfte.tsx | 9 +- .../pages/landelijk/thuiswonende-ouderen.tsx | 15 +- .../app/src/pages/landelijk/vaccinaties.tsx | 32 +- .../app/src/pages/landelijk/varianten.tsx | 22 +- .../landelijk/verdenkingen-huisartsen.tsx | 28 +- .../src/pages/landelijk/verpleeghuiszorg.tsx | 11 +- .../pages/landelijk/ziekenhuis-opnames.tsx | 33 +- packages/app/src/pages/over-risiconiveaus.tsx | 6 +- packages/app/src/pages/over.tsx | 4 +- packages/app/src/pages/toegankelijkheid.tsx | 4 +- .../app/src/pages/veelgestelde-vragen.tsx | 4 +- .../veiligheidsregio/[code]/brononderzoek.tsx | 24 +- .../pages/veiligheidsregio/[code]/gedrag.tsx | 50 +- .../[code]/gehandicaptenzorg.tsx | 12 +- .../pages/veiligheidsregio/[code]/index.tsx | 4 +- .../veiligheidsregio/[code]/maatregelen.tsx | 4 +- .../[code]/positief-geteste-mensen.tsx | 10 +- .../veiligheidsregio/[code]/rioolwater.tsx | 14 +- .../pages/veiligheidsregio/[code]/sterfte.tsx | 10 +- .../[code]/thuiswonende-ouderen.tsx | 12 +- .../veiligheidsregio/[code]/vaccinaties.tsx | 36 +- .../[code]/verpleeghuiszorg.tsx | 8 +- .../[code]/ziekenhuis-opnames.tsx | 10 +- .../app/src/pages/veiligheidsregio/index.tsx | 12 +- packages/app/src/pages/verantwoording.tsx | 7 +- .../use-accessibility-features.spec.tsx | 4 +- .../__tests__/use-format-date-range.spec.tsx | 4 +- .../utils/use-accessibility-annotations.tsx | 12 +- .../app/src/utils/use-escalation-level.tsx | 6 +- packages/app/src/utils/use-scoped-warning.ts | 4 +- packages/cms/src/lokalize/key-mutations.csv | 877 ++++++++++++++++++ 180 files changed, 2391 insertions(+), 1140 deletions(-) create mode 100644 packages/app/src/domain/vaccine/vaccinations-third-shot-kpi-section.tsx diff --git a/packages/app/src/components/article-detail.tsx b/packages/app/src/components/article-detail.tsx index 89f64a9156..92890c8885 100644 --- a/packages/app/src/components/article-detail.tsx +++ b/packages/app/src/components/article-detail.tsx @@ -6,6 +6,7 @@ import { ContentBlock } from '~/components/cms/content-block'; import { Heading, InlineText } from '~/components/typography'; import { ArticleCategoryType } from '~/domain/topical/common/categories'; import { useIntl } from '~/intl'; +import { SiteText } from '~/locale'; import { Article } from '~/types/cms'; import { Link } from '~/utils/link'; import { mergeAdjacentKpiBlocks } from '~/utils/merge-adjacent-kpi-blocks'; @@ -15,6 +16,7 @@ import { LinkWithIcon } from './link-with-icon'; import { PublicationDate } from './publication-date'; interface ArticleDetailProps { article: Article; + text: SiteText['pages']['topicalPage']['shared']; } const imageSizes = [ @@ -22,8 +24,8 @@ const imageSizes = [ [700, 636], ]; -export function ArticleDetail({ article }: ArticleDetailProps) { - const { siteText } = useIntl(); +export function ArticleDetail({ article, text }: ArticleDetailProps) { + const { commonTexts } = useIntl(); article.intro = mergeAdjacentKpiBlocks(article.intro); article.content = mergeAdjacentKpiBlocks(article.content); @@ -32,7 +34,7 @@ export function ArticleDetail({ article }: ArticleDetailProps) { }> - {siteText.article_detail.back_link.text} + {commonTexts.article_detail.back_link.text} @@ -72,7 +74,7 @@ export function ArticleDetail({ article }: ArticleDetailProps) { - {siteText.pages.topicalPage.shared.secties.artikelen.tags} + {text.secties.artikelen.tags} { - siteText.pages.topicalPage.shared.secties.artikelen - .categorie_filters[item as ArticleCategoryType] + text.secties.artikelen.categorie_filters[ + item as ArticleCategoryType + ] } diff --git a/packages/app/src/components/article-teaser.tsx b/packages/app/src/components/article-teaser.tsx index 34ce62c3c4..132d1ac9d1 100644 --- a/packages/app/src/components/article-teaser.tsx +++ b/packages/app/src/components/article-teaser.tsx @@ -25,7 +25,7 @@ type ArticleTeaserProps = { export function ArticleTeaser(props: ArticleTeaserProps) { const { title, slug, summary, cover, coverSizes } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); return ( @@ -42,7 +42,7 @@ export function ArticleTeaser(props: ArticleTeaserProps) { {summary} diff --git a/packages/app/src/components/breadcrumbs/breadcrumbs.tsx b/packages/app/src/components/breadcrumbs/breadcrumbs.tsx index bc4fafd50f..20170f3be7 100644 --- a/packages/app/src/components/breadcrumbs/breadcrumbs.tsx +++ b/packages/app/src/components/breadcrumbs/breadcrumbs.tsx @@ -10,7 +10,7 @@ import { useBreadcrumbs } from './logic/use-breadcrumbs'; export function Breadcrumbs() { const breadcrumbs = useBreadcrumbs(); - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const { pathname } = useRouter(); return ( @@ -31,7 +31,7 @@ export function Breadcrumbs() { px: 4, })} as={'nav'} - aria-label={siteText.breadcrumbs.label} + aria-label={commonTexts.breadcrumbs.label} >
    {breadcrumbs.map(({ title, href, redirectLabel }, index) => ( diff --git a/packages/app/src/components/breadcrumbs/logic/use-breadcrumbs.tsx b/packages/app/src/components/breadcrumbs/logic/use-breadcrumbs.tsx index 858107d080..cc5628faaf 100644 --- a/packages/app/src/components/breadcrumbs/logic/use-breadcrumbs.tsx +++ b/packages/app/src/components/breadcrumbs/logic/use-breadcrumbs.tsx @@ -55,7 +55,7 @@ export const BreadcrumbsDataProvider = ({ export function useBreadcrumbs(): Breadcrumb[] { const { pathname, query } = useRouter(); - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const ctx = useContext(BreadcrumbsDataContext); return useMemo(() => { @@ -73,7 +73,7 @@ export function useBreadcrumbs(): Breadcrumb[] { }; const getTitle = (str: string): string => { - if (str === '') return siteText.breadcrumbs.paths.actueel; + if (str === '') return commonTexts.breadcrumbs.paths.actueel; const { key } = getQueryParameter(str); str = convertQueryParameter(str); @@ -84,8 +84,8 @@ export function useBreadcrumbs(): Breadcrumb[] { return pageTitle ? pageTitle : str; } - return siteText.breadcrumbs.paths[ - str as keyof typeof siteText.breadcrumbs.paths + return commonTexts.breadcrumbs.paths[ + str as keyof typeof commonTexts.breadcrumbs.paths ]; }; @@ -96,10 +96,10 @@ export function useBreadcrumbs(): Breadcrumb[] { case 'landelijk': case 'actueel': { return replaceVariablesInText( - siteText.breadcrumbs.redirects.template, + commonTexts.breadcrumbs.redirects.template, { - page: siteText.breadcrumbs.redirects[ - str as keyof typeof siteText.breadcrumbs.redirects + page: commonTexts.breadcrumbs.redirects[ + str as keyof typeof commonTexts.breadcrumbs.redirects ], } ); @@ -116,7 +116,7 @@ export function useBreadcrumbs(): Breadcrumb[] { // this is the more complex case where we have a str with a gm/vr code if (str.includes('GM') || str.includes('VR')) { const pageTemplate = replaceVariablesInText( - siteText.breadcrumbs.redirects[ + commonTexts.breadcrumbs.redirects[ str.includes('GM') ? 'gemeente' : 'veiligheidsregio' ], { @@ -125,7 +125,7 @@ export function useBreadcrumbs(): Breadcrumb[] { ); return replaceVariablesInText( - siteText.breadcrumbs.redirects.template, + commonTexts.breadcrumbs.redirects.template, { page: pageTemplate, } @@ -160,5 +160,5 @@ export function useBreadcrumbs(): Breadcrumb[] { }); return breadcrumbs; - }, [ctx, pathname, query, siteText]); + }, [ctx, pathname, query, commonTexts]); } diff --git a/packages/app/src/components/chart-region-controls.tsx b/packages/app/src/components/chart-region-controls.tsx index 122a417f29..c05d728ce0 100644 --- a/packages/app/src/components/chart-region-controls.tsx +++ b/packages/app/src/components/chart-region-controls.tsx @@ -10,24 +10,30 @@ interface ChartRegionControlsProps { } export function ChartRegionControls(props: ChartRegionControlsProps) { - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const { value, onChange } = props; const items: RadioGroupItem[] = [ { - label: siteText.charts.region_controls.municipal, + label: commonTexts.charts.region_controls.municipal, value: 'gm', - ariaLabel: replaceVariablesInText(siteText.aria_labels.map_toggle_label, { - label: siteText.charts.region_controls.municipal - }), + ariaLabel: replaceVariablesInText( + commonTexts.aria_labels.map_toggle_label, + { + label: commonTexts.charts.region_controls.municipal, + } + ), }, { - label: siteText.charts.region_controls.region, + label: commonTexts.charts.region_controls.region, value: 'vr', - ariaLabel: replaceVariablesInText(siteText.aria_labels.map_toggle_label, { - label: siteText.charts.region_controls.region - }), + ariaLabel: replaceVariablesInText( + commonTexts.aria_labels.map_toggle_label, + { + label: commonTexts.charts.region_controls.region, + } + ), }, ]; diff --git a/packages/app/src/components/chart-time-controls.tsx b/packages/app/src/components/chart-time-controls.tsx index 71a2d7d1fd..435a14852b 100644 --- a/packages/app/src/components/chart-time-controls.tsx +++ b/packages/app/src/components/chart-time-controls.tsx @@ -23,25 +23,25 @@ export function ChartTimeControls(props: ChartTimeControlsProps) { TimeframeOption.LAST_YEAR, ], } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const selectOptions = useMemo( () => timeframeOptions.map((key) => ({ - label: siteText.charts.time_controls[key], + label: commonTexts.charts.time_controls[key], value: key, content: ( - {siteText.charts.time_controls[key]} + {commonTexts.charts.time_controls[key]} ), })), - [siteText.charts.time_controls, timeframeOptions] + [commonTexts.charts.time_controls, timeframeOptions] ); return ( ; dataOptions: DataOptions; featureOutHandler: ChoroplethTooltipHandlers[1]; featureOverHandler: ChoroplethTooltipHandlers[0]; @@ -62,6 +64,7 @@ export const CanvasChoroplethMap = (props: CanvasChoroplethMapProps) => { anchorEventHandlers, annotations, choroplethFeatures, + containerRef, dataOptions, featureOutHandler, featureOverHandler, @@ -165,6 +168,7 @@ export const CanvasChoroplethMap = (props: CanvasChoroplethMapProps) => { handleMouseOver={handleMouseOver} />
    ( anchorEventHandlers={anchorEventHandlers} isTabInteractive={isTabInteractive} getFeatureName={getFeatureName} + containerRef={containerRef} /> )} diff --git a/packages/app/src/components/choropleth/index.tsx b/packages/app/src/components/choropleth/index.tsx index ec7c226d66..5fa6391736 100644 --- a/packages/app/src/components/choropleth/index.tsx +++ b/packages/app/src/components/choropleth/index.tsx @@ -219,7 +219,7 @@ export function Choropleth({ ...props }: ChoroplethProps) { const [tooltip, setTooltip] = useState>(); - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const tooltipRef = useRef(null); /** Close the tooltip when a click outside of the component occurs */ @@ -227,8 +227,8 @@ export function Choropleth({ const { isTabInteractive, tabInteractiveButton, anchorEventHandlers } = useTabInteractiveButton( - replaceVariablesInText(siteText.choropleth.a11y.tab_navigatie_button, { - subject: siteText.choropleth[props.map].plural, + replaceVariablesInText(commonTexts.choropleth.a11y.tab_navigatie_button, { + subject: commonTexts.choropleth[props.map].plural, }) ); diff --git a/packages/app/src/components/choropleth/tooltips/choropleth-tooltip.tsx b/packages/app/src/components/choropleth/tooltips/choropleth-tooltip.tsx index 18345a6d9a..02894f87b4 100644 --- a/packages/app/src/components/choropleth/tooltips/choropleth-tooltip.tsx +++ b/packages/app/src/components/choropleth/tooltips/choropleth-tooltip.tsx @@ -18,7 +18,7 @@ export function ChoroplethTooltip( ) { const { data, dataFormatters } = props; const { - siteText, + commonTexts, formatNumber, formatPercentage, formatDate, @@ -28,7 +28,7 @@ export function ChoroplethTooltip( formatDateSpan, } = useIntl(); - const text = siteText.choropleth_tooltip; + const text = commonTexts.choropleth_tooltip; const subject = ( text as unknown as Record>> diff --git a/packages/app/src/components/cms/inline-age-demographic.tsx b/packages/app/src/components/cms/inline-age-demographic.tsx index a220d341fb..391dd2ea39 100644 --- a/packages/app/src/components/cms/inline-age-demographic.tsx +++ b/packages/app/src/components/cms/inline-age-demographic.tsx @@ -27,7 +27,7 @@ interface InlineAgeDemographicProps { export function InlineAgeDemographic(props: InlineAgeDemographicProps) { const { configuration, startDate, endDate } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const dateUrl = getDataUrl(startDate, endDate, configuration); @@ -39,8 +39,8 @@ export function InlineAgeDemographic(props: InlineAgeDemographicProps) { return ; } - const source = get(siteText, configuration.sourceKey.split('.'), ''); - const text = get(siteText, configuration.text.split('.'), ''); + const source = get(commonTexts, configuration.sourceKey.split('.'), ''); + const text = get(commonTexts, configuration.text.split('.'), ''); return ( diff --git a/packages/app/src/components/cms/inline-choropleth.tsx b/packages/app/src/components/cms/inline-choropleth.tsx index 31104badd0..eff75be27f 100644 --- a/packages/app/src/components/cms/inline-choropleth.tsx +++ b/packages/app/src/components/cms/inline-choropleth.tsx @@ -30,7 +30,7 @@ interface InlineChoroplethProps { export function InlineChoropleth(props: InlineChoroplethProps) { const { configuration } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const dateUrl = getDataUrl(undefined, undefined, configuration, 'choropleth'); @@ -50,7 +50,7 @@ export function InlineChoropleth(props: InlineChoroplethProps) { : undefined, tooltipVariables: parseTooltipVariables( configuration.tooltipVariables, - siteText + commonTexts ), highlightSelection: configuration.highlightSelection, isPercentage: configuration.isPercentage, @@ -70,7 +70,7 @@ export function InlineChoropleth(props: InlineChoroplethProps) { noDataFillColor: getColor(configuration.noDataFillColor), }; - const source = get(siteText, configuration.sourceKey.split('.'), ''); + const source = get(commonTexts, configuration.sourceKey.split('.'), ''); return ( @@ -90,7 +90,7 @@ export function InlineChoropleth(props: InlineChoroplethProps) { function parseTooltipVariables( tooltipVarsJson: string | undefined, - siteText: SiteText + commonTexts: SiteText['common'] ) { if (!tooltipVarsJson?.length) { return undefined; @@ -99,10 +99,10 @@ function parseTooltipVariables( const varsObject = JSON.parse(tooltipVarsJson); return Object.fromEntries( Object.entries(varsObject).map(([name, value]) => { - if (isString(value) && value.startsWith('siteText')) { + if (isString(value) && value.startsWith('commonTexts')) { return [ name, - get(siteText, value.replace('siteText.', ''), undefined), + get(commonTexts, value.replace('commonTexts.', ''), undefined), ]; } return [name, value]; diff --git a/packages/app/src/components/cms/inline-donut-chart.tsx b/packages/app/src/components/cms/inline-donut-chart.tsx index a91f408164..9f4a44af63 100644 --- a/packages/app/src/components/cms/inline-donut-chart.tsx +++ b/packages/app/src/components/cms/inline-donut-chart.tsx @@ -29,7 +29,7 @@ export function InlineDonutChart< M extends MetricKeys >(props: InlineDonutChartProps) { const { startDate, endDate, configuration } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const dateUrl = getDataUrl(startDate, endDate, configuration, 'donut'); @@ -45,13 +45,13 @@ export function InlineDonutChart< (x) => ({ metricProperty: x.propertyName as any, color: getColor(x.color), - label: get(siteText, x.labelKey.split('.'), null), - tooltipLabel: get(siteText, x.tooltipLabelKey.split('.'), null), + label: get(commonTexts, x.labelKey.split('.'), null), + tooltipLabel: get(commonTexts, x.tooltipLabelKey.split('.'), null), }) ); - const title = get(siteText, configuration.labelKey.split('.'), ''); - const source = get(siteText, configuration.sourceKey.split('.'), ''); + const title = get(commonTexts, configuration.labelKey.split('.'), ''); + const source = get(commonTexts, configuration.sourceKey.split('.'), ''); return ( diff --git a/packages/app/src/components/cms/inline-kpi.tsx b/packages/app/src/components/cms/inline-kpi.tsx index 423a00fda8..ab54357a32 100644 --- a/packages/app/src/components/cms/inline-kpi.tsx +++ b/packages/app/src/components/cms/inline-kpi.tsx @@ -38,7 +38,7 @@ function getDataUrl(configuration: KpiConfiguration, date?: string) { } export function InlineKpi({ configuration, date }: InlineKpiProps) { - const { siteText, formatDateFromSeconds } = useIntl(); + const { commonTexts, formatDateFromSeconds } = useIntl(); const { data } = useSWRImmutable( getDataUrl(configuration, date), @@ -66,8 +66,8 @@ export function InlineKpi({ configuration, date }: InlineKpiProps) { }, }; - const title = get(siteText, configuration.titleKey.split('.'), ''); - const source = get(siteText, configuration.sourceKey.split('.'), ''); + const title = get(commonTexts, configuration.titleKey.split('.'), ''); + const source = get(commonTexts, configuration.sourceKey.split('.'), ''); const lastValue = getLastValue(data, configuration.metricName); diff --git a/packages/app/src/components/cms/inline-time-series-charts.tsx b/packages/app/src/components/cms/inline-time-series-charts.tsx index a32c27e017..fe41f76931 100644 --- a/packages/app/src/components/cms/inline-time-series-charts.tsx +++ b/packages/app/src/components/cms/inline-time-series-charts.tsx @@ -40,7 +40,7 @@ export function InlineTimeSeriesCharts< M extends MetricKeys >(props: InlineTimeSeriesChartsProps) { const { configuration, startDate, endDate } = props; - const { siteText } = useIntl(); + const { commonTexts } = useIntl(); const dateUrl = getDataUrl(startDate, endDate, configuration); @@ -59,7 +59,7 @@ export function InlineTimeSeriesCharts< const config: any = { type: x.type, metricProperty: x.propertyName, - label: get(siteText, x.labelKey.split('.'), null), + label: get(commonTexts, x.labelKey.split('.'), null), color: getColor(x.color), minimumRange: seriesMetricConfig?.minimumRange, }; @@ -70,7 +70,11 @@ export function InlineTimeSeriesCharts< config.fillOpacity = x.fillOpacity; } if (isDefined(x.shortLabelKey) && x.shortLabelKey.length) { - config.shortLabelKey = get(siteText, x.shortLabelKey.split('.'), null); + config.shortLabelKey = get( + commonTexts, + x.shortLabelKey.split('.'), + null + ); } if (isDefined(x.strokeWidth)) { config.strokeWidth = x.strokeWidth; @@ -84,7 +88,7 @@ export function InlineTimeSeriesCharts< scopedMetricConfigs, configuration.metricName, configuration.metricProperties, - siteText, + commonTexts, ]); const dataOptions = useMemo(() => { @@ -99,10 +103,10 @@ export function InlineTimeSeriesCharts< start: calculateStart(x.start, data.values), end: calculateEnd(x.end, x.start, data.values), label: isDefined(x.labelKey) - ? get(siteText, x.labelKey.split('.'), null) + ? get(commonTexts, x.labelKey.split('.'), null) : undefined, shortLabel: isDefined(x.shortLabelKey) - ? get(siteText, x.shortLabelKey.split('.'), null) + ? get(commonTexts, x.shortLabelKey.split('.'), null) : undefined, }) ); @@ -112,17 +116,21 @@ export function InlineTimeSeriesCharts< isPercentage: configuration.isPercentage, renderNullAsZero: configuration.renderNullAsZero, valueAnnotation: configuration.valueAnnotationKey?.length - ? get(siteText, configuration.valueAnnotationKey.split('.'), undefined) + ? get( + commonTexts, + configuration.valueAnnotationKey.split('.'), + undefined + ) : undefined, timespanAnnotations, } as DataOptions; - }, [configuration, siteText, data]); + }, [configuration, commonTexts, data]); if (!isDefined(data)) { return ; } - const source = get(siteText, configuration.sourceKey.split('.'), ''); + const source = get(commonTexts, configuration.sourceKey.split('.'), ''); return ( diff --git a/packages/app/src/components/combo-box/combo-box.tsx b/packages/app/src/components/combo-box/combo-box.tsx index fdea10f363..077d5cb911 100644 --- a/packages/app/src/components/combo-box/combo-box.tsx +++ b/packages/app/src/components/combo-box/combo-box.tsx @@ -46,7 +46,7 @@ type TProps