Skip to main content

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>

Metadata

Release files for translation-god 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for translation-god 1.0.2
File Size Uploaded
translation_god-1.0.2.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for translation-god 1.0.2
File Interpreter ABI Platform
translation_god-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.9 kB

Release files / translation_god-1.0.2.tar.gz

Download URL translation_god-1.0.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4dd90b8871efa4c352c8db167ec81a084d094165b2dde2b3b5f3fee86cfb8776
BLAKE2b-256 checksum
How to use checksums
e58a11547b7cec69d14b8b685f7a6e5c6a16539bfc5f6528ff65f54b2cc654b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / translation_god-1.0.2-py3-none-any.whl

Download URL translation_god-1.0.2-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7a1652d390e021049ae4f984ee5f6d3f417153987a0fd12ab0a46fd726afb40
BLAKE2b-256 checksum
How to use checksums
ba914f1f581a3ee4507fd1a56ab6c29dc1aaa3ab71bcda6eb8989743379974f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page