Default to English the language switcher
What does this MR do and why?
Default to English the language switcher
Instead of crashing the language switcher componte when the cookie
doesn't contain a preferred_language
, now it defaults to English.
Defensive programming.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
How to set up and validate locally
- Apply this patch
diff --git a/app/assets/javascripts/pages/devise/unlocks/show/index.js b/app/assets/javascripts/pages/devise/unlocks/show/index.js
new file mode 100644
index 000000000000..036c9374d3b3
--- /dev/null
+++ b/app/assets/javascripts/pages/devise/unlocks/show/index.js
@@ -0,0 +1,3 @@
+import { initLanguageSwitcher } from '~/language_switcher';
+
+initLanguageSwitcher();
Before
- On an incognito, go to a
/users/unlock?token=asdf
- Delete the
preferred_language
value from the cookie, if any. - Reload window
- No language switcher should be visible (bottom-right of the footer)
- Console error
index.js:13 TypeError: Cannot read properties of undefined (reading 'value')
index.js:13 TypeError: Cannot read properties of undefined (reading 'text')
After
- On an incognito, go to a
/users/unlock?token=asdf
- Delete the
preferred_language
value from the cookie, if any. - Reload window
- The language switcher should be visible: