Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

language mixup on traffic #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

aymanc
Copy link

@aymanc aymanc commented Sep 10, 2017

I noticed if i format a specific language in my handlebars using the helpter-date, the change is then propagated to the rest of my node project through the moment library. Also, the languages get jumbled up within the helper when under considerable multilingual traffic.

I made the following changes, i've noticed this module is under a lot of different names although i posted it here for it being used under handlebars-helpers

Hope it helps,

The changes are mentioned below

...
// moment.locale('en'); ---- So the thing is that:
// The changes you do in this helper via something like {{moment lang='fr'}}
// will affect your moment package settings being used in your project. if u're doing multilingual it's a problem
// You want to remove this and be dependant on the locale in your project whatever it may be.
// english being the default anyway

...

// set the language to use
// moment.locale(opts.lang); ---- Ok So The Same thing here.
// you want to use the locale setting option inside the moment() function instead for it to be a one time thing

if (opts.datejs === false) {
return moment(new Date(str), null, opts.lang).format(pattern); // As such
}
...

Ok so i noticed if i format a specific language in my handlebars, the change is then propagated to the rest of my node project
i made the following changes, and i hope this helps. i've noticed this module under a lot of different names although i posted it here for it being used under handlebars-helpers

Hope it helps, 
Best, Ayman.


The changes are mentioned below

...
// moment.locale('en'); ---- So the thing is that: 
    // The changes you do in this helper via something like {{moment lang='fr'}}
    // will affect your moment package settings being used in your project. if u're doing multilingual it's a problem
    // You want to remove this and be dependant on the locale in your project whatever it may be. 
    // english being the default anyway

...

// set the language to use
  // moment.locale(opts.lang); ---- Ok So The Same thing here. 
  // you want to use the locale setting option inside the moment() function instead for it to be a one time thing
  
  if (opts.datejs === false) {
    return moment(new Date(str), null, opts.lang).format(pattern); // As such
  }
...
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant