-
Notifications
You must be signed in to change notification settings - Fork 1
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: locale detection for icons #81
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, suggested a couple changes
return getSupportedLocale(htmlLocale); | ||
const htmlLocale = document?.documentElement?.lang; | ||
const hostLocale = detectByHost(); | ||
return getSupportedLocale(htmlLocale ?? hostLocale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this fallback approach to work in most cases, you would need to validate/parse document.documentElement.lang since in all cases I've seen, the value is set, just not always correctly. no
is a typical invalid value. Ideally we'd use a library for this but thats extra kb we could do without.
You could add a detectByLangAttribute() function that checks for valid en, fi, nb, sv and da values perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I have added a fallback which if the html lang is incorrect, fallback to detection using hostname.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like this?
Unsupported "${htmlLocale}" locale set in lang attribute on the html tag.
Falling back to locale based on hostname.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing htmlLocale
isn't really useful since someone checking this on console can easily see what the html lang is set to. Wordings I'll tweak a bit 👍
## [1.4.1-next.1](v1.4.0...v1.4.1-next.1) (2024-01-11) ### Bug Fixes * locale detection for icons ([#81](#81)) ([f97d09f](f97d09f))
# [1.5.0](v1.4.0...v1.5.0) (2024-02-02) ### Bug Fixes * locale detection for icons ([#81](#81)) ([f97d09f](f97d09f)) * update oikotie market icons ([#83](#83)) ([d4bad16](d4bad16)) * update strings for logout, picture-stack and organize ([#90](#90)) ([f381be3](f381be3)) ### Features * add 16px icons and update all svgs ([#91](#91)) ([a5f5794](a5f5794)) * add missing 16px icons and a geometric-shapes icon ([#84](#84)) ([c22fd1b](c22fd1b)) * add missing icons ([#88](#88)) ([f5db3ac](f5db3ac))
Change the way we detect locale based on the current NMP RFC