Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Locale fix for ie #339

Merged
merged 7 commits into from
Nov 9, 2023
Merged

Locale fix for ie #339

merged 7 commits into from
Nov 9, 2023

Conversation

adoroshk
Copy link
Contributor

@adoroshk adoroshk commented Aug 3, 2023

Summary

This PR introduces changes to getBrowserLocale method to accommodate the way IE navigator works with browser language.

Why the change is needed

It has been reported that if the browser language is set to a different language, it translates correctly in all browsers but IE. The issue was pointed out to be coming from current implementation of the browser language being obtained from the navigator languages properties, which for IE differs from the rest of the browsers. Following tests indicated in favor of that:

I changed the language in IE browser from English to German and console logged the navigator language properties. I observed following:

navigator.languages: undefined
navigator.language: undefined
navigator.userLanguage: "en-US"
navigator.browserLanguage: "en-US"
navigator.systemLanguage: "de-DE"

It means that for IE the only navigator property that reflects the current browser language is navigator.systemLanguage.
The current implementation of getBrowserLocale method does not use navigator.systemLanguage property, hence error in IE. It does work good for the rest of the browsers though, as they take the language from navigator languages array. I tested it by changing the language from English to German in Chrome, Firefox, Safari and Edge and received following console output:

navigator.languages: Array(1)['de']
navigator.language: 'de'
navigator.userLanguage: undefined
navigator.browserLanguage: undefined
navigator.systemLanguage: undefined

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Following testing have been done for Chrome, Firefox, Safari and Edge:

  1. The language of these browsers have been changed to supported locale (German language), the console.log for getBrowserLocale method returning result was correctly set to 'de' or 'de-DE' (German):
Знімок екрана 2023-08-03 о 4 31 05 пп
  1. The language has been changed to not supported locale (Ukrainian language), the console.log for getBrowserLocale method returning result was correctly set to fall-back locale 'en' (English).
  2. The browser language was set to English, the console.log for getBrowserLocale method returning result was correctly set to 'en' (English).

Screenshots of navigator language props in IE, Edge, Chrome and Safari

A screenshot of navigator props in IE:
Screenshot 2023-08-03 at 2 49 56 PM

A screenshot of multiple languages with German being primary language logged for Edge:
Screenshot 2023-08-03 at 3 03 06 PM

A screenshot of German as an only language logged for Chrome:
Screenshot 2023-08-03 at 3 09 14 PM

A screenshot of Ukrainian as an only language in Safari:
Знімок екрана 2023-08-03 о 3 42 49 пп

Additional Details

This PR resolves:

UXPLATFORM-7942

@github-actions github-actions bot temporarily deployed to preview-pr-339 August 3, 2023 20:09 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-339 August 3, 2023 21:29 Destroyed
@adoroshk adoroshk self-assigned this Aug 4, 2023
@adoroshk adoroshk marked this pull request as ready for review August 7, 2023 16:56
@sdadn
Copy link
Contributor

sdadn commented Nov 8, 2023

Is this PR up to date with main?

@github-actions github-actions bot temporarily deployed to preview-pr-339 November 9, 2023 15:40 Destroyed
@adoroshk
Copy link
Contributor Author

adoroshk commented Nov 9, 2023

Is this PR up to date with main?

@sdadn I just updated it from main and added a snapshot update per change it terra-button

@adoroshk adoroshk merged commit f60c663 into main Nov 9, 2023
6 checks passed
@adoroshk adoroshk deleted the locale_fix_for_ie branch November 9, 2023 19:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants