パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.3.5

auto_translator

クラウド翻訳サービスを使用してARBファイルを翻訳するためのコマンドラインツールです。

macOSWindowsLinux
30日間ダウンロード
453
いいね数
35
Pub ポイント
150

パッケージをインストール

flutter pub add auto_translator

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

クラウド翻訳サービスを使用してARB(App Resource Bundle)ファイルの翻訳を自動化するためのコマンドラインツールです。英語のARBファイルを複数のターゲット言語に変換することで、ローカライズワークフローを簡素化し、国際化における手作業を削減します。マルチリンガルなFlutterアプリを管理する開発者にとって理想的で、既存のビルドプロセスとシームレスに統合され、macOS、Windows、Linuxでのクロスプラットフォーム運用をサポートしています。このツールは外部翻訳APIを利用し、高品質な翻訳を保証するとともに、言語ファイル間の一貫性を維持します。

用途

  • ARB ファイルの翻訳を自動化する
  • CI/CDパイプラインとの統合
  • マルチリンガルなFlutterアプリケーションのサポート
  • 手動翻訳作業負荷の軽減
  • 一括で翻訳を更新する
  • チーム間で言語ファイルを同期する

主な機能

  • APIを介したクラウドベースの翻訳
  • コマンドラインインターフェース
  • クロスプラットフォーム互換性
  • ARB ファイル形式のサポート
  • 翻訳のバッチ処理
  • Flutter ローカリゼーションワークフローとの統合

適している対象

  • 複数の言語を管理するFlutter開発者
  • ローカライズに ARB を使用するチーム
  • 翻訳のCI/CD自動化
  • 頻繁な翻訳更新を必要とするプロジェクト
  • 時間を節約できるローカリゼーションツールを探している開発者

注意事項

  • 翻訳API呼び出しにインターネット接続が必要です
  • サードパーティの翻訳サービスの品質に依存
  • 大量使用時の潜在的なコスト
  • 適切なAPIキーの設定が必要です
  • ARB ファイル形式に制限されています
  • カスタム翻訳プロバイダー用に追加のセットアップが必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Auto Translator

A command-line tool that simplifies translation of an ARB template file to selected languages. This package is designed to work seamlessly with the flutter_localizations and intl packages, Flutter's preferred internationalization approach.

Features

  • Seamless integration with flutter_localizations and intl packages.
  • Works with Google Cloud Translate & DeepL Translate.
  • Minimal quota usage.
  • Works with simple & complex ARB strings, conditions, and variables.
  • Uses placeholder examples for more accurate translations involving proper nouns and other unique cases.
  • Specify translator service and/or source language for individual target languages.

Support the developer

If you found this package useful, please consider contribuitng to it's continued development. Or just show the developer a little love & support. Every little bit helps!

Buy me a coffee

Getting Started

1. Setup Translation Service(s)

Auto Translator supports Google Cloud Translate and DeepL out of the box. You may specify either one as your primary service in the l10n.yaml config file. If neither is provided, the default (Google) is used. You may also specify different translators on a per-language basis, as seen in Preferred Services.

If you are configuring only one service, you can save the API key in a file in the project root directory called translator_key or as a json map in translator_keys. If configuring both services, you must use the json map approach.

:warning: DO NOT publish your key file to Github or similar VCS.

You can also specify an alternate key file path.

Google Cloud Translate

If you do not have a Google Cloud Project with the Cloud Translation API enabled, follow the guide here.

DeepL Translate

If you do not have DeepL API access, follow DeepL's guide to creating an account and obtaining API access here

2. Add auto_translator to your project

Add auto_translator under dev_dependencies in pubspec.yaml

dev_dependencies:
  auto_translator: ^2.3.6
3. Setup the config files

auto_translator uses the same config file as the intl package, Flutter's recommended package for internationalizing your app, as explained here.

If you have not already created the l10n.yaml file, do so now.

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart

translator:
  #Defaults to Google Translate.
  service: Google

  targets:
    - es-ES
    - fr
    - ja

The first three parameters are used by intl as well as auto_translator. The translator section is specific to auto_translator.

The targets parameter is required and tells auto_translator which languages to translate the template file to. Available languages can be found here.

You can also configure preferred source templates for any given target language.

Regional Designations

You can use 2-letter language codes and regional designations (en-US, en-GB, es-Es, etc.).

4. Run the package

Once configured, run the package from the command line.

flutter pub get
dart run auto_translator

All translations will be placed in the defined location and be compatible with flutter_localizations and intl.

Additional Usage

Placeholder Examples

Some translations are more accurate when using an example in place of a generic placeholder variable name. auto_translator now passes a placeholder's example if provided to ensure better quality translations.

"viewingArtwork": "Now viewing {artworkTitle}.",
  "@viewingArtwork": {
      "placeholders": {
          "artworkTitle": {
              "type": "String",
              "example": "Mona Lisa"
          }
      }
  }
Force Translation

To prevent unecessary Google Cloud Translate quota usage, messages that already exist in a target ARB file are not retranslated. You can force a translation by adding the force parameter to translator options in a message's metadata in the template file.

"title": "New Title",
"@title": {
  "description": "...",
  "translator": {
    "force": true
  }
}
Ignore ARB String

You can also tell the translator to ignore a particular message with the ignore tag.

"doNotTranslate": "DO NOT TRANSLATE THIS STRING!!!",
"@doNotTranslate": {
  "description": "...",
  "translator": {
    "ignore": true
  }
}
Preferred Templates

Sometimes, you may wish to specify a language that translates more accurately to a target than the language used in the template-arb-file. For that, you can provide a prefer-lang-templates map to specify a preferred source language to use as a template for any target language.

translator:
  # use es-ES template for fr translation ja for ko
  # all other translations will use [template-arb-file]
  prefer-lang-templates:
    fr: es
    ko: ja
Preferred Services

As one service may outperform the other in a given language you may wish to specify a service an a per-language basis. This can be done by providing a prefer-service map in the config file.

translator:
  # use DeepL for tr and uk
  # all other translations will use the primary service
  # (presumably Google in this case)
  prefer-service:
    # capitilization does not matter for service name
    DeepL:
      - tr
      - uk

Each API key must be provided in the key file (service name capitalization does not matter).

{
  "google": "CLOUD_TRANSLATE_API_KEY",
  "deepL": "DEEP_L_API_KEY"
}
Verbose output

You can enable verbose output with the --verbose (-v) flag. This is especially helpful in pinpointing the cause of errors.

Alternate config file

By default, the config file is named l10n.yaml and is located in the project's root directory. You can pass in an alternate file path when running on the command line using the --config-file option.

Alternate key file

By default, auto_translator looks for keys in the project root at translator_keys or translator_key. You may specify a different location in the config file.

translator:
  key_file: path/to/key/file

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。