Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(i18n): enhance default language fallback #19107

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const localeModels: Dictionary<Model> = {};
export const SYSTEM_LANG = !env.domSupported ? DEFAULT_LOCALE : (function () {
const langStr = (
/* eslint-disable-next-line */
document.documentElement.lang || navigator.language || (navigator as any).browserLanguage
document.documentElement.lang || navigator.language || (navigator as any).browserLanguage || DEFAULT_LOCALE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain when and which item will be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Browser: Firefox ESR 52.5.2_x86

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I tested it in Firefox ESR 52.5.2 (Win64) and found the language is not undefined, adding a fallback to prevent potential errors is always good.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It can meet some customized terminals (customized browser).

).toUpperCase();
return langStr.indexOf(LOCALE_ZH) > -1 ? LOCALE_ZH : DEFAULT_LOCALE;
})();
Expand Down