cljs-time icon indicating copy to clipboard operation
cljs-time copied to clipboard

Support internationalised formatting

Open Looveh opened this issue 8 years ago • 7 comments

It would be very useful to get support for formatting dates in other languages than English, considering the amount of internationalised ClojureScript out there.

Google's closure library already has mature support for this so it might be a good idea to wrap the goog.i18n module for human readable formatting: https://google.github.io/closure-library/api/goog.i18n.html

Looveh avatar Jan 31 '17 11:01 Looveh

+1 Also highly interested in unparsing datetime objects into strings with months and weekdays names in other languages than English. Do you have plans to implement this?

monstasat avatar Feb 12 '17 13:02 monstasat

I'd love for cljs-time to have i18n support, but as a typical anglophone I don't have any personal need for it. So unfortunately it's not that high on my priority list.

Would accept a PR ;)

andrewmcveigh avatar Feb 13 '17 11:02 andrewmcveigh

Having thought about it, I'd like to do something about this. I'm working on a branch https://github.com/andrewmcveigh/cljs-time/pull/85

I'm not 100% sure on the API, but I think it would work as follows.

By default, cljs-time would use the locale symbols set in goog.i18n.DateTimeSymbols, but you could override this with the following code.

(cljs-time.format/with-locale (cljs-time.format/formatter "EEEE dd MMMM yyyy") "pt_BR")

Does that sound reasonable?

Thanks to @CarlosSam for contributing https://github.com/andrewmcveigh/cljs-time/pull/77

andrewmcveigh avatar Feb 15 '17 06:02 andrewmcveigh

@andrewmcveigh , that sounds great! I think this is reasonable as it mimics clj-time (joda-time) API. Thank you for implementing this!

monstasat avatar Feb 15 '17 12:02 monstasat

@andrewmcveigh , when do you plan to merge branch with i18n support into master and release a new version of cljs-time?

monstasat avatar Apr 11 '17 19:04 monstasat

@andrewmcveigh I'm very interested in this as well.

gphilipp avatar Jun 06 '17 10:06 gphilipp

Any update on this?

Grahack avatar Sep 24 '17 12:09 Grahack