gt-react 10.9.1 → 10.9.3
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 +15 -0
- package/README.md +45 -64
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# gt-react
|
|
2
2
|
|
|
3
|
+
## 10.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#888](https://github.com/generaltranslation/gt/pull/888) [`6314624`](https://github.com/generaltranslation/gt/commit/6314624cd6d537e236e7208b1097dc137befab66) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: readme
|
|
8
|
+
|
|
9
|
+
## 10.9.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`e113d8d`](https://github.com/generaltranslation/gt/commit/e113d8d8fb5e37f45a4aa77544e8f4666519bfe8)]:
|
|
14
|
+
- generaltranslation@8.1.3
|
|
15
|
+
- @generaltranslation/react-core@1.3.2
|
|
16
|
+
- @generaltranslation/supported-locales@2.0.33
|
|
17
|
+
|
|
3
18
|
## 10.9.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -16,101 +16,82 @@ Install `gt-react` via npm:
|
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install gt-react
|
|
19
|
-
npm install
|
|
19
|
+
npm install gtx-cli --save-dev
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Getting Started
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Follow the [Quick Start Guide](https://generaltranslation.com/docs/react) or run the setup wizard: `npx gtx-cli init` and add the [`<GTProvider>`](https://generaltranslation.com/en-US/docs/react#gtprovider) to your app.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Translate everything inside of the `<T>` component.
|
|
27
27
|
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
```jsx
|
|
29
|
+
<T>
|
|
30
|
+
<p>This gets translated!</p>
|
|
31
|
+
<div>This also gets translated!</divs>
|
|
32
|
+
</T>
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
## Documentation
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Full documentation, including guides, examples, and API references, can be found at [General Translation Docs](generaltranslation.com/docs).
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
It should be placed as high up in your app as possible, ideally at the root.
|
|
39
|
+
## Features
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
### Jsx Translation
|
|
41
42
|
|
|
42
43
|
```jsx
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<GTProvider locales={['fr', 'zh']}>
|
|
49
|
-
{' '}
|
|
50
|
-
// French and Chinese support
|
|
51
|
-
<MyApp />
|
|
52
|
-
</GTProvider>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
44
|
+
<T>
|
|
45
|
+
Translate anything inside of a {'<T>'} component!
|
|
46
|
+
<div>Including nested structures</div>
|
|
47
|
+
</T>
|
|
55
48
|
```
|
|
56
49
|
|
|
57
|
-
###
|
|
58
|
-
|
|
59
|
-
Wrap any nested JSX content in the `<T>` component to make it translatable.
|
|
60
|
-
For more information, check out the [guide on using `<T>` components](https://generaltranslation.com/docs/react/reference/t-reference).
|
|
50
|
+
### Inline string translation
|
|
61
51
|
|
|
62
52
|
```jsx
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<T>
|
|
68
|
-
<p>This gets translated.</p>
|
|
69
|
-
</T>
|
|
70
|
-
);
|
|
53
|
+
function MyComponent() {
|
|
54
|
+
const gt = useGT();
|
|
55
|
+
return <>{gt('Strings as well!')}</>;
|
|
71
56
|
}
|
|
72
57
|
```
|
|
73
58
|
|
|
74
|
-
|
|
59
|
+
### Dictionary translation
|
|
75
60
|
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export default function Example() {
|
|
80
|
-
return (
|
|
81
|
-
<T>
|
|
82
|
-
<p>
|
|
83
|
-
This gets translated. <Var>This does not.</Var>
|
|
84
|
-
</p>
|
|
85
|
-
</T>
|
|
86
|
-
);
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"key": "Hello, World!"
|
|
87
64
|
}
|
|
88
65
|
```
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
npx gt-react-cli setup
|
|
67
|
+
```jsx
|
|
68
|
+
function MyComponent() {
|
|
69
|
+
const t = useTranslations();
|
|
70
|
+
return <>{t('key')}</>;
|
|
71
|
+
}
|
|
96
72
|
```
|
|
97
73
|
|
|
98
|
-
|
|
99
|
-
For strings, you can use `useGT()` for translation.
|
|
100
|
-
For more information, check out [this guide](/docs/react/tutorials/translating-strings).
|
|
74
|
+
### Pluralization
|
|
101
75
|
|
|
102
|
-
|
|
103
|
-
import { useGT } from 'gt-react';
|
|
76
|
+
Support for pluralization and conditional branching
|
|
104
77
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
78
|
+
```jsx
|
|
79
|
+
<T>
|
|
80
|
+
<Plural
|
|
81
|
+
n={count}
|
|
82
|
+
singular="There is 1 person"
|
|
83
|
+
plural={<>There are <Num>{count}</Num> people}
|
|
84
|
+
/>
|
|
85
|
+
</T>
|
|
109
86
|
```
|
|
110
87
|
|
|
111
|
-
|
|
88
|
+
### Formatting
|
|
112
89
|
|
|
113
|
-
|
|
90
|
+
Support for number, currency, date time, and dynamic variables
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
<Num options={{ style: 'currency', currency: 'EUR' }}>{1000}</Num>
|
|
94
|
+
```
|
|
114
95
|
|
|
115
96
|
## Contributing
|
|
116
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-react",
|
|
3
|
-
"version": "10.9.
|
|
3
|
+
"version": "10.9.3",
|
|
4
4
|
"description": "A React library for automatic internationalization.",
|
|
5
5
|
"main": "./dist/index.cjs.min.cjs",
|
|
6
6
|
"module": "./dist/index.esm.min.mjs",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"react-dom": ">=16.8.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@generaltranslation/supported-locales": "2.0.
|
|
18
|
-
"generaltranslation": "8.1.
|
|
19
|
-
"@generaltranslation/react-core": "1.3.
|
|
17
|
+
"@generaltranslation/supported-locales": "2.0.33",
|
|
18
|
+
"generaltranslation": "8.1.3",
|
|
19
|
+
"@generaltranslation/react-core": "1.3.2"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|