forked from abpframework/abp
-
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.
Merge pull request abpframework#1685 from abpframework/feature/implem…
…ent-angular-locale feature(core): implement angular locale system
- Loading branch information
Showing
13 changed files
with
169 additions
and
23 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
npm/ng-packs/packages/core/src/lib/constants/different-locales.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,33 @@ | ||
// Different locales from .NET | ||
// Key is .NET locale, value is Angular locale | ||
|
||
export default { | ||
'ar-sa': 'ar-SA', | ||
'ca-ES-valencia': 'ca-ES-VALENCIA', | ||
'de-de': 'de', | ||
'es-ES': 'es', | ||
'en-US': 'en', | ||
'fil-Latn': 'en', | ||
'ku-Arab': 'en', | ||
'ky-Cyrl': 'en', | ||
'mi-Latn': 'en', | ||
'prs-Arab': 'en', | ||
'qut-Latn': 'en', | ||
nso: 'en', | ||
quz: 'en', | ||
'fr-FR': 'fr', | ||
'gd-Latn': 'gd', | ||
'ha-Latn': 'ha', | ||
'ig-Latn': 'ig', | ||
'it-it': 'it', | ||
'mn-Cyrl': 'mn', | ||
'pt-BR': 'pt', | ||
'sd-Arab': 'pa-Arab', | ||
'sr-Cyrl-RS': 'sr-Cyrl', | ||
'sr-Latn-RS': 'sr-Latn', | ||
'tg-Cyrl': 'tg', | ||
'tk-Latn': 'tk', | ||
'tt-Cyrl': 'tt', | ||
'ug-Arab': 'ug', | ||
'yo-Latn': 'yo', | ||
}; |
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 @@ | ||
export * from './different-locales'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './locale.provider'; |
24 changes: 24 additions & 0 deletions
24
npm/ng-packs/packages/core/src/lib/providers/locale.provider.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,24 @@ | ||
import { LOCALE_ID, Provider } from '@angular/core'; | ||
import localesMapping from '../constants/different-locales'; | ||
import { LocalizationService } from '../services/localization.service'; | ||
|
||
export class LocaleId extends String { | ||
constructor(private localizationService: LocalizationService) { | ||
super(); | ||
} | ||
|
||
toString(): string { | ||
const { currentLang } = this.localizationService; | ||
return localesMapping[currentLang] || currentLang; | ||
} | ||
|
||
valueOf(): string { | ||
return this.toString(); | ||
} | ||
} | ||
|
||
export const LocaleProvider: Provider = { | ||
provide: LOCALE_ID, | ||
useClass: LocaleId, | ||
deps: [LocalizationService], | ||
}; |
44 changes: 39 additions & 5 deletions
44
npm/ng-packs/packages/core/src/lib/services/localization.service.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
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
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