@graphcommerce/lingui-next 8.0.0-canary.78 → 8.0.0-canary.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.0-canary.80
4
+
5
+ ## 8.0.0-canary.79
6
+
7
+ ### Patch Changes
8
+
9
+ - [#2137](https://github.com/graphcommerce-org/graphcommerce/pull/2137) [`df507b1`](https://github.com/graphcommerce-org/graphcommerce/commit/df507b194c67eef7b02df858c07938bb308b5397) - Don't render pseudo-locale in HTML lang attribute
10
+ ([@hnsr](https://github.com/hnsr))
11
+
3
12
  ## 8.0.0-canary.78
4
13
 
5
14
  ## 8.0.0-canary.77
package/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './components/LinguiProvider'
2
2
  export * from './types'
3
+ export * from './lib/normalizeLocale'
@@ -0,0 +1,24 @@
1
+ /**
2
+ * To support using multiple storefronts using the same language locale (which
3
+ * next.js does not support), we use an additional 'tag' in the locale code in
4
+ * which we specify a unique string (i.e. a Magento store code).
5
+ *
6
+ * This makes next.js happy, as it still follows the BCP47 spec. However, the
7
+ * Intl API and other places may not accept this as a valid locale.
8
+ *
9
+ * Use this method to get a 'normalized' locale that can safely be used in such
10
+ * places.
11
+ */
12
+ export function normalizeLocale(locale: string | undefined) {
13
+ if (!locale) return locale
14
+
15
+ // Specifically match the xx-yy-storecode format, so we don't accidently 'fix'
16
+ // valid locales such as he-Hebr-IL or zh-Hans-CN. This this isn't perfect and
17
+ // we should consider a more formalized way to use such pseudo-locales, which
18
+ // can be matched more precisely.
19
+ const matches = locale?.match(/([a-z]{2})-([a-z]{2})-([a-z]+)/i)
20
+ if (matches) {
21
+ return `${matches[1]}-${matches[2]}`
22
+ }
23
+ return locale
24
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/lingui-next",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.0-canary.78",
5
+ "version": "8.0.0-canary.80",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -18,11 +18,11 @@
18
18
  "@lingui/conf": "4.6.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.78",
22
- "@graphcommerce/next-config": "^8.0.0-canary.78",
23
- "@graphcommerce/next-ui": "^8.0.0-canary.78",
24
- "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.78",
25
- "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.78",
21
+ "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.80",
22
+ "@graphcommerce/next-config": "^8.0.0-canary.80",
23
+ "@graphcommerce/next-ui": "^8.0.0-canary.80",
24
+ "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.80",
25
+ "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.80",
26
26
  "@lingui/core": "^4.2.1",
27
27
  "@lingui/macro": "^4.2.1",
28
28
  "@lingui/react": "^4.2.1",