Code Monkey home page Code Monkey logo

Comments (5)

rodoch avatar rodoch commented on July 26, 2024 1

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.

kaisermann avatar kaisermann commented on July 26, 2024 1

@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.

cbxp avatar cbxp commented on July 26, 2024

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.

kaisermann avatar kaisermann commented on July 26, 2024

@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.

rodoch avatar rodoch commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.