scaleway/scaleway-lib @scaleway/use-i18n@10.0.0
scaleway/scaleway-lib
Captured source
source ↗published Nov 25, 2026seen 2dcaptured 2dhttp 200method plain
@scaleway/use-i18n@10.0.0
Repository: scaleway/scaleway-lib
Tag: @scaleway/use-i18n@10.0.0
Published: 2026-11-25T13:58:15Z
Prerelease: no
Release notes:
Major Changes
- #4173 `54d87e8` Thanks @chambo-e! - Remove the
date-fnsdependency: every date, duration and relative-time format now uses nativeIntlAPIs (Intl.DateTimeFormat,Intl.RelativeTimeFormat,Intl.DurationFormat) with CLDR data instead of date-fns locale bundles.
Added
noSuffixoption onrelativeTime/relativeTimeStrict: returns the bare distance ("21 years","3,499 days") instead of"21 years ago". Not supported with thequarterunit.
Breaking changes
- The
I18nprovider no longer acceptsloadDateLocale,loadDateLocaleAsyncandonLoadDateLocaleError: nativeIntlonly needs the current locale string, so there is nothing to load. Remove these props from your setup. dateFnsLocaleis removed from the context. If you passed it to a component that needs a date-fns locale object (e.g.@scaleway/ui'sDateInput), import and load date-fns in your app.relativeTimeandrelativeTimeStrictoptions areRelativeTimeOptions/RelativeTimeStrictOptionsinstead of date-fns types: the nativeIntl.RelativeTimeFormatOptions(localeMatcher?,numeric?,style?) plusnoSuffix?, andunit?for the strict variant.addSuffixis gone — relative times are suffixed by default ("ago"/"in").roundingMethodis gone as well, with no replacement — distances round half away from "now" on the absolute value, exactly as date-fns did (Intl.RelativeTimeFormatexposes no rounding control).- The
date-fnstype re-exportsFormatDistanceToNowOptionsandFormatDistanceToNowStrictOptionsare no longer exported from@scaleway/use-i18n. formatDurationoptions are nowIntl.DurationFormatOptions(e.g.{ style: 'narrow' }) instead of date-fns format options;'clock'and'clock-milliseconds'are unchanged.switchLocaleis now synchronous and returnsvoidinstead ofPromise— with the date-fns locale loading gone there is nothing asynchronous left. Drop any.then()calls;await switchLocale(...)keeps working unchanged.date-fnsis no longer a peer dependency.
Requirements
- Runtime: non-clock
formatDurationneedsIntl.DurationFormat— Baseline 2025 (Chrome/Edge 129+, Firefox 136+, Safari 16.4+, Node 23+ per MDN). Polyfill@formatjs/intl-durationformatif you support older browsers.relativeTimeneedsIntl.RelativeTimeFormat(available everywhere since 2020). Node is already covered by theenginesfield (>=24). - TypeScript: the published types reference
Intl.DurationFormatOptions, which first ships in TypeScript 6.0 (lib.es2025.intl); on older versions the.d.tswill not compile.
Output changes (CLDR wording):
- Durations gain list separators in English and "et" in French ("3 hours, 40 minutes, 50 seconds", "3 heures, 40 minutes et 50 secondes"), and durations above 24h are plain days instead of calendar months ("45 days", not "1 month 14 days").
- Relative times use CLDR rounding ("21 years ago" instead of "over 20 years ago", "3,499 days ago") and, with the default
numeric: 'auto', the full set of CLDR specials — "now", "yesterday"/"hier", "last week", "last month", "last quarter", "last year" and their future forms. Passnumeric: 'always'to keep plain output. - Granularity goes down to seconds: spans under a minute render "45 seconds ago" where date-fns said "less than a minute ago" (30–59s said "1 minute"), and the 45–59-minute window renders in minutes where date-fns said "about 1 hour ago".
- Distances are elapsed time, not wall-clock time: date-fns normalized daylight-saving transitions for day/month/year buckets, so a span crossing a DST shift can now differ by one unit from date-fns.
relativeTimeStrictuses average unit lengths (30.44-day months, 365.25-day years) instead of date-fns's 30/365-day ones, so large counts differ slightly (3499 days is "115 months" where date-fns said "117").unit: 'week'andunit: 'quarter'now format in their own unit, where date-fns silently computed years.- Legacy date-fns options that no longer exist (
includeSeconds,format,zero,delimiter) are ignored rather than rejected; TypeScript flags them for TS callers.
formatDate output is unchanged.
Patch Changes
- #4196 `3628957` Thanks @chambo-e! - Fix README examples so they compile against the real
I18nContextProviderprops: replace the non-existentsupportedLocalesprop withisLocaleSupported, pass the requireddefaultLoad, fix theuseTranlationtypo, keydefaultTranslationsby locale, moveuseI18n()out of module scope, and remove stray JSX and self-rendering ``.
Excerpt shown — open the source for the full document.