andrewmcveigh / cljs-time

A clj-time inspired date library for clojurescript.
342 stars 57 forks source link

Support internationalised formatting #84

Open Looveh opened 7 years ago

Looveh commented 7 years ago

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

monstasat commented 7 years ago

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

andrewmcveigh commented 7 years ago

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 commented 7 years ago

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

monstasat commented 7 years ago

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

monstasat commented 7 years ago

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

gphilipp commented 7 years ago

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

Grahack commented 6 years ago

Any update on this?