![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A tool for translating JSON files from English to Chinese using multiple translation APIs
A Python tool for translating JSON files from English to Chinese, supporting multiple translation APIs.
一个支持多种翻译API的JSON文件英译中工具。
pip install json-trans
from json_trans import translate_json_baidu
translate_json_baidu(
input_file="input.json",
output_file="output.json",
app_id="your_baidu_app_id",
secret_key="your_baidu_secret_key",
fields_to_translate=["title", "content", "description"] # Required | 必需
)
from json_trans import translate_json_google
translate_json_google(
input_file="input.json",
output_file="output.json",
fields_to_translate=["summary", "details", "text"], # Required | 必需
credentials_path="path/to/google_credentials.json" # Optional | 可选
)
from json_trans import translate_json_gemini
# Basic usage | 基本用法
translate_json_gemini(
input_file="input.json",
output_file="output.json",
api_key="your_gemini_api_key",
fields_to_translate=["title", "content", "description"]
)
# With custom model and role | 使用自定义模型和角色
translate_json_gemini(
input_file="input.json",
output_file="output.json",
api_key="your_gemini_api_key",
fields_to_translate=["title", "content", "description"],
model="gemini-pro", # Optional | 可选
role="translator" # Optional | 可选
)
You can set up environment variables for different environments: 可以为不同环境设置环境变量:
# Baidu Translate API credentials
BAIDU_APP_ID=your_baidu_app_id
BAIDU_SECRET_KEY=your_baidu_secret_key
# Google Gemini API configuration
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.0-flash-exp
# Google Cloud Translation credentials path
GOOGLE_CREDENTIALS_PATH=path/to/your/credentials.json
Baidu Translate API:
Google Cloud Translation API:
Google Gemini API:
# Clone the repository | 克隆仓库
git clone https://github.com/liyown/json-trans.git
cd json-trans
# Install dependencies | 安装依赖
poetry install
# Set up environment variables | 设置环境变量
cp .env.example .env
# Edit .env with your credentials | 编辑 .env 填入您的凭证
# Run tests | 运行测试
poetry run pytest
# Run all tests | 运行所有测试
poetry run pytest
# Run with coverage report | 运行并生成覆盖率报告
poetry run pytest --cov
# Run specific test | 运行特定测试
poetry run pytest tests/test_translator.py::test_json_translator_init
This project is licensed under the MIT License - see the LICENSE file for details.
本项目采用MIT许可证 - 查看LICENSE文件了解详情。
FAQs
A tool for translating JSON files from English to Chinese using multiple translation APIs
We found that json-trans demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.