forked from onecx/onecx-portal-ui-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly inject LOCALE_ID in angular-accelerator.module (onecx#337
) * fix: correctly inject LOCALE_ID in angular-accelerator.module * fix: fix linter * fix: fix class naming * refactor: rename files * fix: await language initialization
- Loading branch information
1 parent
292b58a
commit 1b23c02
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
libs/angular-accelerator/src/lib/utils/dynamic-locale-id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { UserService } from '@onecx/angular-integration-interface' | ||
|
||
export class DynamicLocaleId { | ||
constructor(private userService: UserService) { | ||
Object.getOwnPropertyNames(String.prototype).forEach((k) => { | ||
if (k != 'valueOf') { | ||
;(this as any)[k] = function (...args: any[]) { | ||
const str = this.valueOf() | ||
return str[k](...args) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
valueOf() { | ||
return this.userService.lang$.getValue() | ||
} | ||
} |