Re-implement language switcher during registration
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
- Simulate SaaS
- Visit local GDK
/users/sign_up
- Delete the
preferred_language
cookie in browser - Change browser setting to one of these languages: Deutsch, Francais, Japanese, Simplified-Chinese, Traditional-Chinese
- Visit sign-up page again, displayed language should correspond to the browser setting.
- Delete the
preferred_language
cookie again - 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') - 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #423455 (closed)
Edited by Roy Liu