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

Format date range in in activity page according to locale #21387

Closed
wants to merge 1 commit into from
Closed

Format date range in in activity page according to locale #21387

wants to merge 1 commit into from

Conversation

yardenshoham
Copy link
Member

Fixes #21380

Before this PR, the date range on the activity page was hardcoded in English. This PR adds functionality so that the date range would respect the chosen locale.

For example:
image

Fixes #21380

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
@wxiaoguang
Copy link
Contributor

It's not the proper way to do i18n for date & time.

As a quick fix, the ISO format "2000-01-02" could be better, everyone could understand it.

As a complete fix, the i18n module should have the ability to translate date & time flexibly for all languages, not just replacing the month.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 10, 2022
@yardenshoham
Copy link
Member Author

Gotcha, I was focused on #21380. I was not trying to provide a complete solution. I do believe this PR resolves #21380, but I understand why you wouldn't want it merged.

How do you imagine the complete fix going? I might give it a shot

@wxiaoguang
Copy link
Contributor

At the moment, Gitea's i18n module is also at the early stage, which couldn't properly handle all needs for i18n. I can not think about a feasible plan for the complete solution before Gitea's i18n module gets improved significantly.

That's why I also mentioned a "quick fix", the ISO format is widely used and easy to understand, I can L-G-T-M for the quick fix 😁

@yardenshoham yardenshoham deleted the months branch October 10, 2022 12:25
lafriks pushed a commit that referenced this pull request Oct 12, 2022
…ity page (#21410)

# Description
Previously, to make the date range understood by all, we used the format
"2006-01-02" for the dates as it's locale-generic.

This commit changes the rendering logic. Instead of rendering the date
on the server, we send a formatted computer-readable timestamp. The
client's javascript then renders it according to the user's locale.

This approach is reusable across the codebase, any `<time></time>` tag
with the data-format="date" attribute would get rendered according to
the user's chosen locale.

## Previous View

![image](https://user-images.githubusercontent.com/20454870/195099143-e1c5df86-282a-42f1-898f-a36bb5fe7c2f.png)

## New View

### English

![image](https://user-images.githubusercontent.com/20454870/195099301-5cda4eab-4012-49d5-97e5-b1f9cada9c06.png)

### French

![image](https://user-images.githubusercontent.com/20454870/195099434-ce23e394-8d65-4c4c-8ac8-8b96bc9044f3.png)

### Portuguese

![image](https://user-images.githubusercontent.com/20454870/195099559-9a7aed28-944a-45ec-bedb-64403e3faede.png)

### Italian

![image](https://user-images.githubusercontent.com/20454870/195099661-17758d55-3fe0-4797-879b-d45de0ee8ba3.png)

# References
* #21380 
* #21387
* #21396

Inspiration:

I think either differentiating by class, or probably better by a custom
attribute such as `data-format` or similar, is the best course of
action.

_Originally posted by @delvh in
#21396 (comment)
      


Resolves #21380

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date range in activity page is not localized
3 participants