@graphcommerce/lingui-next 5.2.0-canary.8 → 6.0.0-canary.20
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 +24 -0
- package/Config.graphqls +13 -0
- package/README.md +10 -6
- package/components/LinguiProvider.tsx +7 -5
- package/config.d.ts +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.0.0-canary.20
|
|
4
|
+
|
|
5
|
+
## 5.2.0-canary.19
|
|
6
|
+
|
|
7
|
+
## 5.2.0-canary.18
|
|
8
|
+
|
|
9
|
+
## 5.2.0-canary.17
|
|
10
|
+
|
|
11
|
+
## 5.2.0-canary.16
|
|
12
|
+
|
|
13
|
+
## 5.2.0-canary.15
|
|
14
|
+
|
|
15
|
+
## 5.2.0-canary.14
|
|
16
|
+
|
|
17
|
+
## 5.2.0-canary.13
|
|
18
|
+
|
|
19
|
+
## 5.2.0-canary.12
|
|
20
|
+
|
|
21
|
+
## 5.2.0-canary.11
|
|
22
|
+
|
|
23
|
+
## 5.2.0-canary.10
|
|
24
|
+
|
|
25
|
+
## 5.2.0-canary.9
|
|
26
|
+
|
|
3
27
|
## 5.2.0-canary.8
|
|
4
28
|
|
|
5
29
|
## 5.2.0-canary.7
|
package/Config.graphqls
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
extend input GraphCommerceI18nConfig {
|
|
2
|
+
"""
|
|
3
|
+
Specify a custom locale for to load translations.
|
|
4
|
+
"""
|
|
5
|
+
linguiLocale: String
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
# extend input GraphCommerceConfog {
|
|
9
|
+
# """
|
|
10
|
+
# By default the locale only will be used: locale: "en-us" => "en", but you can use the full locale: locale: "en-us" => "en-us"
|
|
11
|
+
# """
|
|
12
|
+
# linguiFullLocale: String
|
|
13
|
+
# }
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# @graphcommerce/
|
|
1
|
+
# @graphcommerce/lingui-next
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package adds lingui to GraphCommerce
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
1. Create a lingui.config.js with the lingui config.
|
|
8
8
|
[example](../../examples/magento-graphcms/lingui.config.js)
|
|
@@ -14,7 +14,11 @@ This package makes it easy to add Google Recaptcha v3 to GraphCommerce
|
|
|
14
14
|
4. Run `NODE_ENV=development yarn lingui extract` to extact messages for your
|
|
15
15
|
locale.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Configuration
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Configure the following ([configuration values](./Config.graphqls)) in your
|
|
20
|
+
graphcommerce.config.js
|
|
21
|
+
|
|
22
|
+
## Extracting messages
|
|
23
|
+
|
|
24
|
+
Run `NODE_ENV=development yarn lingui extract`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i18nConfig } from '@graphcommerce/next-ui'
|
|
1
2
|
import { i18n, Messages } from '@lingui/core'
|
|
2
3
|
import { I18nProvider, I18nProviderProps } from '@lingui/react'
|
|
3
4
|
import { nl, en, fr } from 'make-plural/plurals'
|
|
@@ -19,17 +20,18 @@ i18n.loadLocaleData({
|
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
export function LinguiProvider(props: LinguiProviderProps) {
|
|
22
|
-
const { loader, ssrLoader, locale, ...
|
|
23
|
+
const { loader, ssrLoader, locale, ...i18nProviderProps } = props
|
|
24
|
+
|
|
25
|
+
const localeOnly = (locale && i18nConfig(locale)?.linguiLocale) ?? locale?.split('-')[0]
|
|
23
26
|
|
|
24
27
|
useMemo(() => {
|
|
25
|
-
const localeOnly = locale?.split('-')[0]
|
|
26
28
|
const data = globalThis.document?.getElementById('lingui')
|
|
27
29
|
|
|
28
30
|
if (data?.lang === localeOnly && data.textContent) {
|
|
29
31
|
// @todo: We're not loading the plurals dynamically, but we can't because it will load the complete module.
|
|
30
32
|
i18n.load(localeOnly, JSON.parse(data.textContent) as Messages)
|
|
31
33
|
i18n.activate(localeOnly)
|
|
32
|
-
} else if (i18n.locale !==
|
|
34
|
+
} else if (i18n.locale !== localeOnly) {
|
|
33
35
|
if (typeof window === 'undefined') {
|
|
34
36
|
const { messages } = ssrLoader(localeOnly)
|
|
35
37
|
i18n.load(localeOnly, messages)
|
|
@@ -55,7 +57,7 @@ export function LinguiProvider(props: LinguiProviderProps) {
|
|
|
55
57
|
}
|
|
56
58
|
// We dont want to call this when the loader/ssrLoader changes, because it will cause a re-render.
|
|
57
59
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
-
}, [
|
|
60
|
+
}, [localeOnly])
|
|
59
61
|
|
|
60
|
-
return <I18nProvider i18n={i18n} {...
|
|
62
|
+
return <I18nProvider i18n={i18n} {...i18nProviderProps} />
|
|
61
63
|
}
|
package/config.d.ts
CHANGED
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": "
|
|
5
|
+
"version": "6.0.0-canary.20",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"@graphcommerce/next-config": "6.0.0-canary.20",
|
|
19
|
+
"make-plural": "6.2.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@graphcommerce/eslint-config-pwa": "
|
|
23
|
-
"@graphcommerce/prettier-config-pwa": "
|
|
24
|
-
"@graphcommerce/typescript-config-pwa": "
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "6.0.0-canary.20",
|
|
23
|
+
"@graphcommerce/prettier-config-pwa": "6.0.0-canary.20",
|
|
24
|
+
"@graphcommerce/typescript-config-pwa": "6.0.0-canary.20",
|
|
25
25
|
"@lingui/conf": "^3.14.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@lingui/core": "^3.13.2",
|
|
29
28
|
"@lingui/react": "^3.13.2",
|
|
29
|
+
"@lingui/core": "^3.13.2",
|
|
30
30
|
"next": "^13.1.1",
|
|
31
31
|
"react": "^18.2.0",
|
|
32
32
|
"react-dom": "^18.2.0"
|