From 393be461c81c27e93538cd16689d472d29050dc8 Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Thu, 4 Jan 2024 09:56:10 -0400 Subject: [PATCH 1/2] =?UTF-8?q?fix(transloco):=20=F0=9F=90=9B=20fixed=20ge?= =?UTF-8?q?nerated=20scope=20name=20in=20subdirectories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/transloco/src/lib/helpers.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/transloco/src/lib/helpers.ts b/libs/transloco/src/lib/helpers.ts index 8541801e..84606426 100644 --- a/libs/transloco/src/lib/helpers.ts +++ b/libs/transloco/src/lib/helpers.ts @@ -91,6 +91,9 @@ export function toCamelCase(str: string): string { .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => index == 0 ? word.toLowerCase() : word.toUpperCase() ) + .replace(/\b\/(\w)/g, (_, p1) => + `.${p1.toLowerCase()}` + ) .replace(/\s+|_|-|\//g, ''); } From 2f7f8b5e909b1fc89836091ba0fc933a0afe5de3 Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Thu, 4 Jan 2024 10:28:48 -0400 Subject: [PATCH 2/2] =?UTF-8?q?test(transloco):=20=F0=9F=92=8D=20Added=20n?= =?UTF-8?q?ew=20test=20for=20nested=20scope=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nested-scope/nested-admin-page/en.json | 4 ++++ .../nested-scope/nested-admin-page/es.json | 4 ++++ libs/transloco/src/lib/tests/scope-resolver.spec.ts | 13 +++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/en.json create mode 100644 libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/es.json diff --git a/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/en.json b/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/en.json new file mode 100644 index 00000000..c8c778ac --- /dev/null +++ b/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/en.json @@ -0,0 +1,4 @@ +{ + "title": "Nested admin english", + "read": "Nested admin read english" +} diff --git a/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/es.json b/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/es.json new file mode 100644 index 00000000..579358e1 --- /dev/null +++ b/libs/transloco/src/lib/tests/i18n-mocks/nested-scope/nested-admin-page/es.json @@ -0,0 +1,4 @@ +{ + "title": "Nested admin spanish", + "read": "Nested admin read spanish" +} diff --git a/libs/transloco/src/lib/tests/scope-resolver.spec.ts b/libs/transloco/src/lib/tests/scope-resolver.spec.ts index 6b2df209..c8fdda97 100644 --- a/libs/transloco/src/lib/tests/scope-resolver.spec.ts +++ b/libs/transloco/src/lib/tests/scope-resolver.spec.ts @@ -65,4 +65,17 @@ describe('ScopeResolver', () => { expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenCalledWith('admin-page', 'adminPage'); }); + + it('should return provider nested scope with object and set the alias as the scope name if not provided', () => { + expect( + resolver.resolve({ + inline: undefined, + provider: { + scope: 'nested-scope/nested-admin-page' + }, + }) + ).toEqual('nested-scope/nested-admin-page'); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith('nested-scope/nested-admin-page', 'nestedScope.nestedAdminPage'); + }) });