Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale for time functions #381

Open
make-github-pseudonymous-again opened this issue Aug 28, 2018 · 9 comments
Open

locale for time functions #381

make-github-pseudonymous-again opened this issue Aug 28, 2018 · 9 comments
Assignees
Milestone

Comments

@make-github-pseudonymous-again

Is it currently possible to format dates in, say, French, instead of English?

@hairyhenderson
Copy link
Owner

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?

@make-github-pseudonymous-again
Copy link
Author

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.

@hairyhenderson
Copy link
Owner

Ok, thanks. Environment variables are easier to support, since they don't involve changing or adding function signatures 😉

@github-actions
Copy link

github-actions bot commented May 1, 2023

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.

@github-actions github-actions bot added the Stale label May 1, 2023
@hairyhenderson hairyhenderson self-assigned this May 1, 2023
@hairyhenderson hairyhenderson added this to the v4.0.0 milestone Jun 26, 2023
@gedw99
Copy link

gedw99 commented Dec 23, 2023

@hairyhenderson this looks pretty cool.

https://github.com/goodsign/monday/ looks perfect.

I guess it never happened ?

@hairyhenderson
Copy link
Owner

@gedw99 No, this never got implemented. Can you elaborate on your use-case?

@gedw99
Copy link

gedw99 commented Jan 5, 2024

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

@hairyhenderson
Copy link
Owner

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.

@gedw99
Copy link

gedw99 commented Jan 7, 2024

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

@hairyhenderson hairyhenderson modified the milestones: v4.0.0, future Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants