Help - translations are not show before calling msgfmt.setLocale()
Hi, I am new to MessageFormat and are having some problems. Since the doc-site is down I am trying to get it running with the info here on github. Maybe I am missing something fundamental.
I am using meteor and React. I have installed the packages and I have got it running kind of. I have native locale 'en' and translations in 'sv'. The translations are not showing on the page untill i call setLocale('en') and then setLocale('sv'). If I call setLocale('sv') first it says "setLocale (already loading) sv". After changing to 'en' and back to 'sv' the translations are showing untill the next page refresh.
I have put msgfmt.init('en') to be loaded first on bouth the client and server code. setLocale('sv') is not in the code - I call it on the console right now to change language.
Does anyone have a suggestion why this is happening? //Jonas
Hey @alvestjo. As per other issue docs are back up. Just note that any info in the READMEs supersede info on the online docs.
Seems like the initial load is getting stuck somewhere. Can you:
msgfmt.init('en', {
logLevel: 'debug' // or 'trace'
})
and see if anything obvious crops up, otherwise paste the full debug output here?
Thanks for your reply. On the client side I get this log-output when the page is loading: debug: [msgfmt] [Q] Found stored locale "sv" debug: [msgfmt] [Q] setLocale sv true debug: [msgfmt] [Q] locale set to sv debug: [msgfmt] [Q] fetchLocale request for "sv", have latest already, aborting debug: [msgfmt] [Q] Meteor.startup(), 140ms after script loading debug: [msgfmt] clientInit, 3767ms after script loading
After the page is loaded i try to type on the console: msgfmt.setLocale('sv'); And get this log row back: debug: [msgfmt] setLocale (already loading) sv
I will try to debug it more later today or tomorrow.
BTW: I am using Webpack. Can this be a issue? //Jonas
Hi again, I have now done some debuging and I think I have found the problem.
It seems to be a problem with your React component. Since you are setting this.state.LOCALE='en' in the constructor this is the language that will be used unless you specify the props.LOCALE on each instance. You say in the README "If LOCALE is not specified, we reactively use msgfmt.locale().", but this is not true as I see it.
//Jonas
Hey, wow, looks like I got ahead of myself when I did this. Thanks for tracking this down! It's not well tested but can you give msgfmt:[email protected] a spin and let me know if solves the problem?
Hi
@alvestjo @gadicc
Updating to 2.0.1 I have this error,
modules-runtime.js?hash=8587d18…:231 Uncaught Error: Cannot find module 'msgfmt' at makeMissingError (modules-runtime.js?hash=8587d18…:231) at require (modules-runtime.js?hash=8587d18…:241) at react.js (react.js:13) at fileEvaluate (modules-runtime.js?hash=8587d18…:343) at require (modules-runtime.js?hash=8587d18…:238) at msgfmt_react.js?hash=80e37a2…:225 at msgfmt_react.js?hash=80e37a2…:236
do you have any idea how to fix it?