Skip to content

Add support for formatting intervals #276

Closed

Description

@xmo-odoo

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.

Activity

  1. sils commented on Oct 14, 2015

    @sils
    Member

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

  2. xmo-odoo commented on Oct 14, 2015

    @xmo-odoo
    ContributorAuthor

    @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?

  3. sils commented on Oct 14, 2015

    @sils
    Member

    @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 :)

  4. etanol commented on Oct 14, 2015

    @etanol
    Contributor

    @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.

  5. xmo-odoo commented on Oct 15, 2015

    @xmo-odoo
    ContributorAuthor

    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)
  6. akx commented on Jan 3, 2016

    @akx
    Member

    I'll take a look at this. :)

  7. self-assigned this
    on Jan 3, 2016
  8. akx commented on Jan 3, 2016

    @akx
    Member

    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)
    ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions