Closed deankarn closed 9 years ago
Hi @joeybloggs!
Currently there's not a way to get at that data.
There's a missing feature in the date/time formatting that allows a datetime to be arbitrarily formatted. Like so:
// signature
func (t *Translator) FormatDateTimeCustom(format string, datetime time.Time) (string, error) { ... }
// usage
str, err := t.FormatDateTimeCustom("MMMM", dt)
// produces (en): January
This hasn't been implemented yet, but it would be nice and would open up all of the date/time component translations for usage. If you feel so inclined to implement this (or some other way of accessing these strings), please make a pull request!
Hi @verkestk
I was thinking of how to expose the rules, or specific rule data and thought that it couldn't really hurt to expose all of the rule data instead of just portions by defining multiple functions.
I then thought what would be the best way to expose it, via a pointer would be the most efficient off of the Translator struct but could potentially cause issues if someone tries changing the values while doing some sort of multithreading; the alternate would be to define a function to return the dereferenced Rules avoiding the issue, but less efficient.
It would all depend on how you wanted to handle this is your library, so I did both and you should see 2 pull requests one with each approach taken.
P.S. I would still like to create some functions to expose the Day, Month data as a map[int]string so that golang's build in day and month constants could be used, but will have to wait and see how you would like to expose the rules.
@joeybloggs looking into merging #8, pending some testing on our side.
Thanks
any word on the progress? definitely not trying to sound pushy just curious as I have a project that can use this change and need to know if I will have to create my own month and day of week messages or will have direct access
thanks in advance!
I was wondering if it was possible to access data from within the defined rules?
for example in en.yaml there is a section for abbreviated months "Jan, Feb, Mar...." is there a function to get that data for use within the application?
not having duplicate this information into messages within the application would be quite the time saver.
I couldn't find anything in the documentation about it, however am still new to the library.
Thanks in advance.