Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.2.0.0 fallback logic & concurrency limit set & structure update #46

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 85 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<p align="center">
<span align="center">✨ Sponsored by Moniesto - Bridge between Traders and Investors in Crypto ✨</span>
</p>

<p align="center">
<span align="center">✨ https://moniesto.com ✨</span>
</p>



<p align="center" >
<img src="https://i.hizliresim.com/stgrebn.png" alt="jsontt logo" width="150" />
</p>
Expand Down Expand Up @@ -63,25 +73,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 --fallback 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
```

### other usage examples

- translate (json/yaml)

```bash
jsontt file.json
```

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

With output name
```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 <your/path/to/file.json> --translator google --from en --to ar fr zh-CN --name myFiles
jsontt --help
```

# **2. 💥 Package Usage**
Expand Down Expand Up @@ -339,11 +407,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 +498,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 +520,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 +606,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
Loading