Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Closes EMB-760 table columns translations (#62760)

Sébastienb7a16be2350b
diff --git a/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts b/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts
index 7828aa0d4a2..1222824f2f7 100644
--- a/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts
+++ b/e2e/test/scenarios/admin/i18n/content-translation/dashboards.cy.spec.ts
@@ -3,8 +3,12 @@ import {
NORMAL_USER_ID,
ORDERS_DASHBOARD_ID,
} from "e2e/support/cypress_sample_instance_data";
-import type { DashboardDetails } from "e2e/support/helpers";
+import type {
+ DashboardDetails,
+ StructuredQuestionDetails,
+} from "e2e/support/helpers";
import type { DictionaryArray } from "metabase-types/api";
+const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const { ACCOUNTS_ID, ACCOUNTS, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =
SAMPLE_DATABASE;
@@ -19,6 +23,87 @@ import { uploadTranslationDictionaryViaAPI } from "./helpers/e2e-content-transla
const { H } = cy;
describe("scenarios > content translation > static embedding > dashboards", () => {
+ describe("measure names", () => {
+ before(() => {
+ cy.intercept("POST", "/api/ee/content-translation/upload-dictionary").as(
+ "uploadDictionary",
+ );
+
+ H.restore();
+ cy.signInAsAdmin();
+ H.activateToken("bleeding-edge");
+
+ uploadTranslationDictionaryViaAPI([
+ ...germanFieldNames,
+ ...germanFieldValues,
+ ...frenchNames,
+ ...frenchBooleanTranslations,
+ ]);
+ H.snapshot("with-translations");
+ });
+
+ beforeEach(() => {
+ cy.intercept("GET", "/api/embed/dashboard/*").as("dashboard");
+ cy.intercept("GET", "/api/embed/dashboard/**/card/*").as("cardQuery");
+ cy.intercept("GET", "/api/embed/dashboard/**/search/*").as("searchQuery");
+ H.restore("with-translations" as any);
+ });
+
+ it("should translate pivot table measure names", () => {
+ const pivotQuestionDetails: StructuredQuestionDetails = {
+ name: "Pivot Table Test",
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [
+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
+ ["field", ORDERS.QUANTITY, null],
+ ],
+ },
+ display: "pivot",
+ visualization_settings: {
+ "pivot_table.column_split": {
+ rows: [ORDERS.CREATED_AT, ORDERS.QUANTITY] as any,
+ columns: [],
+ values: ["count"],
+ },
+ column_settings: {
+ '["name","count"]': {
+ column_title: "Price",
+ },
+ },
+ },
+ };
+
+ H.createQuestionAndDashboard({
+ questionDetails: pivotQuestionDetails,
+ dashboardDetails: {
+ name: "Pivot Dashboard Test",
+ enable_embedding: true,
+ embedding_params: {},
+ },
+ }).then(({ body: { dashboard_id } }) => {
+ H.visitEmbeddedPage(
+ {
+ resource: { dashboard: dashboard_id as number },
+ params: {},
+ },
+ {
+ additionalHashOptions: {
+ locale: "de",
+ },
+ },
+ );
+
+ cy.wait("@dashboard");
+
+ H.getDashboardCard(0).within(() => {
+ cy.findByText("Preis").should("exist");
+ });
+ });
+ });
+ });
+
describe("filters and field values", () => {
describe("ee", () => {
before(() => {
diff --git a/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTableCell.tsx b/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTableCell.tsx
index 723cf3373fe..adf635bd97f 100644
--- a/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTableCell.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTableCell.tsx
@@ -5,6 +5,7 @@ import Draggable from "react-draggable";
import { Ellipsified } from "metabase/common/components/Ellipsified";
import CS from "metabase/css/core/index.css";
+import { useTranslateContent } from "metabase/i18n/hooks";
import type { VisualizationSettings } from "metabase-types/api";
import { PivotTableCell, ResizeHandle } from "./PivotTable.styled";
@@ -140,12 +141,14 @@ export const TopHeaderCell = ({
}: TopHeaderCellProps) => {
const { value, hasChildren, clicked, isSubtotal, maxDepthBelow, span } = item;
+ const tc = useTranslateContent();
+
return (
<Cell
style={{
...style,
}}
- value={value}
+ value={tc(value)}
isNightMode={isNightMode}
isBorderedHeader={maxDepthBelow === 0}
isEmphasized={hasChildren}