go-playground/locales

Missing Duration support

niondir opened this issue · 6 comments

What abbout support for Durations?

I would need something like FmtDuration(d time.Duration) to get "20 days 10 hours 5 minutes 3 seconds"

Hey @niondir that is definitely something I would like to add in some time in the future :)

I definitely want to get the data being generated from the new JSON CLDR files rather than the old XML to make additions a little easier first though and am finding it very hard to find time to get to it though.

Any news here?

I just spend some time looking into the CLDR files. What's wrong with the XML?

As of durations I found them in /common/main/*.xml <units> in three "length" types long, short and narrow. If we add the duration "units" we could even add all units in general.

Example from en.xml:

Long:
<unit type="duration-week">
	<displayName>weeks</displayName>
	<unitPattern count="one">{0} week</unitPattern>
	<unitPattern count="other">{0} weeks</unitPattern>
	<perUnitPattern>{0} per week</perUnitPattern>
</unit>

Short:
<unit type="duration-week">
	<displayName>weeks</displayName>
	<unitPattern count="one">{0} wk</unitPattern>
	<unitPattern count="other">{0} wks</unitPattern>
	<perUnitPattern>{0}/w</perUnitPattern>
</unit>

Narrow:
<unit type="duration-week">
	<displayName>wk</displayName>
	<unitPattern count="one">{0}w</unitPattern>
	<unitPattern count="other">{0}w</unitPattern>
</unit>

Hey @nikolay-turpitko nothing is wrong with the XML per se, I want to add this along with individual format methods for seconds, minutes, hours etc in case someone only wanted the total in say minutes only.

As I said, I just am having trouble finding time getting to it, PR's are welcome :)

@joeybloggs @niondir
Guys, I'd like to help, but I have not so much free time as well.
Also, I'm not currently use this project, so not quite understand what kind of help do you need here.
If you want programming/testing/translation assistance, please be more specific and describe task in a plain English as concrete and detailed as you can. I can invest only so much of my free hours after my daily job, so it's difficult to me to investigate, digest, guess stuff and go into prolonged discussions. So, if you really need my help, please give me some context. What's going on here, what's the current state of affairs, what's need to be done, what do you think is appropriate to accomplish this task (your design view in plain English, preferably even step-by-step instruction), some test cases and references to required documentation, etc.

Thanks I will try to create a project plan in the coming weeks

BTW, (not directly related to the topic of this issue) I've stumped on some interesting related projects. Probably you are aware of them, but just in case:
https://godoc.org/golang.org/x/text/message
https://godoc.org/golang.org/x/text/feature/plural

I haven't tried them myself, currently I do not involved into any multilingual projects. Take a look, may be there is something useful.