fix(NcDateTimePicker): use translated words in dates formatted with a format string#8644
Conversation
| if (localeCode === 'be-tarask') { | ||
| exportName = 'beTarasak' | ||
| } | ||
| content += `loader['${localeCode}'] = async () => (await import('date-fns/locale/${localeCode}')).${exportName}\n` |
There was a problem hiding this comment.
Generated module looks like this.
const loader = {};
loader["af"] = async () => (await import("date-fns/locale/af")).af;
loader["ar-DZ"] = async () => (await import("date-fns/locale/ar-DZ")).arDZ;
...
loader["zh-HK"] = async () => (await import("date-fns/locale/zh-HK")).zhHK;
loader["zh-TW"] = async () => (await import("date-fns/locale/zh-TW")).zhTW;There was a problem hiding this comment.
It tested it with Vite and Rspack apps.
| nodeExternalsOptions: { | ||
| // Packages with paths imports should be added here to mark them as external as well | ||
| include: [/^@nextcloud\/.+\//, /^@mdi\/svg\//], | ||
| include: [/^@nextcloud\/.+\//, /^@mdi\/svg\//, /^date-fns\/locale\//], |
There was a problem hiding this comment.
Externalized as suggested in #7767 (comment)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8644 +/- ##
=======================================
Coverage 54.06% 54.06%
=======================================
Files 106 106
Lines 3479 3479
Branches 1009 1009
=======================================
Hits 1881 1881
Misses 1354 1354
Partials 244 244 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1fc990a to
427346d
Compare
|
|
||
| <template> | ||
| <div class="vue-date-time-picker__wrapper"> | ||
| <!-- Setting :key="dateFnsLocaleCode" forces the component to rerender when `:formatLocale` changes. |
There was a problem hiding this comment.
Is there an upstream bug report for this? If not please create one when adding such a work-around
There was a problem hiding this comment.
Done. I Created an issue upstream and added a link.
Also simplified the workaround by removing an intermediate computed var.
(...I got lazy there because we are behind a few major versions, and I just assumed it's probably fixed. But no, the issue persists in the most recent version too.)
d25f659 to
20a290a
Compare
20a290a to
b2b9764
Compare
… format string Signed-off-by: Oleksandr Dzhychko <hey@oleks.dev>
b2b9764 to
20e1809
Compare
Given:
"de-DE"NcDateTimePickerformatprop"yyyy MMM dd"Expect:
Actual:
☑️ Resolves
If a format string is provided, the component now uses the user defined locale to use translated names of month, weekday etc.
🖼️ Screenshots
🚧 Tasks
🏁 Checklist
stable8for maintained Vue 2 version or not applicableNotes
This fix is a byproduct of loading locales from
data-fns/locale, which I intent to use in fixing #8639 (in PR #8657)I opened this PR to make the review easier and get feedback faster.
The loading of
date-fns/localesis the bulk of the PR.Loading those locales seemed to be a blocker in #7767 (comment)