Home - gs-kikim/docs-trans-app GitHub Wiki

Docs Translate

Markdown(.md) , reStructuredText(.rst) λ¬Έμ„œλ“€μ„ 섀정값에 따라 λ²ˆμ—­ν•˜λŠ” CLI νˆ΄μž…λ‹ˆλ‹€. {config}.json 파일 속성 쀑 "service_name": "Google_v2" μž…λ ₯ μ‹œ [GOOGLE_API_KEY]κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

Installation

$ pip install docs-translate

Settings file

{config}.json파일 κΈ°λ³Έ 섀정은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

Settings file content example:

{
  "target_dir":"{language_convert_dir}",
  "source_lang": "ko",
  "target_lang": "en",
  "service_name": "Google_v2",
}

μ„€μ • 파일 μž‘μ„± ν›„ CLI λͺ…λ Ήμ–΄ μ˜΅μ…˜μ—μ„œ -c CONFIG_PATHλ₯Ό μΆ”κ°€ν•˜μ…”μ•Ό ν•©λ‹ˆλ‹€.

Usage

μ„€μ •ν•˜μ§€ μ•Šμ•„λ„ μœ„ μ˜΅μ…˜μ„ 톡해 μ„€μ • κ°€λŠ₯ν•©λ‹ˆλ‹€.

$ docs-translate [-h] [-c CONFIG_PATH]
               [-s {Google,Google_v2}] [-S] [-T]
               [-path {source_path}] [-d {target_dir}]

예λ₯Ό λ“€μ–΄ 폴더 ꡬ쑰가 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

D:/
β”œβ”€β”€ ko/
β”‚   └── example_folder/
β”‚       β”œβ”€β”€ ex1.md
β”‚       └── ex2.py
β”‚       └── ex3.rst
β”œβ”€β”€ en/
β”‚   └── target_dir/
β”‚       
└── config.json

[μ˜ˆμ‹œ 1] D:\ko\ ν•˜μœ„ .md, .rst νŒŒμΌλ“€μ„ D:\en ν•˜μœ„ 파일둜 λ²ˆμ—­ ν•˜κ³ μž ν•©λ‹ˆλ‹€.

  1. config.json은 μ•„λž˜μ™€ 같이 μ„€μ •ν•©λ‹ˆλ‹€.
{
  "target_dir":"D:\\en",
  "source_lang": "ko",
  "target_lang": "en",
  "service_name": "Google_v2",
}
  1. CLIλ₯Ό 톡해 λͺ…λ Ήμ–΄λ₯Ό μž…λ ₯ν•©λ‹ˆλ‹€. target_dir 섀정을 -d D:\en μ˜΅μ…˜μ„ ν†΅ν•΄μ„œλ„ κ°€λŠ₯ν•©λ‹ˆλ‹€.
> docs-translate -c D:\config.json -path D:\ko
  1. μ•„λž˜μ™€ 같이 폴더 및 파일이 순차적으둜 생성 ν›„ λ²ˆμ—­λ©λ‹ˆλ‹€.
D:/
β”œβ”€β”€ ko/
β”‚   └── example_folder/
β”‚       β”œβ”€β”€ ex1.md
β”‚       └── ex2.py
β”‚       └── ex3.rst
β”œβ”€β”€ en/
β”‚   └── target_dir/
β”‚   └── example_folder/
β”‚       β”œβ”€β”€ ex1.md
β”‚       └── ex3.rst
└── config.json

[μ˜ˆμ‹œ 2] D:\ko\ ν•˜μœ„ .md, .rst νŒŒμΌλ“€μ„ D:\en\target_dir ν•˜μœ„ 파일둜 λ²ˆμ—­ ν•˜κ³ μž ν•©λ‹ˆλ‹€.

  1. config.json은 [μ˜ˆμ‹œ 1]κ³Ό κ°™μŠ΅λ‹ˆλ‹€.
  2. CLIλ₯Ό 톡해 λͺ…λ Ήμ–΄λ₯Ό μž…λ ₯ν•©λ‹ˆλ‹€. config 섀정보닀 -d μ˜΅μ…˜ 값이 높은 μš°μ„ μˆœμœ„λ₯Ό κ°–μŠ΅λ‹ˆλ‹€.
> docs-translate -c D:\config.json -path D:\ko -d c:\en\target_dir
  1. μ•„λž˜μ™€ 같이 폴더 및 파일이 순차적으둜 생성 ν›„ λ²ˆμ—­λ©λ‹ˆλ‹€.
D:/
β”œβ”€β”€ ko/
β”‚   └── example_folder/
β”‚       β”œβ”€β”€ ex1.md
β”‚       └── ex2.py
β”‚       └── ex3.rst
β”œβ”€β”€ en/
β”‚   └── target_dir/
β”‚       └── example_folder/
β”‚           β”œβ”€β”€ ex1.md
β”‚           └── ex3.rst
└── config.json

Positional arguments:

  • path Path to folder to process. If not set, uses current folder
  • -d TARGET_DIR, --target_dir TARGET_DIR, If not set, the target_dir in config.json is set

Optional arguments:

  • -h, --help, show this help message and exit
  • -c CONFIG_PATH, --config_path CONFIG_PATH, Path to config_file
  • -s {Yandex,Google,Bing,Deepl}, --service_name {Yandex,Google,Bing,Deepl}, Translating service
  • -S SOURCE_LANG, --source_lang SOURCE_LANG, Source language code
  • -T TARGET_LANG, --target_lang TARGET_LANG, Target language code

Translation services:

Now used Yandex, Google, Bing, Deepl, Google_v2

Some of them can be not working, try it and find the most suitable for you

Google --> It's free, but the translation isn't good.
Google_v2 --> need to google Cloud Translation API key.

μ°Έκ³