gt-react 10.9.2 → 10.10.0-alpha.0

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,11 @@
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
+
3
9
  ## 10.9.2
4
10
 
5
11
  ### 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 gt-react-cli --save-dev
19
+ npm install gtx-cli --save-dev
20
20
  ```
21
21
 
22
22
  ## Getting Started
23
23
 
24
- ### Step 1: Configure Your Environment Variables
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
- Add the following environment variables to your `.env` file:
26
+ Translate everything inside of the `<T>` component.
27
27
 
28
- ```
29
- GT_API_KEY="your-api-key"
30
- GT_PROJECT_ID="your-project-id"
28
+ ```jsx
29
+ <T>
30
+ <p>This gets translated!</p>
31
+ <div>This also gets translated!</divs>
32
+ </T>
31
33
  ```
32
34
 
33
- - Get your `API Key` and `Project ID` from the [General Translation Dashboard](https://generaltranslation.com).
35
+ ## Documentation
34
36
 
35
- ### 2. Select languages
37
+ Full documentation, including guides, examples, and API references, can be found at [General Translation Docs](generaltranslation.com/docs).
36
38
 
37
- `<GTProvider>` is used to configure the behavior of `gt-react`.
38
- It should be placed as high up in your app as possible, ideally at the root.
39
+ ## Features
39
40
 
40
- Just pass a list of [locale codes](https://generaltranslation.com/docs/platform/locale-strings#supported-locales) to add them to your app.
41
+ ### Jsx Translation
41
42
 
42
43
  ```jsx
43
- import { GTProvider } from 'gt-react';
44
- import MyApp from './MyApp';
45
-
46
- export default function App() {
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
- ### 3. Add the `<T>` component
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
- import { T } from 'gt-react';
64
-
65
- export default function Example() {
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
- Use the `<Var>` component to designate JSX content that should not be translated.
59
+ ### Dictionary translation
75
60
 
76
- ```jsx
77
- import { T, Var } from 'gt-react';
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
- **Tip:**
91
- To save time, run the setup command.
92
- It will scan your codebase for translatable JSX and insert the `<T>` tags for you.
93
-
94
- ```bash title="shell" copy
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
- **Strings:**
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
- ```jsx
103
- import { useGT } from 'gt-react';
76
+ Support for pluralization and conditional branching
104
77
 
105
- export default function Example() {
106
- const t = useGT();
107
- return <p>{t('This gets translated.')}</p>;
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
- ## Documentation
88
+ ### Formatting
112
89
 
113
- Full documentation, including guides, examples, and API references, can be found at [General Translation Docs](generaltranslation.com/docs).
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