Opened 10 years ago
Last modified 3 months ago
#36259 assigned defect (bug)
Switching language should update date and time formats
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | I18N | Keywords: | good-first-bug changes-requested needs-unit-tests has-patch |
| Focuses: | Cc: |
Description (last modified by )
Previously: #11226
- Install WordPress in English.
- Switch language to Russian.
- Date and time formats in General Settings are still
F j, Yandg:i a, which doesn't make sense for Russian and doesn't match the locale defaults (d.m.YandH:i, respectively).
Attachments (4)
Change History (27)
#2
@
10 years ago
This would need to account for those who have set their own date and time formats though, so as not to override user settings that may differ from what we expect from a locale.
It could work by not saving the date and time formats to the database until they differ from the ones specified by the locale.
This ticket was mentioned in Slack in #core-i18n by ocean90. View the logs.
10 years ago
#5
@
10 years ago
- Keywords needs-refresh good-first-bug added
- Milestone changed from Awaiting Review to Future Release
#6
follow-up:
↓ 8
@
10 years ago
- Keywords has-patch added
In 36259.patch, if the locale's default date/time format is used, after the update the new locale's default values will be used. In any other case the code works as before.
#8
in reply to:
↑ 6
@
10 years ago
Replying to vagios:
In 36259.patch, if the locale's default date/time format is used, after the update the new locale's default values will be used. In any other case the code works as before.
I just tested this patch, and if left on the default time format it changes to the one specific to the chosen country.
Before applying the patch I confirmed that the old local was going into the custom format and active.
#9
@
9 years ago
- Owner set to vagios
- Status changed from new to assigned
Assigning ownership to mark the good-first-bug as "claimed".
#12
@
7 years ago
- Milestone changed from 5.1 to Future Release
Patch needs a refresh, testing, and review.
#14
@
4 years ago
It is all good to mark https://core.trac.wordpress.org/ticket/54923 as duplicate but this is a six year old bug, which still has no defined milestone. How can we attract attention to it?
I find it strange that a bug that allowed a general setting, which has a dedicated page, to fail for six years. (I assume the code is the same between .com and .org.)
#15
@
3 years ago
I agree with @sarumbear this seems to be forgotten about. I have custom post types that use the published date and it is confusing and irritating not being able to change the dates in the admin to UK format i.e. dd/mm/yyyy. Please get this looked at.
#16
@
2 years ago
- Keywords needs-testing needs-unit-tests added; needs-refresh removed
I've updated the patch to work with the current WordPress version. Also, in the original patch, the update_option calls were performed before the translations of the new locale were loaded. I've moved the calls to be performed right after the switch is made.
This patch seems to be working correctly, see the screenshots above. I think this could use some unit tests moving forward.
This ticket was mentioned in PR #8406 on WordPress/wordpress-develop by @ankitkumarshah.
12 months ago
#17
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: #36259
Patch used: https://core.trac.wordpress.org/attachment/ticket/36259/36259.diff
## Description:
Added a unit test that verifies date and time formats are updated when switching locale.
## Testing Instruction:
Run following command to verify the test:
npm run test:php -- --filter=Tests_I18n_SwitchingLocaleUpdatesDateTimeFormats
#18
@
10 months ago
- Keywords changes-requested added; has-patch needs-testing has-unit-tests removed
Test Report
Description
🟠 This report validates that the indicated patch works as expected with some caveats regarding Unit Testing.
Patch tested: REPLACE_WITH_PATCH_URL
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 135.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
- WP_Query Tester 1.0.0
Bug Reproduction
- Go to General Settings
- Set to any language different from English with different time locales
- 🐞 Bug Occurs
Expected Results
- The time locales should adapt to the Language
Actual Results
- ✅ Issue resolved with patch. I've tested with Russian and Spanish and everything changes accordingly
- ❌ Unit tests are useless (check Additional Notes)
Additional Notes
- Despite Unit tests are passing accordingly, passing test without patch don't break them
- There is another file more adequate to "Internationalization Locale Switches" in this path:
tests/phpunit/tests/l10n/wpLocaleSwitcher.php
#20
@
4 months ago
I tried updating the unit test and discovered a couple of things:
1) The patch might have some unintended consequences. Since it checks for the user locale, the dashboard is changing the default date/time format based on the user's locale rather than the site's default locale. This might not be what's intended and/or might not be what the user expects.
2) The code for changing options is not unit-testable because it is written procedurally in the options filter. Currently it can only be tested with end-to-end testing, unless the admin options functionality is rewritten.
(With help from @pbearne and @desrosj at WCEH 2025 Contributor Day!)
#21
@
4 months ago
In chatting this through with @fishtron and @pbearne, @swissspidy's suggestion above to not save a value to the database for the two options unless a non-default one is entered/selected seemed like the best approach at first.
However, it seems that this will cause problems within plugins and themes as using get_option() to retrieve these two values directly is quite common (acknowledging that this site is not up to date with the current state of the directory for several months).
Here are some additional observations:
- When the
F j, Yformat is not the default for the active locale, the form renders with\c\u\s\t\o\mas the selected radio button andF j, Y(which is a pretty common and standard date format) is not available as an option. - It may be nice to include something to the effect of "(language default)" next to the top option to make it clear that format is the default.
#22
@
4 months ago
@desrosj
Made start on adding language default text https://core.trac.wordpress.org/ticket/64102
This would need to account for those who have set their own date and time formats though, so as not to override user settings that may differ from what we expect from a locale.