@graphcommerce/lingui-next 2.1.6 → 2.1.9
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 +53 -0
- package/package.json +13 -12
- package/utils/withLingui.tsx +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1490](https://github.com/graphcommerce-org/graphcommerce/pull/1490) [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb) Thanks [@paales](https://github.com/paales)! - upgraded packages
|
|
8
|
+
|
|
9
|
+
## 2.1.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1451](https://github.com/graphcommerce-org/graphcommerce/pull/1451) [`f698ff85d`](https://github.com/graphcommerce-org/graphcommerce/commit/f698ff85df6bb0922288471bb3c81856091b8061) Thanks [@paales](https://github.com/paales)! - Removed all occurences of @lingui/macro and moved to @lingui/macro / @lingui/core in preparation to move to swc.
|
|
14
|
+
|
|
15
|
+
Since we've removed @lingui/macro, all occurences need to be replaced with @lingui/core and @lingui/react.
|
|
16
|
+
|
|
17
|
+
All occurences of `<Trans>` and `t` need to be replaced:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Trans, t } from '@lingui/macro'
|
|
21
|
+
|
|
22
|
+
function MyComponent() {
|
|
23
|
+
const foo = 'bar'
|
|
24
|
+
return (
|
|
25
|
+
<div aria-label={t`Account ${foo}`}>
|
|
26
|
+
<Trans>My Translation {foo}</Trans>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Needs to be replaced with:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Trans } from '@lingui/react'
|
|
36
|
+
import { i18n } from '@lingui/core'
|
|
37
|
+
|
|
38
|
+
function MyComponent() {
|
|
39
|
+
const foo = 'bar'
|
|
40
|
+
return (
|
|
41
|
+
<div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
|
|
42
|
+
<Trans key='My Translation {foo}' values={{ foo }}></Trans>
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
[More examples for Trans](https://lingui.js.org/ref/macro.html#examples-of-jsx-macros) and [more examples for `t`](https://lingui.js.org/ref/macro.html#examples-of-js-macros)
|
|
49
|
+
|
|
50
|
+
## 2.1.7
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#1426](https://github.com/graphcommerce-org/graphcommerce/pull/1426) [`100f4c38c`](https://github.com/graphcommerce-org/graphcommerce/commit/100f4c38c8fcda4bc6e0425e38028b550b60adc2) Thanks [@paales](https://github.com/paales)! - Upgrade packages
|
|
55
|
+
|
|
3
56
|
## 2.1.6
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
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": "2.1.
|
|
5
|
+
"version": "2.1.9",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,22 +15,23 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lingui/core": "^3.13.
|
|
19
|
-
"@lingui/react": "^3.13.
|
|
18
|
+
"@lingui/core": "^3.13.3",
|
|
19
|
+
"@lingui/react": "^3.13.3",
|
|
20
20
|
"babel-plugin-macros": "^3.1.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
23
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.8",
|
|
24
24
|
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^4.0.
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.3",
|
|
26
|
+
"@lingui/conf": "^3.13.2",
|
|
27
|
+
"@playwright/test": "^1.21.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@lingui/
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
30
|
+
"@lingui/react": "^3.13.2",
|
|
31
|
+
"@lingui/core": "^3.13.2",
|
|
32
|
+
"make-plural": "^6.2.2",
|
|
33
|
+
"next": "^12.1.2",
|
|
34
|
+
"react": "^18.0.0",
|
|
35
|
+
"react-dom": "^18.0.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/utils/withLingui.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { i18n } from '@lingui/core'
|
|
2
2
|
// eslint-disable-next-line @next/next/no-document-import-in-page
|
|
3
|
-
import { DocumentContext } from 'next/document'
|
|
3
|
+
import { DocumentContext, DocumentInitialProps } from 'next/document'
|
|
4
4
|
// eslint-disable-next-line @next/next/no-document-import-in-page
|
|
5
5
|
import type NextDocument from 'next/document'
|
|
6
6
|
import React from 'react'
|
|
7
7
|
import { MessageLoader } from '../types'
|
|
8
8
|
|
|
9
|
+
export type LinguiDocumentProps = { linguiScriptTag: React.ReactNode }
|
|
10
|
+
|
|
9
11
|
export function withLingui(
|
|
10
12
|
Document: typeof NextDocument,
|
|
11
13
|
load: MessageLoader,
|
|
@@ -23,10 +25,9 @@ export function withLingui(
|
|
|
23
25
|
i18n.load(locale, messages)
|
|
24
26
|
i18n.activate(locale)
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
const props: DocumentInitialProps & LinguiDocumentProps = {
|
|
27
29
|
...initial,
|
|
28
|
-
|
|
29
|
-
...(React.Children.toArray(initial.head) as Array<JSX.Element | null>),
|
|
30
|
+
linguiScriptTag: (
|
|
30
31
|
<script
|
|
31
32
|
key='lingui'
|
|
32
33
|
type='application/json'
|
|
@@ -34,9 +35,10 @@ export function withLingui(
|
|
|
34
35
|
lang={locale}
|
|
35
36
|
// eslint-disable-next-line react/no-danger
|
|
36
37
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(messages) }}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
/>
|
|
39
|
+
),
|
|
39
40
|
}
|
|
41
|
+
return props
|
|
40
42
|
} catch (e) {
|
|
41
43
|
if (process.env.NODE_ENV !== 'production') console.error(e)
|
|
42
44
|
return initial
|