saleor-dashboard
saleor-dashboard copied to clipboard
Language detection fails on Mac Safari
What I'm trying to achieve
When entering dashboard using Polish language, I want to see page in Polish. On Chrome it works, on Safari not (it displays English).
Steps to reproduce the problem
- Enter dashboard on Mac on Chrome
- Enter dashboard on Mac on Safari
What I expected to happen
Page should detect Polish on Safari.
Important information - I've debugged it and I know the reason. navigator.languages
returns 'pl'
on Chrome, but pl-pl
on Safari. In src/components/Locale, we support only 'pl
.
System information
Operating system:
- [ ] Windows
- [ ] Linux
- [x ] MacOS
- [ ] Other
Browser:
- [x ] Safari
- [x ] Chrome
- [ ] Edge
- [ ] Other
@karer Hey! Thanks for reporting. Could you provide some screenshots? What's your version of Saleor?

I am using macOS 10.15.7 (latest), Safari 14.0 (latest), language of system and browser - Polish. Saleor using 2.11 (both API and Dashboard).
// Edit: After implementing hotfix by myself, it works. Be aware, that it could potentially use for example "en-US" when having browser as "en-GB", as it doesn't check by first part as the latest try.
saleor-dashboard/src/components/Locale/Locale.tsx
From:
for (const preferredLocale of languages) {
for (const localeEntry of localeEntries) {
if (
localeEntry[1].toLowerCase() === preferredLocale.toLowerCase()
) {
return Locale[localeEntry[0]];
}
}
}
To:
for (const preferredLocale of languages) {
for (const localeEntry of localeEntries) {
if (
localeEntry[1].toLowerCase() === preferredLocale.toLowerCase() ||
localeEntry[1].toLowerCase() === preferredLocale.split("-")[0]?.toLowerCase()
) {
return Locale[localeEntry[0]];
}
}
}
Issue reported: SALEOR-7292