-
Notifications
You must be signed in to change notification settings - Fork 202
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
Format feature #131
base: master
Are you sure you want to change the base?
Format feature #131
Conversation
will this work OOTB with other locales? |
Yes, it will, OOTB format will work in more or less general form for all languages. In my project i just add localization for RU manually to have better localization. However i think it should be some feedback from users before adding locales to the plugin itself (because for now it doesn't provide localization files). |
@Ximik This would be an awesome enhancement! 🎉 This project recently got new maintainers (@carlholloway), so hopefully it's easier to advance this feature now! Would it be possible to use the Unicode CLDR data for the ranges? That way multiple locales would be easy to support. As long as the tokens match with the tokens used by We'd then keep a small maintenance script in this repo, that parses the XML files from CLDR and produces JS/JSON output that can be minified into this dist. http://unicode.org/Public/cldr/31/ Example of data in CLDR:
|
i would be wary of adopting new external formats when browsers already have a locale-aware date formatting mechanism built-in. perhaps this functionality could be implemented as an optional wrapper on top of these built-in features? |
@gf3 I love the Also, |
@sandstrom such format will have issues with Russian at least, so I don't think it's good idea. Moreover, adding another config logic when there is one in the plugin itself seems like unnecessary overhead. |
@Ximik I agree it should be converted to JS/JSON. Converted it could look something like this: {
"fallback": '{0} – {1}',
"type-d": {
"diff-d": 'd – d',
},
"type-h": {
"diff-a": 'h a – h a',
"diff-h": 'h – h a',
},
"type-H": {
"diff-H": 'HH – HH',
},
"type-hm": {
"diff-a": 'h:mm a – h:mm a',
"diff-h": 'h:mm – h:mm a',
"diff-m": 'h:mm – h:mm a',
},
"type-Hm": {
"diff-H": 'HH:mm – HH:mm',
"diff-m": 'HH:mm – HH:mm',
},
// shortened for this example; there are more formats available
} With regards to adding another config logic, I don't think we'll have to. The tokens ( For a given locale (the data above is for
(this list glances over some details, but should explain the big picture) The benefit to what I described would be that instead of someone manually having to code up formats for a dozen languages, we can just import formats from CLDR. Also, if formats change or new languages are added, we'd simply re-import the xml. |
Added
format
feature similar tomoment.js
. Also added tests for it and docs.See #129