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

Add support for formatting intervals #276

Closed
xmo-odoo opened this issue Oct 14, 2015 · 7 comments
Closed

Add support for formatting intervals #276

xmo-odoo opened this issue Oct 14, 2015 · 7 comments

Comments

@xmo-odoo
Copy link
Contributor

The LDML has defined an intervalFormats for locale-aware interval formatting since UTS#35 revision 10. Since Babel has added support for formatting durations (timedeltas) it would be convenient to support intervals as well.

@sils
Copy link
Member

sils commented Oct 14, 2015

@xmo-odoo thanks for proposing this, we're happy to accept pull requests, probably no time to do this soon on our own.

@xmo-odoo
Copy link
Contributor Author

@sils1297 is there documentation for the current content of locale dat files (and/or the mapping between the CLDR and locale dat files) aside from the import script and localedata.py? I tried looking quickly if the interval formats were currently parsed/stored but that doesn't seem to be the case so it looks like this issue would require alterations to the CLDR import script, that correct?

@sils
Copy link
Member

sils commented Oct 14, 2015

@xmo-odoo sorry, I'm not that much into this and can't help you without more time effort. Try asking on gitter, @etanol usually knows his way around :)

@etanol
Copy link
Contributor

etanol commented Oct 14, 2015

@xmo-odoo Yes, the import script does not process all the locale features described in CLDR. So, whenever we need to implement new functionality from the XML files, we change the import script first.

The .dat files are just pickle files. There is no formal documentation because those files are tightly coupled to the package and not intended to be exchanged or reused across releases. This also allow us to change their format whenever we need it.

Therefore, if you would like to implement new functionality, the first step is always to modify the CLDR import script as desired in an independent commit. Then, change the affected module based on the changes to the .dat files.

@xmo-odoo
Copy link
Contributor Author

Thanks @etanol

After more spec-reading to see if I could implement it quickly, it looks like this requires way more work than I'd originally expected:

  • intervals use skeletons so Add support for date-time skeletons #265 and closest-match resolution (which Add support for date-time skeletons #265 doesn't seem to include) are probably needed
  • it also requires extracting parts of parse_pattern to get and split fields sequences, not sure whether DateTimePattern should be changed to have more semantic content or some other intermediate structure should be extracted (and compiled into a DateTimePattern)

@akx
Copy link
Member

akx commented Jan 3, 2016

I'll take a look at this. :)

@akx
Copy link
Member

akx commented Jan 3, 2016

For what it's worth, @xmo-odoo, it looks like closest-match resolution might not be needed for an MVP (though I'll look at implementing that too). The skeletons provided by CLDR 28 at present seem to be fairly homogeneous, aside from a couple outliers (at the bottom).

# List of intervalFormat skeletons in use in CLDR 28; format skeleton/count.
[
 ('d', 755),
 ('h', 755),
 ('H', 755),
 ('Hm', 755),
 ('hm', 755),
 ('Hmv', 755),
 ('hmv', 755),
 ('hv', 755),
 ('Hv', 755),
 ('M', 755),
 ('Md', 755),
 ('MEd', 755),
 ('MMM', 755),
 ('MMMd', 755),
 ('MMMEd', 755),
 ('y', 755),
 ('yM', 755),
 ('yMd', 755),
 ('yMEd', 755),
 ('yMMM', 755),
 ('yMMMd', 755),
 ('yMMMEd', 755),
 ('yMMMM', 755),
 ('MMMM', 86),
 ('yMMMMEd', 49),
 ('MMMMEd', 41),
 ('yMMMMd', 41),
 ('MMMMd', 33),
 ('yMMMEEEEd', 5),
 ('yMMMMEEEEd', 2),
 ('MMMEEEEd', 2)
]

akx added a commit to akx/babel that referenced this issue Jan 4, 2016
akx added a commit to akx/babel that referenced this issue Jan 4, 2016
akx added a commit to akx/babel that referenced this issue Jan 4, 2016
akx added a commit to akx/babel that referenced this issue Jan 4, 2016
akx added a commit to akx/babel that referenced this issue Jan 8, 2016
akx added a commit to akx/babel that referenced this issue Jan 8, 2016
akx added a commit to akx/babel that referenced this issue Jan 8, 2016
akx added a commit to akx/babel that referenced this issue Jan 8, 2016
akx added a commit to akx/babel that referenced this issue Jan 11, 2016
akx added a commit to akx/babel that referenced this issue Jan 11, 2016
akx added a commit to akx/babel that referenced this issue Jan 12, 2016
akx added a commit to akx/babel that referenced this issue Jan 12, 2016
akx added a commit to akx/babel that referenced this issue Jan 23, 2016
akx added a commit to akx/babel that referenced this issue Jan 23, 2016
akx added a commit to akx/babel that referenced this issue Jan 23, 2016
@akx akx closed this as completed in #316 Jan 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants