Comments (5)
I'm going to presume this isn't the cause of your issue, but just in case: I believe svelte-i18n, at some level, wraps the Intl API. The Intl API only has access to whatever locales are available in your runtime (server-side: Node.js, client-side: whatever the browser ships with). This bit me recently working with ga-IE localisation in Ireland: Firefox and Edge ship with better localised distros here and svelte-i18n was localising the dates for me, but whenever I opened the app in Chrome the dates were displayed in English as Chrome had no support for the ga-IE locale. In the end the only solution that reliably worked in userland was to use moment.js for date formatting (manually importing ga-IE locale) and svelte-i18n for the rest of the string translation. It works good though, and the way svelte-i18n v3 has broken up the _, number and date functions so they can be tree-shaken reduces extra weight involved with adding an additional library.
Hope I haven't got any of the above wrong @kaisermann
from svelte-i18n.
@rodoch Got pretty much everything right! Thanks for the great explanation 😁 It's not hard to create a derived store from $locale
to format dates with another lib:
const myDateFormatter = derived([locale], (locale) => (date) => dateLib(date, locale))
from svelte-i18n.
We actually have realized that dates are formatted according to the initial locale (taken e.g. from path), but when you change locale with $locale = 'jp'
, it updates all localized texts, but date formats remain according to the previous/initial one. This seems to be a bug
from svelte-i18n.
@cbxp @angryziber There was a bug regarding the memoization of date/time/number formatters which prevented them from being updated when the $locale
changed, see #47. Can you guys try again in v2.3.1
?
from svelte-i18n.
That's a super tip, very clean, thanks. This is a great library, I wouldn't be using Svelte without it. Hoping to do a write up on it somewhere soon!
from svelte-i18n.
Related Issues (20)
- svelte-i18n cli extract - Typescript support? HOT 11
- Engine requirement higher as necessary HOT 2
- Function to retrieve the correct translation for the current language
- Interpolation doesn't work with invalid initialLocale HOT 8
- Styling translations HOT 3
- Locale HOT 1
- a way to display translation keys instead of translation values HOT 1
- How much breaking changes?
- Translations are not rendered in +error.svelte HOT 1
- Support Svelte 4 HOT 3
- Allow unit tests with ts-node esm HOT 1
- Sveltekit: Update translation outside of component
- Variable inside html isn't replaced HOT 1
- Inform about unused language keys HOT 1
- When I hover over a <a> the site language changes to the default language. HOT 1
- `intl-getcanocicallocales` is probably not a good idea HOT 2
- CJS / ESM conflict HOT 22
- Change log version comparison links are off
- Production build using svelte-i18n ^3.7.4 throws "Named export 'IntlMessageFormat' not found." HOT 6
- Problems with LIB check in cli extractor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-i18n.