@ttoss/i18n-cli 0.6.5 → 0.7.1
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 +86 -7
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -11,25 +11,104 @@ You should declare your messages as describe in the [FormatJS](https://formatjs.
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
pnpm add @ttoss/i18n-cli --dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
Add this script to your `package.json`
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"scripts": {
|
|
24
|
+
"i18n": "ttoss-i18n",
|
|
25
|
+
"i18n:extract": "ttoss-i18n --no-compile",
|
|
26
|
+
"i18n:ignore-ttoss-pkg": "ttoss-i18n --ignore-ttoss-packages"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
15
29
|
```
|
|
16
30
|
|
|
17
31
|
## Usage
|
|
18
32
|
|
|
19
|
-
Extract only:
|
|
33
|
+
### Extract only:
|
|
20
34
|
|
|
21
35
|
```sh
|
|
22
|
-
|
|
36
|
+
pnpm run i18n:extract
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This command extracts translations from your code but doesn't compile them. And created a new path (`i18n/lang/en.json`) if doesn't exists with extracted translations. As followed below:
|
|
40
|
+
|
|
41
|
+
- 📂 i18n
|
|
42
|
+
- 📂 lang
|
|
43
|
+
- 📄 en.json
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
// i18n/lang/en.json
|
|
47
|
+
{
|
|
48
|
+
"0XOzcH": {
|
|
49
|
+
"defaultMessage": "My title page",
|
|
50
|
+
"description": "Page title"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To translate your text, you only need to duplicate the file `i18n/lang/en.json` to your new language and translate it, as followed below:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
// i18n/lang/pt-BR.json
|
|
59
|
+
{
|
|
60
|
+
"0XOzcH": {
|
|
61
|
+
"defaultMessage": "Título da minha página",
|
|
62
|
+
"description": "Título da página"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
23
65
|
```
|
|
24
66
|
|
|
25
|
-
Extract and compile:
|
|
67
|
+
### Extract and compile:
|
|
26
68
|
|
|
27
69
|
```sh
|
|
28
|
-
|
|
70
|
+
pnpm run i18n
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This command extracts translations from your code and compiles them into a usable format. And create a new path (`i18n/compiled/en.json`) if doesn't exists with compiled translations based in all of the files on path `i18n/lang`. As followed below:
|
|
74
|
+
|
|
75
|
+
- 📂 i18n
|
|
76
|
+
- 📂 compiled
|
|
77
|
+
- 📄 en.json
|
|
78
|
+
- 📄 pt-BR.json
|
|
79
|
+
|
|
80
|
+
#### en.json
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
// i18n/compiled/en.json
|
|
84
|
+
{
|
|
85
|
+
"0XOzcH": [
|
|
86
|
+
{
|
|
87
|
+
"type": 0,
|
|
88
|
+
"value": "My title page"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
29
92
|
```
|
|
30
93
|
|
|
31
|
-
|
|
94
|
+
#### pt-BR.json
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
// i18n/compiled/pt-BR.json
|
|
98
|
+
{
|
|
99
|
+
"0XOzcH": [
|
|
100
|
+
{
|
|
101
|
+
"type": 0,
|
|
102
|
+
"value": "Título da minha página"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Ignoring ttoss packages:
|
|
32
109
|
|
|
33
110
|
```sh
|
|
34
|
-
|
|
111
|
+
pnpm run i18n:ignore-ttoss-pkg
|
|
35
112
|
```
|
|
113
|
+
|
|
114
|
+
This command extracts and compiles translations, ignoring translations from all ttoss packages, if you have them installed in your project.
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/i18n-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"license": "UNLICENSED",
|
|
3
|
+
"version": "0.7.1",
|
|
5
4
|
"author": "ttoss",
|
|
6
5
|
"contributors": [
|
|
7
6
|
"Pedro Arantes <arantespp@gmail.com> (https://arantespp.com)"
|
|
@@ -19,12 +18,12 @@
|
|
|
19
18
|
"dist"
|
|
20
19
|
],
|
|
21
20
|
"dependencies": {
|
|
22
|
-
"@formatjs/cli-lib": "^6.
|
|
23
|
-
"glob": "^10.3.
|
|
21
|
+
"@formatjs/cli-lib": "^6.3.3",
|
|
22
|
+
"glob": "^10.3.10"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"tsup": "^
|
|
27
|
-
"@ttoss/config": "^1.
|
|
25
|
+
"tsup": "^8.0.1",
|
|
26
|
+
"@ttoss/config": "^1.31.1"
|
|
28
27
|
},
|
|
29
28
|
"publishConfig": {
|
|
30
29
|
"access": "public",
|