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

The added date is mm/dd/yyyy, should be localised and/or configurable #123

Closed
PaulBags opened this issue Dec 13, 2020 · 13 comments
Closed

Comments

@PaulBags
Copy link

PaulBags commented Dec 13, 2020


name: 'πŸ› Bug Report'
about: 'Report a general bug'

Type: Bug Report

  • [ βœ… ] Try to follow the update procedure described in the README and try again before opening this issue.
  • Also checked Config.ts in case there was some hidden setting I was missing (though localisation should be per user).

Your Environment

  • Version used:
    • Version (stable release)
      4.3.1
    • Commit ID (development release) git --no-pager log -1
  • Environment name and version:
    • Node.js version node --version
      v12.19.0
    • npm version npm --version
      7.1.0
    • Web browser name and version
      Firefox version 83.0
  • Operating system and version:
    Windows 10 v20H2
  • Torrent client and version:

Summary: dates are wrong

For me mm/dd/yyyy is specifically wrong, confusing, & neigh unreadable. yyyy-mm-dd would be my preference (and an international standard, readable by everyone 😊) but even dd/mm/yyyy would be better.

Edit: I'm updating this to a bug report, because frankly the date format is completely incorrect if being tied to the language English. The date format used is American.

Expected Behavior: being able to read the date.

Current Behavior: date format unreadable.

Possible Solution

My solution would be a place for a setting in settings > user interface, directly under the language setting.
Could be a drop down menu with predetermined formats, a field for entering a custom format - or both, with custom being an option in the drop down menu.

Steps to Reproduce N/A

Context

@jesec
Copy link
Owner

jesec commented Dec 13, 2020

It depends on your language.

I tried different languages, and it seems that the date is properly formatted.

English:
image

ζ—₯本θͺžοΌš
image

@PaulBags
Copy link
Author

That's not how this works, date formats are tied to countries - not languages.

There are english speaking countries that officially use dd/mm/yyyy and only dd/mm/yyyy. Language selection is not an answer.

And besides, people may have preferences that differ from their localisation.

@PaulBags
Copy link
Author

Hmm. I've been poking around crowdin, but I can't figure out how to touch english or add any of the localised englishes as a target language so that I can fix the date.

I assume crowdin is the correct tool, unless I have to go off and fix the date formatter in react...

@PaulBags
Copy link
Author

I'm updating this to a bug. English language uses dmy, a similar language called American uses mdy. The localisation for English is incorrect and since it's the projects root language it's uneditable.

@PaulBags
Copy link
Author

PaulBags commented Dec 13, 2020

Oh and well I'm here: language won't stay on specifically English. Reverts to Automatic.

Ok now it is. Maybe I got too upset to hit save settings? πŸ€·β€β™‚οΈ

@PaulBags
Copy link
Author

Ah, I see that client/src/javascript/util/detectLocale.ts is specifically ignoring localisations. That won't help.

@PaulBags
Copy link
Author

PaulBags commented Dec 13, 2020

Console output showing overriding to be the source of the problem:

(new Date()).toLocaleDateString();
"14/12/2020"
Intl.DateTimeFormat().format(new Date())
"14/12/2020"
Intl.DateTimeFormat('en').format(new Date())
"12/14/2020"
Intl.DateTimeFormat('en-GB').format(new Date())
"14/12/2020"
Intl.DateTimeFormat('en-GB'.substr(0,2)).format(new Date())
"12/14/2020"

@jesec
Copy link
Owner

jesec commented Dec 14, 2020

Currently Flood uses FormattedDate of react-intl. It uses the current language settings, and I don't think it has the capability to specify different date format.

@PaulBags
Copy link
Author

PaulBags commented Dec 14, 2020

"It uses the current language settings"

It's not, check your own code: flood is truncating locales.

Sorry let me rephrase. Yes react-intl is using current locale, however flood is setting locale by truncating where there isn't an existing match. This is good enough for string translation, but affects date format - and possibly affects decimal seperator elsewhere as well.

jesec added a commit that referenced this issue Dec 14, 2020
@jesec
Copy link
Owner

jesec commented Dec 14, 2020

detectLocale now respects the locale of user and passes it to the IntlProvider. Though, Flood still uses the old behavior if you specify language manually. I think it would be too much maintenance burden for the project if a separate manual selection menu needs to be added for locale.

@PaulBags
Copy link
Author

PaulBags commented Dec 14, 2020

Or a single very long list of "languages"/locales.

This is an elegant solution which is working well, thank you. I'm impressed.

P.S. if anyone does want to take this further I boiled the English locales down to four "types": en, en-CA, en-001, and en-150.

en uses `mdy` date formats and the decimal seperator `.`
 locales: en, en-AS, en_BI, en_GU, en_MH, en_MP, en_PR, en_UM, en-US, en-US-POSIX, en_VI
en-CA uses `ymd` date formats and the decimal seperator `.`
 locales: en-CA, en_SE, en-ZA
en-150 uses `dmy` date formats and the decimal seperator `,`
 locales: en-<any in Europe>
en-001 uses `dmy` date formats and the decimal seperator `.`
 locales: en-<rest of world>

But, frankly, that way lays madness.

@GitHubGeek
Copy link

Thanks guys, the dates look much better now in Flood. en-GB locale now shows dd/mm/yyyy

@lwbt
Copy link

lwbt commented Aug 6, 2024

Using a format that users of a certain locale typically expect is probably fine. But at least an option to switch to ISO 8601 YYYY-MM-DD should be provided. I'm German, I often use English and whenever I have to use a date format it is ISO 8601 (date -I in bash scripts). Then I have one thing less to worry about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants