Open make-github-pseudonymous-again opened 6 years ago
Hi @aureooms, thanks for logging this issue! Unfortunately right now gomplate just wraps Go's time package, which currently does not support any sort of localization.
However, there is a wrapper project https://github.com/goodsign/monday/ which I could add support for specifically translating dates & times.
Can I get some more information about your use case?
Are you wanting to be able to specify the language/locale in which to format the date, and/or are you wanting to have gomplate respect the LANG
and LC_TIME
environment variables?
Well I guess usually you would want a single language per document so environment variables would be perfect. That is my use case. But we are never sure one day someone will want to format dates in different languages in the same document.
Ok, thanks. Environment variables are easier to support, since they don't involve changing or adding function signatures 😉
This issue is stale because it has been open for 60 days with no activity. Remove stale
label or comment or this will be automatically closed in a few days.
@hairyhenderson this looks pretty cool.
https://github.com/goodsign/monday/ looks perfect.
I guess it never happened ?
@gedw99 No, this never got implemented. Can you elaborate on your use-case?
@gedw99 No, this never got implemented. Can you elaborate on your use-case?
Same as original Issue maker. The ability to convert Date and Time to different locales formats.
But also to convert to and from UTC other users locale time. This is for when you're hitting a DB that holds all data time values in UTC. SO its just converting the values, not the format.
Pretty standard stuff for any i18n situation. You typically first need to convert the data, and then convert the format ( for any gui ).
Is that clear ?
Thanks @gedw99.
In the very simple case of converting time zones, that's already supported with functions like time.ParseInLocation
, and converting from some timezone to UTC can be done with the UTC
function on the parsed time.Time
value.
For converting from UTC to local time you can use Local
, which uses the TZ
environment variable to inform which zone to use.
Anyway, that brings us back to locale-specific formatting, which is of course not yet supported.
I'd be willing to review a PR to add support for it, but I don't have the bandwidth to work on it myself right now.
Thanks @hairyhenderson
I guess I should have looked harder at the docs.
Regarding a PR and the local-specific formatting, I guess we first need locale detection as an option, rather than the TZ environment variable.
https://github.com/gioui/gio-x/tree/main/pref/locale for example
Is it currently possible to format dates in, say, French, instead of English?