Skip to content

calendar: added support for custom calendar strings, and starting days#2548

Open
xrtxn wants to merge 1 commit into
longbridge:mainfrom
xrtxn:main
Open

calendar: added support for custom calendar strings, and starting days#2548
xrtxn wants to merge 1 commit into
longbridge:mainfrom
xrtxn:main

Conversation

@xrtxn

@xrtxn xrtxn commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Closes #2517

Description

Added support for custom weekday, month, and starting days. I found this to be the best tradeoff in terms of performance and ergonomy.

Screenshot

Before After
image image

How to Test

First day

            DatePickerState::new(window, cx)
                .date_format("%Y. %m. %d.")
                .first_day_of_week(Weekday::Mon)

Week day and month day

        .weekday_names([
            t!("calendar.monday"),
            t!("calendar.tuesday"),
            t!("calendar.wednesday"),
            t!("calendar.thursday"),
            t!("calendar.friday"),
            t!("calendar.saturday"),
            t!("calendar.sunday"),
        ])
        .month_names([
            t!("calendar.january"),
            t!("calendar.february"),
            t!("calendar.march"),
            t!("calendar.april"),
            t!("calendar.may"),
            t!("calendar.june"),
            t!("calendar.july"),
            t!("calendar.august"),
            t!("calendar.september"),
            t!("calendar.october"),
            t!("calendar.november"),
            t!("calendar.december"),
        ])

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

@huacnlee

Copy link
Copy Markdown
Member

Hi, weekday_names, month_names is not a good solution. I have make change of rust-i18n to support this feature and make PR in #2563

huacnlee added a commit that referenced this pull request Jul 13, 2026
## Summary

- upgrade to rust-i18n 4.2.0 and register Story locales with
`extend!(gpui_component)`
- add French Calendar and DatePicker translations as a Story-only
extension
- keep the component’s built-in Italian and Traditional Chinese locales
unchanged
- add French to the Story language menu and cover extension fallback
behavior with a test
- document custom I18n setup, namespace rules, override priority, and
locale selection in English and Simplified Chinese

This uses rust-i18n’s locale extension mechanism to address the
customization requirement discussed in #2548 without adding every
downstream locale to gpui-component itself.

Refs #2548

## Test Plan

- `cargo test -p gpui-component-story`
- `git diff --check`
- `bun run build` *(blocked by the current Bun/Vite Vue runtime:
`crypto.hash is not a function` while compiling the existing
`contributors.md`)*

---------

Co-authored-by: Codex <codex@openai.com>
@xrtxn

xrtxn commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, this should work for me, this was my original idea too, but unsure how to implement it. However, please check out .first_day_of_week() as well, as this is still missing. If you rather I can implement the changes needed for this updated version,

@huacnlee

Copy link
Copy Markdown
Member

first_day_of_week is ok to merge, you can cleanup you PR, then I will merge it.

@xrtxn

xrtxn commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Please check it out, I cleaned up the code

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

Successfully merging this pull request may close these issues.

Override gpui-component localization from the application side

2 participants