Comments (8)
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.
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?
from i18n.
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:
- User with Russian browser visited webapp
- Webapp have only Wnglish and French locales
browser
locale auto-detect store decided to use English locale.- A few months later, webapp get Russian translation
- 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.
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
from i18n.
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.
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.
Can you open another issue there to track them separately?
from i18n.
from i18n.
Related Issues (15)
- Translation preprocessor
- number, time and count functions type mismatch HOT 6
- Add HMR support HOT 1
- is there a nice way to use nanostores/i18n outside of react / react-hooks? HOT 27
- SSR Example HOT 4
- does nanostores/i18n process process lists in international way? HOT 1
- runtime error when NODE_ENV === 'production', HOT 6
- Prevent `baseTranslation` from flashing HOT 9
- Error while using useStore HOT 4
- Usage in sandboxes HOT 2
- Nesting of translations HOT 3
- Add partial translation loading HOT 2
- Generate types for `params()` automatically by TS string parsing
- Not able to change language HOT 5
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 i18n.