Proposal: Improve Locale Detection Logic in TranslocoLocaleService #860
chaitanay94
started this conversation in
Ideas
Replies: 1 comment
-
i have raised a pull request #861 @shaharkazaz request you to go-through the same |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve been working with both Transloco and TranslocoLocale, and I noticed a potential improvement in how locale is determined in TranslocoLocaleService.
Currently, the locale is derived using:
private _locale = this.defaultLocale || this.toLocale(this.translocoService.getActiveLang());
This assumes that the active language from TranslocoService (e.g., 'fr') can be reliably converted to a full locale (e.g., 'fr-FR'). However, this approach:
Ignores the user's actual browser locale (navigator.language or navigator.languages)
Doesn't account for user preferences or app-level overrides
May lead to incorrect formatting (e.g., 'fr' mapping to 'fr-FR' when the user is in Canada and expects 'fr-CA')
💡 Proposal
Enhance TranslocoLocaleService to:
🔧 Example Implementation
This would ensure that both translation and formatting are aligned with the user's actual environment.
Would love to hear thoughts from the maintainers and community. Happy to contribute a PR if this direction makes sense!
@shaharkazaz we would like discuss more if required.
Beta Was this translation helpful? Give feedback.
All reactions