Skip to content
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

[stable4.5] simpler locale fall back code #5466

Merged
merged 1 commit into from
Sep 11, 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
20 changes: 7 additions & 13 deletions src/utils/moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,16 @@
} catch (error) {
const splitLocale = locale.split('-')
try {
// failure: fallback to de
locale = splitLocale[1]
// failure: fallback to first part of locale, which
// should be language
locale = splitLocale[0]

Check warning on line 88 in src/utils/moment.js

View check run for this annotation

Codecov / codecov/patch

src/utils/moment.js#L88

Added line #L88 was not covered by tests
await import(`moment/locale/${locale}.js`)
return locale
} catch (e) {
try {
// failure: fallback to en
locale = splitLocale[0]
await import(`moment/locale/${locale}.js`)
return locale
} catch (e) {
// failure, fallback to english
console.debug('Fallback to locale', 'en')
// English is the default locale and doesn't need to imported.
// It is already included in moment.js.
}
// failure, fallback to english
console.debug('Fallback to locale', 'en')

Check warning on line 93 in src/utils/moment.js

View check run for this annotation

Codecov / codecov/patch

src/utils/moment.js#L93

Added line #L93 was not covered by tests
// English is the default locale and doesn't need to imported.
// It is already included in moment.js.
}
}

Expand Down
Loading