Skip to content

Re-implement language switcher during registration

Roy Liu requested to merge 423455-fix-language-switcher-breaking-qa into master

What does this MR do and why?

Re-implement !129651 (merged). Original MR was reverted due to causing qa test failures. Codes causing issue below:

  def browser_languages
    http_language_header = request.env['HTTP_ACCEPT_LANGUAGE']
    return [] unless http_language_header

    http_language_header.tr!('-', '_').split(%r{[;,]}).reject { |str| str.start_with?('q') }
  end

Root cause is HTTP_ACCEPT_LANGUAGE header in git clone operation over http can be blank string, hence causing http_language_header.tr! return nil and subsequently throws error: undefined method split for nil.

What does the original MR do?

Detect marketing site language option and browser language setting, and set the preferred_language cookie base on that if the language is valid (high translation level).

How to set up and validate locally

  1. Simulate SaaS
  2. Visit local GDK /users/sign_up
  3. Delete the preferred_language cookie in browser
  4. Change browser setting to one of these languages: Deutsch, Francais, Japanese, Simplified-Chinese, Traditional-Chinese
  5. Visit sign-up page again, displayed language should correspond to the browser setting.
  6. Delete the preferred_language cookie again
  7. Visit /-/trial_registrations/new?glm_source=about.gitlab.com/fr-fr/ (if browser setting is already French, change 'fr-fr' to 'de-de' or 'ja-jp')
  8. Displayed language on trial registration page should correspond to the url param.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #423455 (closed)

Edited by Roy Liu

Merge request reports