-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2137 from graphcommerce-org/feature/GCOM-1304-nor…
…malize-locale-html-lang Normalize `<html lang=...` locale (GCOM-1304)
- Loading branch information
Showing
10 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@graphcommerce/magento-product-configurable': patch | ||
'@graphcommerce/lingui-next': patch | ||
'@graphcommerce/next-ui': patch | ||
--- | ||
|
||
Don't render pseudo-locale in HTML lang attribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './components/LinguiProvider' | ||
export * from './types' | ||
export * from './lib/normalizeLocale' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* To support using multiple storefronts using the same language locale (which | ||
* next.js does not support), we use an additional 'tag' in the locale code in | ||
* which we specify a unique string (i.e. a Magento store code). | ||
* | ||
* This makes next.js happy, as it still follows the BCP47 spec. However, the | ||
* Intl API and other places may not accept this as a valid locale. | ||
* | ||
* Use this method to get a 'normalized' locale that can safely be used in such | ||
* places. | ||
*/ | ||
export function normalizeLocale(locale: string | undefined) { | ||
if (!locale) return locale | ||
|
||
// Specifically match the xx-yy-storecode format, so we don't accidently 'fix' | ||
// valid locales such as he-Hebr-IL or zh-Hans-CN. This this isn't perfect and | ||
// we should consider a more formalized way to use such pseudo-locales, which | ||
// can be matched more precisely. | ||
const matches = locale?.match(/([a-z]{2})-([a-z]{2})-([a-z]+)/i) | ||
if (matches) { | ||
return `${matches[1]}-${matches[2]}` | ||
} | ||
return locale | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2315ab7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
graphcommerce-hygraph-dynamic-rows-ui – ./packages/hygraph-dynamic-rows-ui
graphcommerce-hygraph-dynamic-rows-ui-git-canary-graphcommerce.vercel.app
graphcommerce-hygraph-dynamic-rows-ui-graphcommerce.vercel.app
graphcommerce-hygraph-dynamic-rows-ui.vercel.app