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

STRF-7438 fix stencil language translation in Safari #186

Merged

Conversation

bc-williamkwon
Copy link
Contributor

@bc-williamkwon bc-williamkwon commented Oct 16, 2019

This should fix the issue of Safari only sending the most preferred language's code. If the most preferred language's code does not exist then we go to the fallback for that language such as fr-CA to fr. If neither of these locales exist then we fallback to English. Tested in safari browser.

https://jira.bigcommerce.com/browse/STRF-7438

@bc-williamkwon bc-williamkwon force-pushed the fixSafariTranslation branch 2 times, most recently from 8c8d9f4 to 18ed2ea Compare October 16, 2019 22:23
lib/translator/index.js Outdated Show resolved Hide resolved
@bc-williamkwon bc-williamkwon force-pushed the fixSafariTranslation branch 8 times, most recently from 7365a43 to 5c4b5e8 Compare October 18, 2019 17:11
lib/translator/index.js Outdated Show resolved Hide resolved

// Safari sends only one language code, this is to have a default fallback in case we don't have that language
// As an example we may not have fr-FR so add fr to the header
if (localesArr.length === 1 && localesArr[0].split('-').length === 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? I thought localesArr[0] would be an object, not a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localesArr[0] would be an object after acceptlanguageparser.parse but I'm doing this after the map function which makes things into an array of strings.

lib/translator/locale-parser.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants