gt-next 4.3.6 → 4.3.7
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/README.md +37 -22
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://generaltranslation.com" target="_blank">
|
|
3
|
+
<img src="https://generaltranslation.com/gt-logo-light.svg" alt="General Translation" width="100" height="100">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
1
7
|
# gt-next: Automatic i18n for Next.js
|
|
2
8
|
|
|
3
9
|
gt-next is a powerful internationalization library designed for Next.js applications. It replaces your existing localization library, and integrates with [generaltranslation.com](https://generaltranslation.com) for translations.
|
|
4
10
|
|
|
11
|
+
See our [docs](https://www.generaltranslation.com/docs) for more information including guides, examples, and API references.
|
|
12
|
+
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
Install `gt-next` via npm:
|
|
@@ -27,30 +35,27 @@ GT_API_KEY="your-api-key"
|
|
|
27
35
|
GT_PROJECT_ID="your-project-id"
|
|
28
36
|
```
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
- Get your `API Key` and `Project ID` from the [General Translation Dashboard](https://www.generaltranslation.com).
|
|
31
39
|
|
|
32
40
|
### Step 2: Add the `<GTProvider>`
|
|
33
41
|
|
|
34
|
-
Add the `<GTProvider>` component to add translations for client-side
|
|
42
|
+
Add the `<GTProvider>` component below your root `layout.tsx` `<html>` tag to add translations for client-side
|
|
35
43
|
content, and set the <html> `lang` attribute using `getLocale()`.
|
|
36
44
|
|
|
37
45
|
```jsx
|
|
38
|
-
import { GTProvider } from 'gt-next'
|
|
39
|
-
import { getLocale } from 'gt-next/server'
|
|
40
|
-
|
|
41
|
-
export default async function RootLayout({ children }) {
|
|
46
|
+
import { GTProvider } from 'gt-next';
|
|
47
|
+
import { getLocale } from 'gt-next/server';
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
49
|
+
export default async function RootLayout({ children }) {
|
|
50
|
+
const lang = await getLocale();
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<html lang={lang}>
|
|
54
|
+
<body>
|
|
55
|
+
<GTProvider>{children}</GTProvider>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
);
|
|
54
59
|
}
|
|
55
60
|
```
|
|
56
61
|
|
|
@@ -62,15 +67,25 @@ The `<T>` component is the simplest way to translate inline JSX content.
|
|
|
62
67
|
import { T } from 'gt-next';
|
|
63
68
|
|
|
64
69
|
export default function HomePage() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
return (
|
|
71
|
+
<T id='greeting'>
|
|
72
|
+
<p>Hello, world!</p>
|
|
73
|
+
</T>
|
|
74
|
+
);
|
|
70
75
|
}
|
|
71
76
|
```
|
|
72
77
|
|
|
78
|
+
If you have an existing project you would like to internationalize, you can use the `gt-react-cli` tool for initial setup.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install gt-react-cli
|
|
82
|
+
npx gt-react-cli scan
|
|
83
|
+
```
|
|
73
84
|
|
|
74
85
|
## Documentation
|
|
75
86
|
|
|
76
87
|
Full documentation, including guides, examples, and API references, can be found at [General Translation Docs](www.generaltranslation.com/docs).
|
|
88
|
+
|
|
89
|
+
## Contributing
|
|
90
|
+
|
|
91
|
+
We welcome any contributions to our libraries. Please submit a pull request!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-next",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"description": "A Next.js library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.server.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -12,18 +12,20 @@
|
|
|
12
12
|
"patch": "npm version patch",
|
|
13
13
|
"transpile": "tsc",
|
|
14
14
|
"build": "npm run transpile",
|
|
15
|
+
"clean:build": "rm -rf dist; npm run build",
|
|
16
|
+
"publish": "npm run clean:build && npm publish",
|
|
15
17
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
18
|
},
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/general-translation/gt-
|
|
21
|
+
"url": "git+https://github.com/general-translation/gt-libraries.git"
|
|
20
22
|
},
|
|
21
23
|
"author": "General Translation, Inc.",
|
|
22
24
|
"license": "FSL-1.1-ALv2",
|
|
23
25
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/general-translation/gt-
|
|
26
|
+
"url": "https://github.com/general-translation/gt-libraries/issues"
|
|
25
27
|
},
|
|
26
|
-
"homepage": "https://github.com/general-translation/gt-
|
|
28
|
+
"homepage": "https://github.com/general-translation/gt-libraries#readme",
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@types/node": ">=20.0.0 <23.0.0",
|
|
29
31
|
"@types/react": ">=18.0.0 <20.0.0",
|