GithubHelp home page GithubHelp logo

Comments (8)

ai avatar ai commented on August 16, 2024

Thanks for very well-formed issue report.

The quick fix is to move i18n() functions out from React component:

let messages = i18n("hello", {
  helloWorld: "Hello World"
});

export default () => {
  const t = useStore(messages);

We can detect when component was defined with the same name and print a warning to avoid these mistakes in the future. What do you think?

from i18n.

azat-io avatar azat-io commented on August 16, 2024

Thanks for the answer!

Also I need to know which language was selected on app first render. I'm creating persistentAtom store which default value is undefined and put it as localeSettings to my createI18n() function. Is there any way to update atom store from localeSettings here?

image

from i18n.

ai avatar ai commented on August 16, 2024

Is there any way to update atom store from localeSettings here?

I recommend to set localeSettings store only when user manually changed locale.

The reason is in this use case:

  1. User with Russian browser visited webapp
  2. Webapp have only Wnglish and French locales
  3. browser locale auto-detect store decided to use English locale.
  4. A few months later, webapp get Russian translation
  5. Old users will not see new Russian translation because after first visit English locale was written in localStorage

Also I need to know which language was selected on app first render

Can you use locale store (created by localeFrom)? This store was created to be the single source of truth of current locale.

from i18n.

azat-io avatar azat-io commented on August 16, 2024

I recommend to set localeSettings store only when user manually changed locale.

Agree with you, thanks!

And the last question: it looks like there is a problem with deleting language data from storage after opening the site in the second browser tab

Untitled

from i18n.

ai avatar ai commented on August 16, 2024

I added check to prevent multiple definitions 0344aa4

it looks like there is a problem with deleting language data from storage after opening the site in the second browser tab

Very strange. Can you repeat the issue with another @nanostores/persistance store outside of I18n?

from i18n.

azat-io avatar azat-io commented on August 16, 2024

Very strange. Can you repeat the issue with another @nanostores/persistance store outside of I18n?

I have updated my test web page. Looks like this is a problem with @nanostores/persistent package. Sorry.

from i18n.

ai avatar ai commented on August 16, 2024

Can you open another issue there to track them separately?

from i18n.

azat-io avatar azat-io commented on August 16, 2024

nanostores/persistent#14

from i18n.

Related Issues (15)

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.