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
Revert temporary FE-side filters content-translation logic (#69276)
Timofey Kachalovc82d33f4b3af
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 fa94659ae25..0d4eacc2753 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@@ -160,7 +160,7 @@ describe("scenarios > embedding-sdk > content-translations", () => {});});- describe("filter step", () => {+ describe.skip("filter step", () => {it("should translate content for numeric field", () => {setupEditor();mountEditor();@@ -743,7 +743,7 @@ describe("scenarios > embedding-sdk > content-translations", () => {});});- it("should translate filter display name in RTL locale", () => {+ it.skip("should translate filter display name in RTL locale", () => {setupArabicEditor();mountArabicEditor();diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.tsindex 3904c08535f..a38a1c8d30c 100644--- a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts@@ -167,7 +167,7 @@ export const translateColumnDisplayName = (const hasPrefix = displayName.startsWith(prefix);const hasSuffix = displayName.endsWith(suffix);- if (hasPrefix && hasSuffix) {+ if (hasPrefix && hasSuffix && (prefix || suffix)) {const innerStart = prefix.length;const innerEnd = displayName.length - suffix.length;@@ -243,57 +243,7 @@ export const translateColumnDisplayName = ();}- // First try direct translation of the full display name- const directTranslation = tc(displayName);- if (directTranslation !== displayName) {- return directTranslation;- }-- // If no direct translation, try space-based iteration for filter patterns- // (handles cases like "Created At is in the previous 3 months" where only the column name is translatable)- // TODO: temporary code, in a follow up we will get this from CLJ side-- let longestPrefix = -1;- let longestPrefixTranslation = "";- let longestSuffix = -1;- let longestSuffixTranslation = "";-- for (let i = 0; i < displayName.length; i++) {- if (displayName[i] !== " ") {- continue;- }-- // LTR: column at the start (keep last match = longest prefix)- const prefix = displayName.substring(0, i);- const translatedPrefix = translateColumnDisplayName(prefix, tc, patterns);- if (translatedPrefix !== prefix) {- longestPrefix = i;- longestPrefixTranslation = translatedPrefix;- }-- // RTL: column at the end (keep first match = longest suffix)- if (longestSuffix === -1) {- const suffix = displayName.substring(i + 1);- const translatedSuffix = translateColumnDisplayName(suffix, tc, patterns);- if (translatedSuffix !== suffix) {- longestSuffix = i;- longestSuffixTranslation = translatedSuffix;- }- }- }-- // Prefer LTR match over RTL- if (longestPrefix > 0) {- return longestPrefixTranslation + displayName.substring(longestPrefix);- }-- if (longestSuffix >= 0) {- return (- displayName.substring(0, longestSuffix + 1) + longestSuffixTranslation- );- }-- return displayName;+ return tc(displayName);};const isRecord = (obj: unknown): obj is Record<string, unknown> =>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 f44eed6914e..7fa394fdb77 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@@ -664,106 +664,4 @@ describe("translateColumnDisplayName", () => {});});});-- describe("filter display name patterns", () => {- const tcWithFilterTranslations: ContentTranslationFunction = (str) => {- const translations: Record<string, string> = {- Total: "Gesamtsumme",- Price: "Preis",- "Created At": "Erstellt am",- Products: "Produkte",- Status: "Status",- };-- return typeof str === "string" ? (translations[str] ?? str) : str;- };-- it("should translate column name in filter: Total is greater than 100", () => {- const result = translateColumnDisplayName(- "Total is greater than 100",- tcWithFilterTranslations,- );- expect(result).toBe("Gesamtsumme is greater than 100");- });-- it("should translate column name in filter: Created At is in the previous 3 months", () => {- const result = translateColumnDisplayName(- "Created At is in the previous 3 months",- tcWithFilterTranslations,- );- expect(result).toBe("Erstellt am is in the previous 3 months");- });-- it("should translate column name in filter: Status is Active", () => {- const result = translateColumnDisplayName(- "Status is Active",- tcWithFilterTranslations,- );- expect(result).toBe("Status is Active");- });-- it("should translate column name in filter: Price is between 10 and 100", () => {- const result = translateColumnDisplayName(- "Price is between 10 and 100",- tcWithFilterTranslations,- );- expect(result).toBe("Preis is between 10 and 100");- });-- it("should translate column name in filter: Total is empty", () => {- const result = translateColumnDisplayName(- "Total is empty",- tcWithFilterTranslations,- );- expect(result).toBe("Gesamtsumme is empty");- });-- it("should translate column name in filter: Total is not empty", () => {- const result = translateColumnDisplayName(- "Total is not empty",- tcWithFilterTranslations,- );- expect(result).toBe("Gesamtsumme is not empty");- });-- it("should translate column name in filter with contains operator", () => {- const result = translateColumnDisplayName(- "Status contains Active",- tcWithFilterTranslations,- );- expect(result).toBe("Status contains Active");- });-- it("should translate aggregation column in filter: Sum of Total is greater than 100", () => {- const result = translateColumnDisplayName(- "Sum of Total is greater than 100",- tcWithFilterTranslations,- );- expect(result).toBe("Sum of Gesamtsumme is greater than 100");- });-- it("should translate joined column in filter: Products → Price is greater than 50", () => {- const result = translateColumnDisplayName(- "Products → Price is greater than 50",- tcWithFilterTranslations,- );- expect(result).toBe("Produkte → Preis is greater than 50");- });-- it("should translate temporal bucket column in filter: Created At: Month is today", () => {- const result = translateColumnDisplayName(- "Created At: Month is today",- tcWithFilterTranslations,- );- expect(result).toBe("Erstellt am: Month is today");- });-- it("should not translate when column has no translation", () => {- const result = translateColumnDisplayName(- "Unknown Column is greater than 100",- tcWithFilterTranslations,- );- expect(result).toBe("Unknown Column is greater than 100");- });- });});