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-779 content translation is now case insensitive (#63171)

Sébastieneb474fbf52aa
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/utils.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/utils.unit.spec.ts
index 88fa90c7fe3..5acf8d42606 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/utils.unit.spec.ts
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/utils.unit.spec.ts
@@ -101,13 +101,13 @@ describe("content translation utils", () => {
).toBe("Whitespace Translation");
});
- it("should handle case sensitivity", () => {
+ it("should be case insensitive for msgid (metabase#61795)", () => {
expect(translateContentString(mockDictionary, "es", "hello")).toBe(
- "hello",
- ); // no match
- expect(translateContentString(mockDictionary, "ES", "Hello")).toBe(
- "Hello",
- ); // no match
+ "Hola",
+ );
+ expect(translateContentString(mockDictionary, "es", "WORLD")).toBe(
+ "Mundo",
+ );
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts
index c6f3e2d2a6e..55db3d82f4a 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/utils.ts
@@ -43,8 +43,11 @@ export const translateContentString: TranslateContentStringFunction = (
return msgid;
}
+ const lowerCaseMsgId = msgid.toLowerCase();
+
const msgstr = dictionary?.find(
- (row) => row.locale === locale && row.msgid === msgid,
+ (row) =>
+ row.locale === locale && row.msgid.toLowerCase() === lowerCaseMsgId,
)?.msgstr;
if (!msgstr || !msgstr.trim()) {