Add i18n vendor overlays and dynamic bundling
- Add opt-in vendor overlays under src/env/locales/<env>
(and optional variant), merged on top of base locales at runtime.
- Auto-discover and bundle all base locale JSON files
in src/locales/.
- Example: move dump type labels under pageDumps.dumpTypes;
read vendor-only dump labels from overlays.
- Docs: update i18n guidelines and env README (formatting fixes).
- Tests: add focused unit tests for overlays and locale aliases.
Tested:
- Unit: i18n.locale-alias.spec.js, i18n.vendor.spec.js (passing)
- Manual: Verified dynamic locale discovery and overlay merge in UI
Change-Id: I8eae2bfec0e9622bafdafac3168dbf96650e8ae8
Signed-off-by: jason westover <jwestover@nvidia.com>
diff --git a/tests/unit/i18n.vendor.spec.js b/tests/unit/i18n.vendor.spec.js
new file mode 100644
index 0000000..93049b9
--- /dev/null
+++ b/tests/unit/i18n.vendor.spec.js
@@ -0,0 +1,44 @@
+// How to run this test in isolation:
+// npm run test:unit -- i18n.vendor.spec.js
+// This verifies vendor overlays (e.g., nvidia shared folder) and vendor-root fallback
+// without requiring component mounts or full app boot.
+describe('i18n vendor overlays', () => {
+ const ORIGINAL_ENV = process.env;
+ beforeEach(() => {
+ jest.resetModules();
+ process.env = { ...ORIGINAL_ENV };
+ // Ensure default locale is deterministic for the test
+ window.localStorage.setItem('storedLanguage', 'en-US');
+ });
+
+ afterEach(() => {
+ process.env = ORIGINAL_ENV;
+ });
+
+ test('falls back to vendor root overlays when env has hyphenated suffix', async () => {
+ // Simulate running in nvidia-gb but having overlays only in src/env/locales/nvidia
+ process.env.VUE_APP_ENV_NAME = 'nvidia-gb';
+
+ const { createI18nInstance } = await import('@/i18n');
+ const vendorEn = require('@/env/locales/nvidia/en-US.json');
+ const stubLoader = () => ({ 'en-US': vendorEn.default || vendorEn });
+ const i18nInstance = createI18nInstance('nvidia-gb', 'en-US', stubLoader);
+
+ // System HGX dump is NVIDIA-specific and defined in src/env/locales/nvidia/en-US.json
+ const translated = i18nInstance.global.t(
+ 'pageDumps.dumpTypes.systemHgxDump',
+ );
+ expect(translated).toBe('System [HGX] dump (disruptive)');
+ });
+
+ test('base locales do not contain vendor-only keys', async () => {
+ process.env.VUE_APP_ENV_NAME = undefined;
+ const { createI18nInstance } = await import('@/i18n');
+ const i18nInstance = createI18nInstance(undefined, 'en-US');
+ const translated = i18nInstance.global.t(
+ 'pageDumps.dumpTypes.systemHgxDump',
+ );
+ // When no env overlays are loaded, accessing vendor-only keys should return the key path
+ expect(translated).toBe('pageDumps.dumpTypes.systemHgxDump');
+ });
+});