Skip to content

Commit

Permalink
v.2.0.0 fallback logic & concurrency limit set & structure update
Browse files Browse the repository at this point in the history
  • Loading branch information
ParvinEyvazov committed Dec 21, 2023
1 parent b29cbee commit 2f6232e
Show file tree
Hide file tree
Showing 22 changed files with 1,871 additions and 966 deletions.
130 changes: 75 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,83 @@ jsontt <your/path/to/file.yaml/yml>

## Options

- -V, --version output the version number
- -T, --translator <Translator> specify translation service (choices: "google", "libre", "argos", "bing")
- -f, --from <Language> the translate language from it, e.g., --from en
- -t, --to <Languages...> the Languages to translate into, e.g., --to ar fr zh-CN
- -n, --name the name of the output file (optional), e.g., --name newFileName
- -h, --help display help for command
```
-V, --version output the version number
-m, --module <Module> specify translation module
-f, --from <Language> from language
-t, --to <Languages...> to translates
-n, --name <string> optional ↵ | output filename
-fb, --fallback <string> optional ↵ | fallback logic,
try other translation modules on fail | yes, no | default: no
-cl, --concurrencylimit <number> optional ↵ | set max concurrency limit
(higher faster, but easy to get banned) | default: 3
-h, --help display help for command
```

## Examples

Translate a JSON file using Google Translate:

```bash
jsontt <your/path/to/file.json> --translator google --from en --to ar fr zh-CN
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN
```

- with output name

```bash
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles
```

- with fallback logic (try other possible translation modules on fail)

```bash
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles -fb yes
```

- set concurrency limit (higher faster, but easy to get banned | default: 3)

```bash
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles --fallback yes --concurrencylimit 10
```

With output name
### other usage examples

- translate (json/yaml)

```bash
jsontt file.json
```

```bash
jsontt <your/path/to/file.json> --translator google --from en --to ar fr zh-CN --name myFiles
jsontt folder/file.json
```

```bash
jsontt "folder\file.json"
```

```bash
jsontt "C:\folder1\folder\en.json"
```

- with proxy (only Google Translate module)

```bash
jsontt file.json proxy.txt
```

Result will be in the same folder as the original JSON/YAML file.

<br>

- help

```bash
jsontt -h
```

```bash
jsontt --help
```

# **2. 💥 Package Usage**
Expand Down Expand Up @@ -339,11 +397,9 @@ Let`s translate our json file into another language and save it into the same fo

let path = 'C:/files/en.json'; // PATH OF YOUR JSON FILE (includes file name)

await translator.translateFile(
path,
translator.languages.English,
translator.languages.German
);
await translator.translateFile(path, translator.languages.English, [
translator.languages.German,
]);
```

```bash
Expand Down Expand Up @@ -432,46 +488,6 @@ To ignore words on translation use `{{word}}` OR `{word}` style on your object.
}
```

## **7. CLI commands**

- translate (json/yaml)

```bash
jsontt file.json
```

```bash
jsontt folder/file.json
```

```bash
jsontt "folder\file.json"
```

```bash
jsontt "C:\folder1\folder\en.json"
```

- with proxy

```bash
jsontt file.json proxy.txt
```

Result will be in the same folder as the original JSON/YAML file.

<br>

- help

```bash
jsontt -h
```

```bash
jsontt --help
```

## How to contribute?

- Clone it
Expand All @@ -494,7 +510,7 @@ yarn

- Update translation

Go to file `src/core/core.ts`
Go to file `src/modules/functions.ts`

- Update JSON operations(deep dive, send translation request)

Expand Down Expand Up @@ -580,6 +596,10 @@ Make sure your terminal has admin access while running these commands to prevent

:heavy_check_mark: YAML file Translate

:heavy_check_mark: Fallback Translation (try new module on fail)

:heavy_check_mark: Can set concurrency limit manually

- [ ] Libre Translate option (in code package)

- [ ] Argos Translate option (in code package)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.10.0",
"version": "2.0.0",
"license": "MIT",
"main": "dist/index.js",
"description": "Translate your JSON file or object into another languages with Google Translate API",
Expand Down
Loading

0 comments on commit 2f6232e

Please sign in to comment.