New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
locale changes does'nt work #2962
Comments
Are you using a module loader that may be giving you a different instance of moment?
|
I'm in an angular project, modules are handles with JSPM. The 3 lines are real code I tried, using the same moment in the same method.
results are :
|
Are you importing the locale data? Which .js file(s) are you using? |
Do you mean adding another import after the line: or import in the module sens, here with JSPM. |
Read through the "Where to use it" section of the docs and see if any of those scenarios apply to you. In general, you either need to be using Basically, if you try to switch to a locale that's not loaded, moment will revert to the |
See also "Loading locales in the browser". |
I'll experiment what I can whith this. I then use it with a single import: I wrote it in this comment to keep a track for future users who may have the same usage. |
I added: and using: now sets properly the locale to french. I can close it I think and thanks for all people who answered. |
Maybe add this to the documentation. I had the same issue and more and more people start using jspm instead of Bower. |
Glad you got it working! I added an issue to the docs repo. Feel free to send a PR there. |
import like that |
Thanks @younss, your method worked for me. I'm using Ionic 2 RC 2. |
@younss you are my savior! it's 10/10/2017 and the docs don't specify this change! updated from moment 2.18 to 2.19.0 and locales imports completely crashed :( |
I had the same problem when I updaded to the 2.19.1 Remove :
Re-launch: I keep import 'moment' normally and use locale in my sources. So no need to import as @younss did. Maybe the pb is in the package-lock.json file which do not update the moment node data properly. By removing it and re-launching npm install it create a new package-lock.json file with all data updated. |
@younss, thanks , works for me, i am using parcel-bundler |
This Solution Worked for me.. Here
|
Did this change again?
I created a class with one function:
The logs are as follows:
|
It works for me thanks! |
I use:
and it works. |
import moment from 'moment/dist/moment';
import 'moment/dist/locale/ru';
moment.locale('ru'); The only works for me. @ligne13 Thanks for the hint! moment 2.25.2 |
Hi, When using 'import 'moment/locale/fr';' in my Node/Express App, I got this error : "SyntaxError: Cannot use import statement outside a module". I googled this and I try to add --experimental-modules --es-module-specifier-resolution=node flags but now my app is a mess. If I can't add this import, is there another way to change the locale ? Thanks Paul Specs :
|
You can't use 'import' in node.js yet. I haven't tried it myself, but I reckon that this would work:
|
Form 2022 onward you have to import as follows.
|
This is the shortest version that works for me:
Working with Vue |
using import 'moment/dist/locale/de', I get an error when reloading the page(export default hooks;SyntaxError: Unexpected token 'export'). How can I fix this |
this is work for me |
When I try to change the locale value, nothing happens, not even error.
I also tried from the Chrome developer tools console:
The text was updated successfully, but these errors were encountered: