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

WIP: Add administrate default format #2781

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

goosys
Copy link
Contributor

@goosys goosys commented Feb 19, 2025

  • refs Refactor Time-related Fields ahead of upcoming improvements #2702
  • The only way to change the time format was to modify the Rails default setting. However, changing it would also affect other parts of the application outside the admin panel. Therefore, I added a dedicated format specifically for Administrate.
    • administrate_date_default administrate_datetime_default administrate_time_default
  • Currently, the Time format is fixed as "%I:%M%p", but in Japanese, we would prefer the order "%p %I:%M". I believe other languages may also have their own preferred orders. I have made it possible to change this for each language using administrate_time_default .

@goosys
Copy link
Contributor Author

goosys commented Feb 19, 2025

At this point, there is a backward compatibility issue.

Since administrate_*_default does not exist in everyone's Rails setup, some initial configuration is required to start using this feature. I feel bad about forcing this initial setup on everyone, so I’d like to discuss if there’s a better way.

  1. Write the configuration values for each language in all config/locales/administrate.*.yml files.
  2. Create config/locales/date.yml and include only the default (en) settings.
  3. Use I18n.localize with default: [:"time.formats.default"] to enable fallback. ref.

Option 1 is very tedious. Option 3 would likely work, but it introduces unnecessary processing if the initial configuration is already set up, so I’d prefer to avoid it if possible.
What do you think?

@goosys goosys force-pushed the add-administrate_default-format branch from 2995e3d to 6d0935d Compare February 19, 2025 12:56
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.

1 participant