Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transloco): 🐛 fixed generated scope name in subdirectories #738

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/transloco/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Nested admin english",
"read": "Nested admin read english"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Nested admin spanish",
"read": "Nested admin read spanish"
}
13 changes: 13 additions & 0 deletions libs/transloco/src/lib/tests/scope-resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
})
});
Loading