fix: add automatic date/time format option for locale-native defaults#1323
Open
Kameti77 wants to merge 6 commits into
Open
fix: add automatic date/time format option for locale-native defaults#1323Kameti77 wants to merge 6 commits into
Kameti77 wants to merge 6 commits into
Conversation
Signed-off-by: Kameti <kametidanielk@gmail.com>
…ocale format Signed-off-by: Kameti <kametidanielk@gmail.com>
…anges Signed-off-by: Kameti <kametidanielk@gmail.com>
…defaults Adds an Automatic option to both the date and time format pickers that reverts to the locale's native format (e.g. DD.MM.YYYY for German, H:mm for Spanish) instead of locking the user to a hard-coded preset. A new nativeLocaleFormats signal in dayjs.tsx captures the locale's original L and LT formats before any user overrides are applied, so the Automatic preview always shows the true locale default. Selecting Automatic calls clearDateFormat/clearTimeFormat on the Locale store. Explicit overrides are preserved across language switches and can be reverted to Automatic at any time. Fixes stoatchat#629 Signed-off-by: Kameti <kametidanielk@gmail.com>
…to reload locale Signed-off-by: Kameti <kametidanielk@gmail.com>
Author
|
Hi @stoatchat/for-web-maintainers, this is my first contribution. I've fixed #629 by adding an Automatic option to the date/time format pickers so locales like German and Spanish correctly show their native formats. Would appreciate a review when you have time! Looking forward to your feedback. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds an Automatic option to both the date and time format pickers in Language settings. Previously, the only choices were fixed presets (DD/MM/YYYY, MM/DD/YYYY, YYYY-MM-DD for date and HH:mm, h:mm A for time). Many locales use formats that don't match any of these. For example, German uses DD.MM.YYYY, Spanish uses H:mm, and Indonesian uses HH.mm, so users on those locales had no option that correctly reflected their locale's native format, and there was no way to revert to the locale default once an override had been picked.
The Automatic option uses the locale's native dayjs format tokens (L for date, LT for time), so it always displays the correct format for whatever language is selected. Switching languages updates the Automatic preview immediately. Explicit overrides are preserved across language switches and can be reverted to Automatic at any time.
Changes made:
Language.tsx— Added Automatic as the first option in both pickers. The preview is computed viacreateMemotracking a newnativeLocaleFormatssignal so it updates reactively when the locale changes. Selecting Automatic callsclearDateFormat()/clearTimeFormat()on the store.dayjs.tsx— Added anativeLocaleFormatssignal that captures the locale's original L and LT formats before any user overrides are applied, so the Automatic preview is never affected by a previously picked override.Locale.ts— Added a publicgetOptions()accessor (the existingget()is protected). FixedclearDateFormat()andclearTimeFormat()to callloadTimeLocale()directly so the locale reloads even when the language itself hasn't changed.Time.tsx— Changed thedateformat case to use dayjs'sLtoken (locale-aware) instead of the hardcodedDD/MM/YYYY. Added a separatedateNormalcase that keeps the hardcodedDD/MM/YYYYfor the Traditional option preview. AddedcreateEffectso the component updates immediately when the locale signal changes rather than waiting for the nextsetIntervaltick.Fixes #629
How was this PR tested?
DD.MM.YYYY(dots)H:mm(no AM/PM, no leading zero)DD/MM/YYYY, time showsh:mm AMM/DD/YYYYDD/MM/YYYY), then switched languages — override was preserved, did not resetScreenshots & Screencasts (if appropriate)
Checklist:
Please declare, if any, LLM usage involved in creating this PR
I used Claude Code (Anthropic) as a pair programming assistant throughout this PR. It helped me navigate the codebase, understand the Solid.js reactivity model, and reason through the timing issues with async locale loading. All code was reviewed and understood before committing.