diff --git a/libs/transloco/src/lib/helpers.ts b/libs/transloco/src/lib/helpers.ts index 8541801e0..846064263 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, ''); } 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 000000000..c8c778acd --- /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 000000000..579358e16 --- /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 6b2df2090..c8fdda97e 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'); + }) });