• Lukas 'Eipi' Eipert's avatar
    Use configured browser locales for date formatting · ce46da1b
    Lukas 'Eipi' Eipert authored
    This allows us to decide a little better what a user wants as a locale
    for using with the Intl browser APIs. If they have set their GitLab to
    a language, it will check whether `navigator.languages` contains
    matching ones. This function always adds `en` as a fallback in order to
    have date renders if all fails before it.
    
    - Example one: GitLab language is `en` and browser languages are:
      `['en-GB', 'en-US']`. We would choose `['en-GB', 'en-US', 'en']` as
      the preferred locales, the Intl APIs would try to format first as
      British English, if that isn't available US or any English.
    - Example two: GitLab language is `en` and browser languages are:
      `['de-DE', 'de']`. We would choose `['en']`, so the Intl APIs
      would prefer English formatting in order to not have German dates
      mixed with English GitLab UI texts.
      If the user wants for example British English formatting (24h, etc),
      they could set their browser languages to `['de-DE', 'de', 'en-GB']`.
    - Example three: GitLab language is `de` and browser languages are \
      `['en-US', 'en']`. We would choose `['de', 'en']`, aligning German
      dates with the chosen translation of GitLab.
    
    This function is currently only used for absolute dates:
    - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65570
    
    Changelog: changed
    ce46da1b
preferences.md 7.4 KB