The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add content translations for aggregations (#68733)
Timofey Kachalovdf8fd2aa980d
diff --git a/e2e/test-component/scenarios/embedding-sdk/content-translations.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/content-translations.cy.spec.tsxindex 478e15118f4..7d05bae3a0b 100644--- a/e2e/test-component/scenarios/embedding-sdk/content-translations.cy.spec.tsx+++ b/e2e/test-component/scenarios/embedding-sdk/content-translations.cy.spec.tsx@@ -51,12 +51,12 @@ describe("scenarios > embedding-sdk > content-translations", () => {{locale: "de",msgid: "Question Embed SDK",- msgstr: "Override title für Deutsch",+ msgstr: "DE-Question Embed SDK",},{locale: "de",msgid: "Product ID",- msgstr: "Override Product ID für Deutsch",+ msgstr: "DE-Product ID",},]);@@ -75,10 +75,8 @@ describe("scenarios > embedding-sdk > content-translations", () => {);getSdkRoot().within(() => {- cy.findByText("Override title für Deutsch").should("be.visible");- cy.findByText("Override Product ID für Deutsch").should(- "be.visible",- );+ cy.findByText("DE-Question Embed SDK").should("be.visible");+ cy.findByText("DE-Product ID").should("be.visible");});});});@@ -91,21 +89,21 @@ describe("scenarios > embedding-sdk > content-translations", () => {uploadTranslationDictionaryViaAPI([// Table translations- { locale: "de", msgid: "Orders", msgstr: "Bestellungen" },- { locale: "de", msgid: "Products", msgstr: "Produkte" },- { locale: "de", msgid: "People", msgstr: "Personen" },- { locale: "de", msgid: "Reviews", msgstr: "Bewertungen" },+ { locale: "de", msgid: "Orders", msgstr: "DE-Orders" },+ { locale: "de", msgid: "Products", msgstr: "DE-Products" },+ { locale: "de", msgid: "People", msgstr: "DE-People" },+ { locale: "de", msgid: "Reviews", msgstr: "DE-Reviews" },// Column translations- { locale: "de", msgid: "ID", msgstr: "Kennung" },- { locale: "de", msgid: "Total", msgstr: "Gesamtsumme" },- { locale: "de", msgid: "Tax", msgstr: "Steuer" },- { locale: "de", msgid: "Quantity", msgstr: "Menge" },- { locale: "de", msgid: "Discount", msgstr: "Rabatt" },- { locale: "de", msgid: "Created At", msgstr: "Erstellt am" },- { locale: "de", msgid: "Product ID", msgstr: "Produkt ID" },- { locale: "de", msgid: "User ID", msgstr: "Benutzer ID" },- { locale: "de", msgid: "Subtotal", msgstr: "Zwischensumme" },- { locale: "de", msgid: "Address", msgstr: "Adresse" },+ { locale: "de", msgid: "ID", msgstr: "DE-ID" },+ { locale: "de", msgid: "Total", msgstr: "DE-Total" },+ { locale: "de", msgid: "Tax", msgstr: "DE-Tax" },+ { locale: "de", msgid: "Quantity", msgstr: "DE-Quantity" },+ { locale: "de", msgid: "Discount", msgstr: "DE-Discount" },+ { locale: "de", msgid: "Created At", msgstr: "DE-Created At" },+ { locale: "de", msgid: "Product ID", msgstr: "DE-Product ID" },+ { locale: "de", msgid: "User ID", msgstr: "DE-User ID" },+ { locale: "de", msgid: "Subtotal", msgstr: "DE-Subtotal" },+ { locale: "de", msgid: "Address", msgstr: "DE-Address" },]);cy.signOut();@@ -125,6 +123,7 @@ describe("scenarios > embedding-sdk > content-translations", () => {},);+ // "Pick your starting data" in German localegetSdkRoot().contains("Wähle deine Start-Daten");};@@ -135,21 +134,22 @@ describe("scenarios > embedding-sdk > content-translations", () => {popover().within(() => {// Use .should("exist") instead of .should("be.visible") because// elements in scrollable popovers might be below the fold- cy.findByText("Produkte").should("exist");+ cy.findByText("DE-Products").should("exist");- cy.findByText("Bestellungen").click();+ cy.findByText("DE-Orders").click();});getSdkRoot().within(() => {+ // "Add a filter to narrow down your answer" in German localecy.findByText("Füge Filter hinzu, um deine Antwort einzugrenzen",).click();});popover().within(() => {- cy.findByText("Gesamtsumme").should("exist");- cy.findByText("Steuer").should("exist");- cy.findByText("Menge").should("exist");+ cy.findByText("DE-Total").should("exist");+ cy.findByText("DE-Tax").should("exist");+ cy.findByText("DE-Quantity").should("exist");});});@@ -158,7 +158,7 @@ describe("scenarios > embedding-sdk > content-translations", () => {mountEditor();popover().within(() => {- cy.findByText("Bestellungen").click();+ cy.findByText("DE-Orders").click();});getSdkRoot().within(() => {@@ -168,24 +168,24 @@ describe("scenarios > embedding-sdk > content-translations", () => {});popover().within(() => {- cy.findByText("Gesamtsumme").click();+ cy.findByText("DE-Total").click();});popover().within(() => {cy.findByTestId("number-filter-picker").within(() => {- cy.findByText("Gesamtsumme").should("be.visible");+ cy.findByText("DE-Total").should("be.visible");cy.findByPlaceholderText("Min").type("100");cy.findByPlaceholderText("Max").type("200");+ // "Add filter" in German localecy.button("Füge einen Filter hinzu").click();});});getSdkRoot().within(() => {- cy.findByText("Gesamtsumme ist zwischen 100 und 200").should(- "be.visible",- );+ // "DE-Total is between 100 and 200" - filter display with translated column name+ cy.findByText("DE-Total ist zwischen 100 und 200").should("be.visible");});});@@ -194,22 +194,54 @@ describe("scenarios > embedding-sdk > content-translations", () => {mountEditor();popover().within(() => {- cy.findByText("Bestellungen").click();+ cy.findByText("DE-Orders").click();});getSdkRoot().within(() => {+ // "Pick a function or metric" in German localecy.findByText("Wähle eine Funktion oder Metrik aus").click();});popover().within(() => {+ // "Sum of..." in German localecy.findByText("Summe von...").click();- cy.findByText("Bestellungen").should("exist");- cy.findByText("Rabatt").should("exist");+ cy.findByText("DE-Orders").should("exist");+ cy.findByText("DE-Discount").should("exist");+ });++ popover().within(() => {+ cy.findByText("DE-Total").click();+ });++ getSdkRoot().within(() => {+ // "Pick a column to group by" in German locale+ cy.findByText("Wähle eine Spalte für die Gruppierung").click();+ });++ popover().within(() => {+ cy.findByText("DE-Orders").should("exist");+ cy.findByText("DE-Product ID").should("exist");++ cy.findByText("DE-Total").click();+ });+ });++ it("should translate aggregation-related columns", () => {+ setupEditor();+ mountEditor();++ popover().within(() => {+ cy.findByText("DE-Orders").click();+ });++ getSdkRoot().within(() => {+ cy.findByText("Wähle eine Funktion oder Metrik aus").click();});popover().within(() => {- cy.findByText("Gesamtsumme").click();+ cy.findByText("Summe von...").click();+ cy.findByText("DE-Total").click();});getSdkRoot().within(() => {@@ -217,10 +249,36 @@ describe("scenarios > embedding-sdk > content-translations", () => {});popover().within(() => {- cy.findByText("Bestellungen").should("exist");- cy.findByText("Produkt ID").should("exist");+ cy.findByText("DE-Product ID").click();+ });++ getSdkRoot().within(() => {+ // "Visualize" in German locale+ cy.button("Darstellen").click();++ cy.findByTestId("interactive-question-result-toolbar").within(() => {+ // "1 summary" in German locale+ cy.findByText("1 Zusammenfassung").click();+ });++ popover().within(() => {+ // "Sum of DE-Total" - aggregation pattern with translated column+ cy.findByText("Summe von DE-Total").should("be.visible");+ });++ cy.findByTestId("interactive-question-result-toolbar").within(() => {+ // "1 grouping" in German locale+ cy.findByText("1 Gruppierung").click();+ });++ popover().within(() => {+ cy.findByText("DE-Product ID").should("be.visible");+ });- cy.findByText("Gesamtsumme").click();+ cy.findByTestId("table-header").within(() => {+ cy.findByText("DE-Product ID").should("be.visible");+ cy.findByText("Summe von DE-Total").should("be.visible");+ });});});@@ -229,21 +287,22 @@ describe("scenarios > embedding-sdk > content-translations", () => {mountEditor();popover().within(() => {- cy.findByText("Bestellungen").click();+ cy.findByText("DE-Orders").click();});getSdkRoot().within(() => {+ // "Sort" in German localecy.button("Sortieren").click();});popover().within(() => {- cy.findByText("Benutzer ID").should("exist");+ cy.findByText("DE-User ID").should("exist");- cy.findByText("Gesamtsumme").click();+ cy.findByText("DE-Total").click();});getSdkRoot().within(() => {- cy.findByText("Gesamtsumme").should("be.visible");+ cy.findByText("DE-Total").should("be.visible");});});@@ -252,43 +311,45 @@ describe("scenarios > embedding-sdk > content-translations", () => {mountEditor();popover().within(() => {- cy.findByText("Bestellungen").click();+ cy.findByText("DE-Orders").click();});getSdkRoot().within(() => {+ // "Join data" in German localecy.button("Daten verknüpfen").click();});getSdkRoot().within(() => {- cy.findByLabelText("Linke Tabelle").should("have.text", "Bestellungen");+ // "Left table" in German locale+ cy.findByLabelText("Linke Tabelle").should("have.text", "DE-Orders");});popover().within(() => {- cy.findByText("Personen").click();+ cy.findByText("DE-People").click();});getSdkRoot().within(() => {- cy.findByText("Benutzer ID").click();+ cy.findByText("DE-User ID").click();});popover().within(() => {- cy.findByText("Bestellungen").should("exist");+ cy.findByText("DE-Orders").should("exist");- cy.findByText("Produkt ID").click();+ cy.findByText("DE-Product ID").click();});getSdkRoot().within(() => {- cy.findByText("Kennung").click();+ cy.findByText("DE-ID").click();});popover().within(() => {- cy.findByText("Personen").should("exist");- cy.findByText("Adresse").click();+ cy.findByText("DE-People").should("exist");+ cy.findByText("DE-Address").click();});getSdkRoot().within(() => {- cy.findByText("Produkt ID").should("be.visible");- cy.findByText("Adresse").should("be.visible");+ cy.findByText("DE-Product ID").should("be.visible");+ cy.findByText("DE-Address").should("be.visible");});});});@@ -321,22 +382,26 @@ describe("scenarios > embedding-sdk > content-translations", () => {});uploadTranslationDictionaryViaAPI([- { locale: "de", msgid: "Test Collection", msgstr: "Test Sammlung" },+ {+ locale: "de",+ msgid: "Test Collection",+ msgstr: "DE-Test Collection",+ },{locale: "de",msgid: "Test Dashboard",- msgstr: "Test Armaturenbrett",+ msgstr: "DE-Test Dashboard",},{locale: "de",msgid: "Dashboard description text",- msgstr: "Armaturenbrett Beschreibungstext",+ msgstr: "DE-Dashboard description text",},- { locale: "de", msgid: "Test Question", msgstr: "Testfrage" },+ { locale: "de", msgid: "Test Question", msgstr: "DE-Test Question" },{locale: "de",msgid: "Question description text",- msgstr: "Frage Beschreibungstext",+ msgstr: "DE-Question description text",},]);@@ -359,13 +424,11 @@ describe("scenarios > embedding-sdk > content-translations", () => {);getSdkRoot().within(() => {- cy.findByText("Test Sammlung").should("be.visible");- cy.findByText("Test Armaturenbrett").should("be.visible");- cy.findByText("Testfrage").should("be.visible");- cy.findByText("Armaturenbrett Beschreibungstext").should(- "be.visible",- );- cy.findByText("Frage Beschreibungstext").should("be.visible");+ cy.findByText("DE-Test Collection").should("be.visible");+ cy.findByText("DE-Test Dashboard").should("be.visible");+ cy.findByText("DE-Test Question").should("be.visible");+ cy.findByText("DE-Dashboard description text").should("be.visible");+ cy.findByText("DE-Question description text").should("be.visible");});});});diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/index.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/index.tsindex 7397f291d1d..952dff0d411 100644--- a/enterprise/frontend/src/metabase-enterprise/content_translation/index.ts+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/index.ts@@ -9,6 +9,7 @@ import {import { useTranslateContent } from "./use-translate-content";import {getTranslatedFilterDisplayName,+ translateAggregationDisplayName,translateDisplayNames,useSortByContentTranslation,useTranslateFieldValuesInHoveredObject,@@ -46,6 +47,7 @@ export function initializePlugin() {);},translateDisplayNames,+ translateAggregationDisplayName,getTranslatedFilterDisplayName,ContentTranslationConfiguration,});diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.tsindex 0a6be073510..adb7cbbe44b 100644--- a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts@@ -1,6 +1,7 @@import * as I from "icepick";import { useCallback, useMemo } from "react";import { P, match } from "ts-pattern";+import { t } from "ttag";import _ from "underscore";import type { ContentTranslationFunction } from "metabase/i18n/types";@@ -64,6 +65,82 @@ export const translateContentString: TranslateContentStringFunction = (return msgstr;};+export type AggregationPattern = (value: string) => string;++/**+ * Patterns for aggregation display names.+ * These must match the patterns used in the backend (metabase.lib.aggregation).+ * Each pattern is a function that takes a column name and returns the full display name.+ * More specific patterns must come before less specific ones.+ */+const AGGREGATION_PATTERNS: AggregationPattern[] = [+ (value: string) => t`Average of ${value}`,+ (value: string) => t`Count of ${value}`,+ (value: string) => t`Cumulative count of ${value}`,+ (value: string) => t`Cumulative sum of ${value}`,+ (value: string) => t`Distinct values of ${value}`,+ (value: string) => t`Max of ${value}`,+ (value: string) => t`Median of ${value}`,+ (value: string) => t`Min of ${value}`,+ (value: string) => t`Standard deviation of ${value}`,+ (value: string) => t`Sum of ${value} matching condition`,+ (value: string) => t`Sum of ${value}`,+ (value: string) => t`Variance of ${value}`,+];++// Unique marker to find where the value placeholder is in a pattern+const VALUE_MARKER = "\u0000";++/**+ * Translates an aggregation column display name by recursively parsing the+ * aggregation pattern and translating the inner column name.+ *+ * Handles patterns where the value can be:+ * - At the start: "{value} של סכום" (Hebrew, right-to-left)+ * - At the end: "Sum of {value}" (English)+ * - Wrapped: "Somme de {value} totale" (hypothetical)+ *+ * Examples:+ * - "Total" => tc("Total") (no aggregation pattern matched)+ * - "Sum of Total" => t`Sum of ${tc("Total")}`+ * - "Sum of Min of Total" => t`Sum of ${t`Min of ${tc("Total")}`}`+ */+export const translateAggregationDisplayName = (+ displayName: string,+ tc: ContentTranslationFunction,+ patterns: AggregationPattern[] = AGGREGATION_PATTERNS,+): string => {+ if (!hasTranslations(tc)) {+ return displayName;+ }++ for (const pattern of patterns) {+ const withMarker = pattern(VALUE_MARKER);+ const markerIndex = withMarker.indexOf(VALUE_MARKER);++ const prefix = withMarker.substring(0, markerIndex);+ const suffix = withMarker.substring(markerIndex + VALUE_MARKER.length);++ const hasPrefix = displayName.startsWith(prefix);+ const hasSuffix = displayName.endsWith(suffix);++ if (hasPrefix && hasSuffix) {+ const innerStart = prefix.length;+ const innerEnd = displayName.length - suffix.length;++ if (innerStart <= innerEnd) {+ const innerPart = displayName.substring(innerStart, innerEnd);++ return pattern(+ translateAggregationDisplayName(innerPart, tc, patterns),+ );+ }+ }+ }++ return tc(displayName);+};+const isRecord = (obj: unknown): obj is Record<string, unknown> =>_.isObject(obj) && Object.keys(obj).every((key) => typeof key === "string");@@ -76,21 +153,34 @@ export const translateDisplayNames = <T>(if (!hasTranslations(tc)) {return obj;}- const traverse = (o: T): T => {- if (Array.isArray(o)) {- return o.map((item) => traverse(item)) as T;++ const traverse = (element: T): T => {+ if (Array.isArray(element)) {+ return element.map((item) => traverse(item)) as T;}- if (isRecord(o)) {- return Object.entries(o).reduce((acc, [key, value]) => {- const newValue =- fieldsToTranslate.includes(key as string) && typeof value === "string"- ? tc(value)- : traverse(value as T);++ if (isRecord(element)) {+ return Object.entries(element).reduce((acc, [key, value]) => {+ const shouldTranslate =+ fieldsToTranslate.includes(key as string) &&+ typeof value === "string";++ // We can't detect if an element is an aggregation-related or not here.+ // We can't rely on the `source` field as for cases when a question containing aggregations is a base for another question,+ // the `source` field contains the `fields` value, not the `aggregation` one.+ // As the solution, we always try to translate the display name as an aggregation one,+ // and inside `translateAggregationDisplayName` we fallback to regular tc() call if no aggregation pattern is matched.+ const newValue = shouldTranslate+ ? translateAggregationDisplayName(value as string, tc)+ : traverse(value as T);+return I.assoc(acc, key, newValue);- }, o);+ }, element);}- return o;++ return element;};+return traverse(obj);};diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.unit.spec.tsindex 888228b67b0..03c4e345a20 100644--- a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.unit.spec.ts+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.unit.spec.ts@@ -12,6 +12,7 @@ import { createMockDatasetData } from "metabase-types/api/mocks";import { leaveUntranslated } from "./use-translate-content";import {getTranslatedFilterDisplayName,+ translateAggregationDisplayName,translateFieldValuesInSeries,} from "./utils";@@ -384,3 +385,149 @@ describe("getTranslatedFilterDisplayName", () => {expect(result).toBe("Ein Filter");});});++describe("translateAggregationDisplayName", () => {+ const tcWithColumnTranslations: ContentTranslationFunction = (str) => {+ const translations: Record<string, string> = {+ Total: "Gesamtsumme",+ Price: "Preis",+ Quantity: "Menge",+ };++ return typeof str === "string" ? (translations[str] ?? str) : str;+ };++ it("should return displayName unchanged when tc has no translations", () => {+ const result = translateAggregationDisplayName(+ "Sum of Total",+ mockTranslateWithoutTranslations,+ );++ expect(result).toBe("Sum of Total");+ });++ it("should translate a simple column name without aggregation pattern", () => {+ const result = translateAggregationDisplayName(+ "Total",+ tcWithColumnTranslations,+ );++ expect(result).toBe("Gesamtsumme");+ });++ it.each([+ ["Sum of Total", "Sum of Gesamtsumme"],+ [+ "Sum of Total matching condition",+ "Sum of Gesamtsumme matching condition",+ ],+ ["Average of Price", "Average of Preis"],+ ["Count of Quantity", "Count of Menge"],+ ["Min of Price", "Min of Preis"],+ ["Max of Price", "Max of Preis"],+ ["Median of Total", "Median of Gesamtsumme"],+ ["Cumulative count of Total", "Cumulative count of Gesamtsumme"],+ ["Cumulative sum of Total", "Cumulative sum of Gesamtsumme"],+ ["Distinct values of Total", "Distinct values of Gesamtsumme"],+ ["Standard deviation of Total", "Standard deviation of Gesamtsumme"],+ ["Variance of Total", "Variance of Gesamtsumme"],+ ])(+ "should translate column name inside aggregation pattern: %s -> %s",+ (input, expected) => {+ const result = translateAggregationDisplayName(+ input,+ tcWithColumnTranslations,+ );+ expect(result).toBe(expected);+ },+ );++ it.each([+ ["Sum of Min of Total", "Sum of Min of Gesamtsumme"],+ ["Average of Sum of Min of Price", "Average of Sum of Min of Preis"],+ ])("should handle nested aggregations: %s -> %s", (input, expected) => {+ const result = translateAggregationDisplayName(+ input,+ tcWithColumnTranslations,+ );+ expect(result).toBe(expected);+ });++ it("should return original string when column name has no translation", () => {+ const result = translateAggregationDisplayName(+ "Sum of UnknownColumn",+ tcWithColumnTranslations,+ );++ expect(result).toBe("Sum of UnknownColumn");+ });++ it("should handle empty string", () => {+ const result = translateAggregationDisplayName(+ "",+ tcWithColumnTranslations,+ );++ expect(result).toBe("");+ });++ describe("RTL and wrapped patterns", () => {+ // RTL pattern: value comes first, then the aggregation text+ // e.g., Hebrew: "{value} של סכום" (Sum of {value})+ const rtlPatterns = [(value: string) => `${value} של סכום`];++ // Wrapped pattern: value is surrounded by prefix and suffix+ // e.g., hypothetical French: "Somme de {value} totale"+ const wrappedPatterns = [(value: string) => `Somme de ${value} totale`];++ it("should handle RTL patterns where value comes first", () => {+ const result = translateAggregationDisplayName(+ "Total של סכום",+ tcWithColumnTranslations,+ rtlPatterns,+ );++ expect(result).toBe("Gesamtsumme של סכום");+ });++ it("should handle wrapped patterns where value is in the middle", () => {+ const result = translateAggregationDisplayName(+ "Somme de Total totale",+ tcWithColumnTranslations,+ wrappedPatterns,+ );++ expect(result).toBe("Somme de Gesamtsumme totale");+ });++ it("should handle nested RTL patterns", () => {+ const nestedRtlPatterns = [+ (value: string) => `${value} של סכום`,+ (value: string) => `${value} של מינימום`,+ ];++ const result = translateAggregationDisplayName(+ "Total של מינימום של סכום",+ tcWithColumnTranslations,+ nestedRtlPatterns,+ );++ expect(result).toBe("Gesamtsumme של מינימום של סכום");+ });++ it("should handle nested wrapped patterns", () => {+ const nestedWrappedPatterns = [+ (value: string) => `Somme de ${value} totale`,+ (value: string) => `Minimum de ${value} local`,+ ];++ const result = translateAggregationDisplayName(+ "Somme de Minimum de Total local totale",+ tcWithColumnTranslations,+ nestedWrappedPatterns,+ );++ expect(result).toBe("Somme de Minimum de Gesamtsumme local totale");+ });+ });+});diff --git a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/SummarizeBadgeList.tsx b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/SummarizeBadgeList.tsxindex 714b495f904..9255beae437 100644--- a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/SummarizeBadgeList.tsx+++ b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/SummarizeBadgeList.tsx@@ -1,7 +1,5 @@import { t } from "ttag";-import { useTranslateContent } from "metabase/i18n/hooks";-import { BadgeList, type BadgeListProps } from "../util/BadgeList";import {@@ -18,13 +16,12 @@ export const SummarizeBadgeList = ({"onRemoveItem" | "onAddItem" | "onSelectItem">) => {const aggregationItems = useSummarizeData();- const tc = useTranslateContent();return (<BadgeListitems={aggregationItems.map((item) => ({item,- name: tc(item.displayName),+ name: item.displayName,}))}addButtonLabel={t`Add another summary`}onSelectItem={onSelectItem}diff --git a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/use-summarize-data.ts b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/use-summarize-data.tsindex 97710a3038d..fa01c6cbb4f 100644--- a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/use-summarize-data.ts+++ b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Summarize/use-summarize-data.ts@@ -1,5 +1,7 @@import { useCallback, useMemo } from "react";+import { useTranslateContent } from "metabase/i18n/hooks";+import { PLUGIN_CONTENT_TRANSLATION } from "metabase/plugins";import {type AggregationItem,getAggregationItems,@@ -15,6 +17,7 @@ export interface SDKAggregationItem extends AggregationItem {export const useSummarizeData = () => {const { question, updateQuestion } = useSdkQuestionContext();+ const tc = useTranslateContent();const query = question?.query();const stageIndex = -1;@@ -55,12 +58,17 @@ export const useSummarizeData = () => {return {...aggregationItem,+ displayName:+ PLUGIN_CONTENT_TRANSLATION.translateAggregationDisplayName(+ aggregationItem.displayName,+ tc,+ ),onRemoveAggregation,onUpdateAggregation,};}): [],- [onQueryChange, query, stageIndex],+ [onQueryChange, query, stageIndex, tc],);return aggregationItems;diff --git a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Visualization.tsx b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Visualization.tsxindex cbded7c6202..0779cfac282 100644--- a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Visualization.tsx+++ b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/components/Visualization.tsx@@ -14,6 +14,7 @@ import { useSdkSelector } from "embedding-sdk-bundle/store";import { getIsGuestEmbed } from "embedding-sdk-bundle/store/selectors";import { useLocale } from "metabase/common/hooks/use-locale";import CS from "metabase/css/core/index.css";+import { PLUGIN_CONTENT_TRANSLATION } from "metabase/plugins";import { QueryVisualization } from "metabase/query_builder/components/QueryVisualization";import type Question from "metabase-lib/v1/Question";import type { CardDisplayType } from "metabase-types/api";@@ -64,6 +65,18 @@ export const QuestionVisualization = ({}}, [display, onVisualizationChange]);+ const [result] = queryResults ?? [];+ const card = question?.card();++ const untranslatedRawSeries = useMemo(+ () => (card ? [{ card, data: result && result.data }] : []),+ [card, result],+ );++ const rawSeries = PLUGIN_CONTENT_TRANSLATION.useTranslateSeries(+ untranslatedRawSeries,+ );+// When visualizing a question for the first time, there is no query result yet.const isQueryResultLoading =question && shouldRunCardQuery({ question, isGuestEmbed }) && !queryResults;@@ -80,9 +93,6 @@ export const QuestionVisualization = ({}}- const [result] = queryResults ?? [];- const card = question.card();-return (<FlexibleSizeComponentheight={height}@@ -93,7 +103,7 @@ export const QuestionVisualization = ({<QueryVisualizationclassName={cx(CS.flexFull, CS.fullWidth, CS.fullHeight)}question={question}- rawSeries={[{ card, data: result && result.data }]}+ rawSeries={rawSeries}isRunning={isQueryRunning}isObjectDetail={false}isResultDirty={false}diff --git a/frontend/src/metabase/plugins/oss/content-translation.ts b/frontend/src/metabase/plugins/oss/content-translation.tsindex 850cb142672..4a275d587ef 100644--- a/frontend/src/metabase/plugins/oss/content-translation.ts+++ b/frontend/src/metabase/plugins/oss/content-translation.ts@@ -21,6 +21,10 @@ const getDefaultPluginContentTranslation = () => ({obj: T,_tc: ContentTranslationFunction,) => obj,+ translateAggregationDisplayName: (+ displayName: string,+ _tc: ContentTranslationFunction,+ ): string => displayName,getTranslatedFilterDisplayName: (displayName: string,_tc: ContentTranslationFunction,