frappe icon indicating copy to clipboard operation
frappe copied to clipboard

feat!: enhance Language to become more of a Locale

Open barredterra opened this issue 1 year ago • 1 comments

This PR enhances the Language DocType to become more of a locale, i.e. Language now bundles all date, time and number format settings that apply to a specific region.

Before, the user could only set an individual language. All other settings, like date, time and number format would be taken from System Settings. (The same applies to Lead, Customer and Supplier in ERPNext.) Now, the whole set of options is configurable per language/locale.

Overview

  • Add settings for date and time to Language
  • Add backend utils for retrieving locale settings from the user's Language or global defaults
  • Refactor existing code to make use of above methods
  • Update user defaults when user's Language or Language's settings change

Design considerations

  • Language by default does not have any date/time/number formats set, these are fully optional.
  • System defaults are used if language does not have any values.

This way, the behavior should be mostly backwards compatible. The only change is that the user's language/locale can now override the system defaults, if desired.

Nevertheless, to be safe, this is meant for develop only.

Language, in theory, should now be named Locale, but this would be too breaking, IMO.

Screenshots

System Settings: system_settings

Language "de" ("Deutsch"): lang_de

Language "en" ("English"): lang_en

Print with Language set to "en" (uses System Settings because "en" has no specific config set): print_en_system

Print with Language set to "de" (uses more specific settings from Language "de"): print_de

Form view with user's language set to "de" (uses more specific settings from Language "de"): user_lang_de

Form view when user has no specific language (uses System Settings): no_user_lang

To do

  • [x] fix money_in_words (The follow-up PR #27190 improves money_in_words. Here, we just make sure it continues to work like before.)

Resolves #9001

barredterra avatar Jul 21 '24 13:07 barredterra

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

stale[bot] avatar Aug 28 '24 02:08 stale[bot]