Skip to content

[bugfix] Fix locale autoload, revert #3344 - #3438

Closed
ichernev wants to merge 1 commit into
moment:developfrom
ichernev:fix-locale-autoload
Closed

ichernev wants to merge 1 commit into
moment:developfrom
ichernev:fix-locale-autoload

Conversation

@ichernev

Copy link
Copy Markdown
Contributor

This is a redo of #3344 that doesn't (hopefully) break karma + phantomjs -- #3431.
@ljharb @yiminghe let me know if that works for both of you.

@ljharb

ljharb commented Sep 15, 2016

Copy link
Copy Markdown

I'm afraid not - with 2.15 + this diff, i'm now getting "SyntaxError: import declarations may only appear at top level of a module". I think this approach is defeating babel-node or webpack, because it's not a static require() call.

@ichernev

Copy link
Copy Markdown
Contributor Author

How about now?

@ljharb

ljharb commented Sep 15, 2016

Copy link
Copy Markdown

That seems to do it for me, thanks! Looking forward to the patch release :-D

@ljharb ljharb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@Aanal

Aanal commented Sep 19, 2016

Copy link
Copy Markdown

@ichernev thanks for fixing. Do you know when is the next patch release?

@ichernev

Copy link
Copy Markdown
Contributor Author

I'll only revert #3344 for now, and release 2.15.1

@ichernev

Copy link
Copy Markdown
Contributor Author

Merged in 0d67e7e

@ichernev ichernev changed the title Fix locale autoload [bugfix] Fix locale autoload, revert #3344 Sep 21, 2016
@ichernev ichernev closed this Sep 21, 2016
ichernev added a commit that referenced this pull request Sep 21, 2016
[bugfix] Fix locale autoload, revert #3344
ljharb added a commit to react-dates/react-dates that referenced this pull request Sep 21, 2016
@mattjohnsonpint mattjohnsonpint added this to the 2.15.1 milestone Sep 21, 2016
@gfviegas

gfviegas commented Oct 6, 2016

Copy link
Copy Markdown
import moment from 'moment';
import 'moment/locale/pt-br';

moment.locale('pt-br');
console.log(moment.locale()); // en
console.log(moment.locale('pt-br')); // en
console.log(moment.locale('pt-BR')); // en

Locale still doesnt work for me..
Using moment 2.15.1 in Ionic 2 RC0

@ichernev

ichernev commented Oct 6, 2016

Copy link
Copy Markdown
Contributor Author

@gfviegas can you print output of moment.locales(). You can put a few prints in the code to figure out is the thing loading or not. Also, if you're loading the locale yourself (and you are) this change is not relevant for you.

@gfviegas

gfviegas commented Oct 6, 2016

Copy link
Copy Markdown

@ichernev the output is:

["en"]

Am I doing something wrong to import the locale? It stopped working when I upgraded my Ionic to RC 0

@gfviegas

Copy link
Copy Markdown

Any thoughts on my issue?

@ichernev

Copy link
Copy Markdown
Contributor Author

@gfviegas your locale is not getting loaded. Put a console.log in it. Or it is, but it can't load moment, so it can't attach itself properly. This is not the most complicated system, and so far you're the only one complaining, so I'm expecting to be something in your setup (that is simple to debug), rather than a bug in moment.

@gfviegas

Copy link
Copy Markdown

@ichernev thing is I don't know where I'm wrong on importing it. I'm following exactly the same example of the docs. Is my import code right?

@ichernev

Copy link
Copy Markdown
Contributor Author

I said you need to debug it, I didn't say who is wrong or right, just where I'd expect to see the issue. You need to specify a reproducible environment if you want any external help. Most likely if you try to reproduce it cleanly you'll find the issue. Anyway, you can start by putting a few prints and seeing whether the locale file is downloaded and executed to start with.

@gfviegas

gfviegas commented Oct 24, 2016 •

Copy link
Copy Markdown

@ichernev I had to

import 'moment/src/locale/pt-br';

instead of

import 'moment/locale/pt-br';

to make it work. I have no idea why.

MarcoAntonioAG added a commit to MarcoAntonioAG/React-dates that referenced this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants