Skip to main content

A translation tool based ChatGPT

Project description

Translation God

Translation God是一个基于ChatGPT的翻译工具。 可以将一个目录下的所有json文件翻译成指定的语言,并按照原始的文件目录结构生成翻译结果。也可以是单个的javascrit文件,只是必须保证js文件的内容格式如下:

export default {
    "key": "value",
    "key2": "value2"
}

如果你想用人工翻译,可以将目录下的json文件借助TranslationGod生成一个Excel文件。 Excel文件经过人工翻译完成之后,可以再次借助TranslationGod将Excle文件翻译写入到各个对应语言的目录中,依然是和源语言的目录结构保持一致。

Install

因为包没有推送到仓库中,所以安装的第一步,需要下载源码tar包,并解压, 进入包目录,会看到setup.py这个文件,安装TranslationGod执行如下命令:

pip setup.py install

安装成功之后,我们在终端执行 tg -h 查看tg的一些参数和使用帮助

Usage

设置OPENAI_API_KEY环境变量

export OPENAI_API_KEY="sk-xxxxxxx"

翻译目录下的JSON文件或者翻译单个JSON文件

tg --command=tj --sourcelang="Chinese"  --targetlangs="English,Japanese,French" --input="./jsondirectory_or_file" --output="./output"
# or
tg -c tj -s Chinese -t "English,Japanese,French" -i "./jsondirectory" -o "./output"

翻译Excel文件

tg --command=te --sourcelang="Chinese" --input="./my_excel.xlsx" --output="./my_translated_excel.xlsx"

# Or

tg -c te -s Chinese -i "./my_excel.xlsx" -o "./my_translated_excel.xlsx"

将目录下的JSON文件转换成Excel文件

# this command will produce 2 files, one is output option specified, such as "result.xlsx", the other one is "result.map.xlsx"
tg --command=cje --sourcelang="Chinese" --targetlangs="English,Japanese,French" --input="./json_file" --output="./must_end_with_xlsx.xlsx"

# Or

tg -c cje -s "Chinese" -t "English,Japanese,French" -i "./json_file" -o "must_end_with_xlsx.xlsx"

将Excel的文件转换成对应翻译语言的目录和JSON文件

注意:excel文件必须保持TranslationGod生成的格式。 .map.xlsx文件存储的key,当没有.map.xlsx文件时,将xlsx的第一列作为key

# this command will convert result.xlsx and result.map.xlsx to json files
tg --command cej --input "./result.xlsx" --output "outputdir/"

# Or

tg -c cej -i "./result.xlsx" -o "outputdir/"

Generate missing translation entries and output the results to the specified directory

tg --command gld --input <lang_dir_or_file> --source <source_lang> --targetlangs="English,Japanese,French" --output <output_langs_dir>

# or

tg -c gld -i <lang_dir_or_file> -s <source_lang> -t "English,Japanese,French" -o <output_langs_dir>

Merge json files in <input_path> to <target_path>

tg --command mj --input <input_dir> --output <output_dir>

# or

tg -c mj -i <input_dir> -o <output_dir>

Insert or Update translation entry

tg --command=upsert --input <file> --key <key>   --value <value>

# or

tg -c upsert -i <file> -k <key> -v <value>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

translation_god-1.0.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

translation_god-1.0.2-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file translation_god-1.0.2.tar.gz.

File metadata

  • Download URL: translation_god-1.0.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for translation_god-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4dd90b8871efa4c352c8db167ec81a084d094165b2dde2b3b5f3fee86cfb8776
MD5 57f166004a6a753de65bf7315bc0510b
BLAKE2b-256 e58a11547b7cec69d14b8b685f7a6e5c6a16539bfc5f6528ff65f54b2cc654b7

See more details on using hashes here.

File details

Details for the file translation_god-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for translation_god-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a7a1652d390e021049ae4f984ee5f6d3f417153987a0fd12ab0a46fd726afb40
MD5 5f024c1a655dc80c49872bfc51542a96
BLAKE2b-256 ba914f1f581a3ee4507fd1a56ab6c29dc1aaa3ab71bcda6eb8989743379974f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page