-
Notifications
You must be signed in to change notification settings - Fork 443
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 date-time skeletons #265
Conversation
Current coverage is
|
Interesting. However, dedicated test code is missing. I know, doctests should cover it but I have a feeling that, if not me, somebody else will ask you for it. |
I found this while looking into intervals (as they use skeletons), this PR implements basic support for skeletons, but doesn't seem to support skeleton matching (see "matching skeletons" sub-section) and match adjustment, is that normal/intentional? I also am not sure about the inheritance support: the spec states
which I read as each skeleton ( |
@etanol uhm I'mnot quite sure I agree with you here, that would mean that we have redundant tests which is nothing but a maintenance overhead, am I wrong? |
@sils1297 Yes, they are an overhead. However, if you check the test suite you will find that there are quite a few tests that are identical to the corresponding docstring. Since I don't know the whole history of Babel, I'm not clear on how this redundancy originated. |
@etanol so we probably want to avoid redundancy from now on and approve PRs that remove identical tests, agreed? Code duplication is bad and doctest is a great invention to reduce testing overhead, we should use that advantage IMO. |
5519960
to
8f301f1
Compare
@sils1297 I've removed the commit which added the extra tests from this PR. @xmo-odoo I'll be honest I did the minimal here that I needed for my use-case. Which didn't include skeleton-matching although that looks nice I think this is still useful without that. Inheritance however seems to have been handled for me by babel's CLDR import mechanism. e.g. there is no 'hm' skeleton in the en_GB.xml file but the following works:
|
In CLDR 26, which babel is currently using there is a partial list of skeletons that appears to get correctly merged with the parent locale (en_US I think in CLDR 26, although I believe that is also changing). |
@mbirtwell ok, good to know then (I only checked 23.1 — used by the last release — and 28 — latest CLDR — and neither has "partial" skeletons lists) |
@mbirtwell Could you please rebase on top of 2.2.0? One doctest will also need updating based on the current CLDR data. ================================== FAILURES ===================================
_______________ [doctest] babel.core.Locale.datetime_skeletons ________________
EXAMPLE LOCATION UNKNOWN, not showing all tests of that example
??? >>> Locale('fr').datetime_skeletons['MEd']
Expected:
<DateTimePattern u'E d/M'>
Got:
<DateTimePattern 'E dd/MM'>
==================== 1 failed, 520 passed in 5.28 seconds ===================== |
The skeletons for dates and times are described on http://cldr.unicode.org/translation/date-time-patterns under Additional Date-Time Formats. And are useful when you want to some more control over formatting dates and times but don't want to force all locales to use the same pattern.
8f301f1
to
65e20c1
Compare
Thanks @mbirtwell! 🎉 |
Add support for date-time skeletons
The skeletons for dates and times are described on
http://cldr.unicode.org/translation/date-time-patterns under
Additional Date-Time Formats. And are useful when you want to some more
control over formatting dates and times but don't want to force all
locales to use the same pattern.