搜索插件、代码仓与 APP 分类

插件详情v1.1.0

arb_translate

一个命令行工具,可使用 Google Gemini 或 OpenAI ChatGPT 自动为 ARB 文件生成缺失的翻译,由 LeanCode 提供。

AndroidiOSmacOSWindowsLinux
近 30 天下载
719
喜欢数
143
Pub 分数
140

安装插件

flutter pub add arb_translate

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

arb_translate 是一个命令行工具,利用 Google Gemini 或 OpenAI ChatGPT 的 AI 模型自动生成功能缺失的 ARB(App Resource Bundle)文件中的翻译。由 LeanCode 开发,该工具通过基于现有字符串提供准确的翻译建议,简化了本地化工作流程,减少了手动操作。该工具可无缝集成到跨多个平台(包括 Android、iOS、macOS、Windows 和 Linux)的 Flutter 项目中。它支持实时翻译和批量处理,非常适合需要高效管理多语言应用内容的团队。

适合场景

  • 自动化缺失翻译生成
  • 简化国际化工作流程
  • 减少手动翻译工作量
  • 支持多语言 Flutter 应用
  • 将人工智能驱动的翻译集成到CI/CD流水线中

主要特点

  • 通过 Google Gemini 或 OpenAI 提供的 AI 驱动翻译
  • 用于自动化的命令行界面
  • 支持 ARB 文件格式
  • 跨平台兼容性
  • 批量处理翻译键
  • 与 Flutter 项目的轻松集成

适合对象

  • Flutter 开发人员管理多种语言
  • 使用 ARB 进行本地化的团队
  • 需要快速翻译迭代的项目
  • 具有本地化需求的 CI/CD 流水线
  • 寻求AI辅助翻译工具的开发者

使用建议

  • 需要 Google Gemini 或 OpenAI 的 API 访问权限
  • 依赖互联网连接进行AI调用
  • 高用量的潜在成本
  • 翻译质量取决于提示的准确性
  • 不是人工审查的替代品

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

arb_translate

arb_translate on pub.dev

A command-line tool for automatically generating missing translations to ARB files using Google Gemini or OpenAI ChatGPT by LeanCode

Installation

$ dart pub global activate arb_translate

Configuration

arb_translate has been designed to seamlessly integrate with Flutter apps using flutter_localizations for code generation from ARB files. Thanks to this integration, the setup process for arb_translate can be completed in just a few steps:

  1. Generate your API key. You can create your Gemini key here or your OpenAI key here

  2. Save your API token in the environment variable ARB_TRANSLATE_API_KEY or add arb-translate-api-key: {your-api-key} to l10n.yaml in your project.

  3. (Optional) Select model used for translation. To do it add arb-translate-model to l10n.yaml or use command argument --model. The default model is gemini-2.5-flash. For all available models see arb_translate --help.

  4. (Optional) Add context of your application arb-translate-context: {your-app-context} eg. "sporting goods store app"

All other required parameters match flutter_localizations parameters and will be read from l10n.yaml file. You can override them using command arguments if necessary. See arb_translate --help for more information.

Configuration without l10n.yaml

If you project doesn't include l10n.yaml configuration you have to provide configuration using environment variables and command arguments. You also have to provide:

  1. --arb-dir The directory where the template and translated ARB files are located

  2. --template-arb-file The template ARB file that will be used as the basis for translation

See arb_translate --help for more information.

Custom model configuration

You can use arb_translate with any model with an OpenAI-compatible API. To configure a custom model:

  1. Add arb-translate-custom-model: {your-model-name} to l10n.yaml or specify as command argument custom-model: {your-model-name}
  2. Add arb-translate-custom-model-provider-base-url: {your-model-url} to l10n.yaml or specify as command argument: --custom-model-provider-base-url: {your-model-url}
  3. (Optional) Set target batch size appropriately to model token count limits by adding arb-translate-batch-size: {size} to your l10n.yaml or specify as command argument batch-size: {size}. Batch size is the number of characters of ARB messages in a single batch and does not include the prompt or app context.

Usage

To generate translations, simply call arb_translate. All messages included in the template ARB file but missing from other files will be translated. To add a new locale, simply add an empty ARB file.

$ arb_translate

Or without l10n.yaml file

$ arb_translate --arb-dir...

Read more

If you want to know how we made this tool and what challenges we had, read the story.

LeanCode

Built with ☕️ by LeanCode

所属分类

依赖

依赖清单 9 项

源码仓库

使用此插件的项目

暂无相关数据。