auto-translate-json-library 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/README.MD +113 -0
  2. package/package.json +2 -2
package/README.MD ADDED
@@ -0,0 +1,113 @@
1
+ # Use as library
2
+
3
+ ```shell
4
+ npm i auto-translate-json-library
5
+ ```
6
+
7
+ ```Typescript
8
+ import { translate, Configuration } from 'auto-translate-json-library';
9
+
10
+ let config: Configuration = {} as Configuration;
11
+
12
+ // set google api key
13
+ config.translationKeyInfo = {
14
+ kind: 'google',
15
+ apiKey: googleApiKey
16
+ };
17
+ const pivotTranslation="./en.json";
18
+ await translate(pivotTranslation, config) ;
19
+ // translation for example fr.json in same folder as pivotTranslation should contain the translations
20
+ ```
21
+
22
+ # Use as command line tool
23
+
24
+ first install it
25
+
26
+ ```shell
27
+ npm i auto-translate-json-library
28
+ ```
29
+
30
+ do not forget to set translation engine parameters in environment variables or .env file
31
+
32
+ ```shell
33
+
34
+ ```shell
35
+ node node_modules\auto-translate-json-library\index.js --pivotTranslation=./translations/en.json
36
+ ```
37
+
38
+ if you clone repo you can use the following command
39
+
40
+ ```shell
41
+ npm start --pivotTranslation=./test/en.json
42
+ ```
43
+
44
+ ```
45
+ # CLI PARAMETERS
46
+
47
+ mode,
48
+ file or folder,
49
+ default is file
50
+
51
+ startDelimiter,
52
+ start delimiter,
53
+ default is {
54
+
55
+ endDelimiter,
56
+ end delimiter,
57
+ default is }
58
+
59
+ keepExtraTranslations,
60
+ keep extra translations (not present in pivot translation),
61
+ default is keep,
62
+ it could be keep or remove
63
+
64
+ keepTranslations,
65
+ keep existing translations,
66
+ default is keep
67
+ it could be keep or retranslate
68
+
69
+ sourceLocale
70
+ source locale
71
+ it could be en or fr ...
72
+ if specified it must match with pivot translation
73
+
74
+ pivotTranslation
75
+ pivot translation file that will be used as source for translations
76
+
77
+ # ENVIRONMENT VARIABLES
78
+
79
+ google parameters
80
+ ATJ_GOOGLE_API_KEY=
81
+
82
+ aws parameters
83
+ ATJ_AWS_ACCESS_KEY_ID=
84
+ ATJ_AWS_SECRET_ACCESS_KEY=
85
+ ATJ_AWS_REGION=
86
+
87
+ azure parameters
88
+ ATJ_AZURE_SECRET_KEY=
89
+ ATJ_AZURE_REGION=
90
+
91
+ deepl pro parameters
92
+ ATJ_DEEPL_PRO_SECRET_KEY=
93
+ deepl free parameters
94
+ ATJ_DEEPL_FREE_SECRET_KEY=
95
+
96
+ start delimiter
97
+ ATJ_START_DELIMITER={{
98
+ end delimiter
99
+ ATJ_END_DELIMITER=}}
100
+
101
+ file or folder
102
+ ATJ_MODE=file
103
+
104
+ source locale
105
+ ATJ_SOURCE_LOCALE=en
106
+
107
+ keep or retranslate existing translations
108
+ ATJ_KEEP_TRANSLATIONS=keep
109
+
110
+ keep or remove extra translations
111
+ ATJ_KEEP_EXTRA_TRANSLATIONS=keep
112
+
113
+ You can also use .env file to store environment variables
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-translate-json-library",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Automatically translates JSON language files to other languages using Google Translate,AWS,Azure or DeepL",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@aws-sdk/client-translate": "^3.121.0",
34
- "@google-cloud/translate": "^6.3.1",
34
+ "@google-cloud/translate": "^7.0.0",
35
35
  "axios": "^0.27.2",
36
36
  "dotenv": "^16.0.1",
37
37
  "form-data": "^4.0.0",