Skip to content
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

i18n versions do not parse months properly #243

Open
lllopo opened this issue Mar 6, 2015 · 3 comments
Open

i18n versions do not parse months properly #243

lllopo opened this issue Mar 6, 2015 · 3 comments

Comments

@lllopo
Copy link

lllopo commented Mar 6, 2015

Hi,
I've noticed that there is something wrong when parsing i18n months names. Did dome digging and basically got to the following :

  1. Date.parse does a "s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s));" which replaces the i18n month names with the english ones, based on the basicReplaceHash.
  2. The grammar parser though, uses the i18n regular expressions to match the month name.

The result is the if the original date is something like "01 Juli 1975", it gets converted to "01 July 1975" by the normalizer and then it is matched against "/jul(i)/", which of course does not work properly. I made a fix to the basicReplaceHash, making it to use as keys the i18n month names, but I"m not sure this is the right thing to do .... it seems to be working though :-).

@abritinthebay
Copy link
Owner

Good catch. I need to spend some quality time working on this. Issues like this specifically.

@NorbertTUZA
Copy link

Hi,
I can confirm Illopo's catch.
I've tried to feed French date piece like '2 juil' to Date.parse() and it didn't return a valid date like in case of English.
I figured out the same that s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); beside removing ordinal dates it returns English localized date, and next step grammar based parser won't find correct date so will try to parse with native. I do the modification and then it works properly:

// find ordinal dates (1st, 3rd, 8th, etc and remove them as they cause parsing issues)
//s = $D.Parsing.Normalizer.parse(parseUtils.removeOrds(s)); //removed
s = parseUtils.removeOrds(s); // newly added
d = parseUtils.grammarParser(s);
if (d !== null) {
return d;
} else {
return parseUtils.nativeFallback(s);
}

@abritinthebay
Copy link
Owner

Removing the Normailizer will break MANY other things though (like.. a lot of things, all over the place).

Good catch tho - the Normalizer should respect local strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants