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

feat: validate SDConfig.SUPPORTED_LANGUAGES for usable locales #6406

Merged
merged 5 commits into from
May 3, 2022

Commits on May 2, 2022

  1. feat: validate SDConfig.SUPPORTED_LANGUAGES for *usable* locales

    A locale is considered usable if it is both (a) available in the
    filesystem and (b) configured by the administrator in
    SDConfig.SUPPORTED_LANGUAGES.  Once we've determined which configured
    locales are actually usable, we:
    
    1. warn if a configured locale is not available;
    
    2. fall back to the hard-coded FALLBACK_LOCALE ("en_US") if
       SDConfig.DEFAULT_LOCALE is not usable; and
    
    3. error out if neither the default nor the fallback locale is usable.
    cfm committed May 2, 2022
    Configuration menu
    Copy the full SHA
    9c11950 View commit details
    Browse the repository at this point in the history
  2. feat: map_locale_display_names(): skip (hide) unusable locales

    We can't iterate directly over USABLE_LOCALES: Set(Locale) because
    Locales aren't sortable.  Instead, we parse config.SUPPORTED_LOCALES in
    order and skip those that aren't in USABLE_LOCALES.
    cfm committed May 2, 2022
    Configuration menu
    Copy the full SHA
    20c59fd View commit details
    Browse the repository at this point in the history

Commits on May 3, 2022

  1. refactor(map_locale_display_names): use set rather than looping twice…

    … to disambiguate SUPPORTED_LOCALES
    
    thread: #6406 (comment)
    cfm committed May 3, 2022
    Configuration menu
    Copy the full SHA
    9621639 View commit details
    Browse the repository at this point in the history
  2. fix(get_locale): don't assume the session-provided locale is usable

    This is a safe assumption except in the corner case where (e.g.):
    
    1. A user begins a session and selects language L.
    
    2. The Application Server upgrades to a version of securedrop-app-code
       that removes support for language L.
    
    3. The user resumes their session, which still has language L selected.
    
    But, since this case has come up in testing[1], best to check for it.
    
    [1]: #6406 (comment)
    cfm committed May 3, 2022
    Configuration menu
    Copy the full SHA
    eb2a042 View commit details
    Browse the repository at this point in the history
  3. refactor(get_locale): resolve locale from single list of preferences

    As of 9c11950, get_locale() handled user/agent-provided locale
    preferences and deferred to resolve_fallback_locale() if none
    could be satisfied.  Here we build a single list of locales,
    beginning with user/agent preferences and ending with the server-side
    {DEFAULT_FALLBACK}_LOCALEs, and call babel.core.negotiate_locale()
    once to negotiate one (if possible).
    cfm committed May 3, 2022
    Configuration menu
    Copy the full SHA
    20c7212 View commit details
    Browse the repository at this point in the history