Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(ui): return en-GB locale to Weblate-managed fallback

joshistoast147d4f1f13b9
diff --git a/invokeai/frontend/webv2/src/workbench/palette/commandPaletteI18n.test.ts b/invokeai/frontend/webv2/src/workbench/palette/commandPaletteI18n.test.ts
index 5113bfb6a2..cdac5762e5 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/commandPaletteI18n.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/commandPaletteI18n.test.ts
@@ -1,24 +1,23 @@
+import i18n from 'i18next';
import { describe, expect, it } from 'vitest';
const enModules = import.meta.glob('../../../public/locales/en.json', { eager: true, import: 'default' });
const enGbModules = import.meta.glob('../../../public/locales/en-GB.json', { eager: true, import: 'default' });
-const en = Object.values(enModules)[0] as { commandPalette: Record<string, unknown> };
-const enGb = Object.values(enGbModules)[0] as { commandPalette: Record<string, unknown> };
-
-const flattenKeys = (value: Record<string, unknown>, prefix = ''): string[] =>
- Object.entries(value).flatMap(([key, child]) => {
- const path = prefix ? `${prefix}.${key}` : key;
-
- return child && typeof child === 'object' && !Array.isArray(child)
- ? flattenKeys(child as Record<string, unknown>, path)
- : [path];
- });
+const en = Object.values(enModules)[0] as { commandPalette: { title: string } };
+const enGb = Object.values(enGbModules)[0] as Record<string, unknown>;
describe('command palette translations', () => {
- it('keeps English and British-English command palette keys in parity', () => {
- const enCommandPalette = en.commandPalette;
- const enGbCommandPalette = enGb.commandPalette;
+ it('resolves command palette keys through the en fallback for en-GB', async () => {
+ const instance = i18n.createInstance();
+ await instance.init({
+ lng: 'en-GB',
+ fallbackLng: 'en',
+ resources: {
+ en: { translation: en },
+ 'en-GB': { translation: enGb },
+ },
+ });
- expect(flattenKeys(enGbCommandPalette).sort()).toEqual(flattenKeys(enCommandPalette).sort());
+ expect(instance.t('commandPalette.title')).toBe(en.commandPalette.title);
});
});