🚀 motaword CLI
MotaWord CLIを使用すると、MotaWordアカウントとさまざまな方法でやり取りし、翻訳とローカライズのニーズを管理することができます。
🚀 クイックスタート
事前ビルド済みバイナリのダウンロード
このGitHubリポジトリのReleasesを使用して、該当するプラットフォーム用のアプリケーションをダウンロードします。motaword
はLinux、Windows、MacOS用にさまざまな構成でリリースされています。
ダウンロード先: Releases
bashインストーラーを使用したインストール
curl
で使用できるinstaller.sh
bashスクリプトを提供しています。これを使用すると、作業ディレクトリにmotaword
CLIの最新バージョンをインストールできます。installer.sh
スクリプトはこのリポジトリにあります。
以下のコマンドを実行してmotaword
をインストールできます。
curl -s https://raw.githubusercontent.com/motaword/cli/master/installer.sh | bash
Homebrewを使用したインストール
Macユーザーは、Homebrewを使用して簡単にmotaword
をインストールできます。
- タップを追加します。
brew tap motaword/homebrew-tap
motaword
をインストールします。
brew install motaword
これで、システム内のどこからでもmotaword
を実行できます。
✨ 主な機能
motaword
を使用すると、MotaWordプラットフォームのあらゆる側面にアクセスできます。翻訳用のファイルの提出からレポートの取得、用語集の管理からスタイルガイドの管理まで、様々な操作が可能です。また、motaword
はローカルで使用することも、ソフトウェアの継続的なローカライズのためのCI/CDの一部として使用することもできます。
📦 インストール
上述の通り、以下の方法でmotaword
をインストールできます。
- 事前ビルド済みバイナリのダウンロード
- bashインストーラーを使用したインストール
- Homebrewを使用したインストール
💻 使用例
基本的な使用法
コマンドカテゴリ/親コマンド
motaword
がサポートするすべてのコマンドを表示するには、以下のコマンドを実行します。
> motaword help
Usage:
motaword [command]
Available Commands:
async Manage async operations
auth Authentication settings
continuous-projects Manage your continuous projects
debug Debug your MotaWord configuration and environment
documents Manage documents
get-access-token Retrieve an access token to interact with the API.
glossaries Manage glossaries
help Help about any command
help-config Show CLI configuration help
help-input Show CLI input help
projects Manage projects
reports Manage reports
search Manage search operations
static Manage static endpoints
stats Manage stats
strings Manage strings
styleguides Manage styleguides
translate Instantly translate your content with your existing TM and MT resources. This is an alias to `continuous-projects translate`
users Manage users
webhooks Manage webhooks
Flags:
-h, --help help for motaword
-o, --output-format string Output format [json, yaml] (default "json")
--profile string Credentials profile to use for authentication (default "default")
-q, --query string Filter / project results using JMESPath
--raw Output result as raw rather than pretty JSON
--server string Override server URL
--v Enable WARN level verbose log output
--verbose Enable DEBUG level verbose log output, same as --vvv flag
--vv Enable INFO level verbose log output
--vvv Enable DEBUG level verbose log output
Additional help topics:
motaword blog Manage blog articles
motaword clients Manage client account
motaword token Manage token operations
Use "motaword [command] --help" for more information about a command.
サブコマンド
アカウントに関するレポートを取得するには、以下のコマンドを実行します。
> motaword reports
Usage:
motaword reports [command]
Available Commands:
get-language-pairs-report Returns a report of language pairs.
get-projects-report Returns a report of corporate account users.
get-users-report Returns a report of corporate account users.
reports
カテゴリのサブコマンドを使用して、特定のレポートを取得できます。
> motaword reports get-language-pairs-report
{
"meta": {
"paging": {
"links": {
"next": null,
"previous": null,
"self": {
"href": "https://api.staging.motaword.com/v0/reports/language-pairs"
}
},
"page": 1,
"per_page": 2,
"total_count": 2
}
},
"report": [
{
"language_pair": {
"source_language": "af",
"target_language": "ak"
},
"spending": "343.42",
"word_count": "2475"
},
{
"language_pair": {
"source_language": "en-US",
"target_language": "fr"
},
"spending": "11.70",
"word_count": "195"
}
]
}
ほとんどのコマンドはJSON応答を返します。jq
などのツールを使用すると、これらのJSON応答を処理できます。
> motaword reports get-language-pairs-report \
| jq '.report[] | "For \(.language_pair.source_language) into \(.language_pair.target_language), we spent $\(.spending)"'
"For af into ak, we spent $343.42"
"For en-US into fr, we spent $11.70"
コマンドパラメータ
一部のコマンドはパラメータとJSONペイロードを受け付けます。コマンドが受け付けるパラメータやJSONペイロードの種類を確認するには、--help
フラグを使用します。
> motaword projects get-project --help
Get single project
Usage:
motaword projects get-project id [flags]
Flags:
-h, --help help for get-project
--with[] string Include detailed information. Possible values 'client', 'vendor', 'score'
get-project
コマンドはid
パラメータとwith[]
フラグのみを受け付けます。
一部のコマンドはJSONペイロードを受け付けます。これらは通常、作成/更新コマンド(HTTPでのPOST/PUTリクエストなど)です。
> motaword reports get-projects-report --help
properties:
budget_code:
type: string
date_from:
format: date-time
type: string
date_to:
format: date-time
type: string
source_languages:
items:
type: string
type: array
target_languages:
items:
type: string
type: array
users:
items:
format: int64
type: integer
type: array
type: object
Usage:
motaword reports get-projects-report [flags]
Flags:
-h, --help help for get-projects-report
ヘルプ出力のリクエストスキーマに従って、以下のようにペイロードを送信できます。
{
"date_from":"2021-04-21T16:07:12.727Z",
"date_to":"2021-05-21T16:07:12.727Z"
}
JSONペイロードの送信
上記のようなJSONペイロードは、STDIN
をコマンドにパイプすることで送信できます。
> echo '{"date_from":"2021-05-21T16:07:12.727Z","date_to":"2021-05-21T16:07:12.727Z"}' \
| motaword reports get-projects-report
より複雑なペイロードの場合は、まずファイルに保存してから、そのファイルをコマンドにパイプします。
> motaword reports get-projects-report < my-complex-payload.json
高度な使用法
翻訳の設定
motaword translate
コマンドを使用すると、高度に柔軟な設定でファイルの翻訳を行うことができます。以下は、translate
コマンドの設定項目です。
設定キー |
タイプ |
必須 |
デフォルト値 |
説明 |
project-id |
integer | string |
yes |
null |
MotaWordから提供される継続的なプロジェクトIDです。 |
source-directory |
string |
yes |
null |
motaword CLIがソースファイルを検索するためのベースディレクトリです。実際のソースファイルの検出はrules 設定で管理できます。すべてのルールはこのソースディレクトリを基準にします。 |
translations-directory |
string |
no |
source-directory /{locale} |
motaword CLIが翻訳済みファイルを配置するためのベースディレクトリです。翻訳済みファイルのパターンはrules 設定に基づきます。source-directory と同じにすることもできます。デフォルトでは、翻訳はsource-directory の下の各{locale} ディレクトリに配置されます。ただし、このデフォルト値は適切でない場合があります。 |
rules |
JSON Map {string: string} |
yes |
{ "**/*" : "{path}/{basename}" } |
glob 形式のファイルパスパターンのリストで、ソースファイルとその翻訳済みバージョンの配置方法を指定します。使用可能な変数、詳細な説明、および例については、以下を参照してください。 |
exclude-rules |
JSON Array [string] |
no |
[] |
glob 形式の除外ソースファイルパターンのリストです。翻訳中にこれらのファイルはスキップされます。 |
翻訳ルール
rules
設定は非常に柔軟で、さまざまなユースケースでの翻訳を可能にします。各ルールはglob
形式のパスパターンを使用してソースファイルを指定し、その翻訳済みバージョンの配置方法を指定します。
{
"source-directory": "src/en",
"translations-directory": "src/{locale}",
"rules": {
"**/*": "{path}/{basename}"
}
}
このルールは、src/en
ディレクトリ内のすべてのファイルをソースファイルとして取得し、その翻訳をsrc/{locale}
ディレクトリ内の同じパス構造に配置するようにmotaword
CLIに指示します。
より複雑な例を見てみましょう。
{
"source-directory": "src/main/resources/strings",
"translations-directory": "src/main/resources/translations",
"rules": {
"frontend/json/*.json": "{locale}/{path}/{basename}",
"frontend/**/*.yml": "{locale}/{path}/{filename}.yaml",
"pot/*.pot": "{locale}/{path}/{basename}",
"md/*.md": "markdown-translations/{locale}/{path}/{filename}.md"
},
"exclude-rules": [
"pot/passwords*"
]
}
このrules
設定は、以下のような操作を指示します。
src/main/resources/strings
をソースファイルのベースディレクトリとします。
src/main/resources/translations
を翻訳済みファイルのベースディレクトリとします。
src/main/resources/strings/frontend/json/
ディレクトリ内のすべての.json
ファイルを翻訳し、その翻訳をsrc/main/resources/translations/fr/frontend/json/
に配置します。
src/main/resources/strings/frontend/
ディレクトリ内のすべての.yml
ファイルを再帰的に翻訳し、その翻訳をsrc/main/resources/translations/fr/
の相対パスに配置します。
src/main/resources/strings/md/
ディレクトリ内のすべての.md
ファイルを翻訳し、その翻訳をsrc/main/resources/translations/fr/md/
に配置します。
- 最後に、
src/main/resources/strings/pot
ディレクトリ内のファイル名がpasswords
で始まるすべてのファイルを除外します。
ルールで使用可能な変数
変数 |
説明 |
例 |
{basename} |
ファイルの完全な名前(拡張子を含む) |
ソースディレクトリが./source-directory の場合、./source-directory/json-files/ui.json の{basename} はui.json です。 |
{filename} |
ファイル名(拡張子を除く)。この変数は、通常、翻訳済みファイルの拡張子を変更するために使用されます。 |
ソースディレクトリが./source-directory の場合、./source-directory/json-files/ui.json の{filename} はui です。 |
{path} |
ソースディレクトリからファイルまでのディレクトリパス。この変数は、ディレクトリ構造を変更するために最も有用です。 |
ソースディレクトリが./source-directory の場合、./source-directory/json-files/v1/public/ui.json の{path} はjson-files/v1/public です。 |
{locale} |
処理中の翻訳言語コード。この変数は、翻訳ディレクトリがターゲット言語ディレクトリに異なる要件を持つ場合に最も有用です。 |
en-US , fr , zh-CN など |
翻訳設定の例
このリポジトリの./examples
ディレクトリには、さまざまな設定例があります。
📚 ドキュメント
motaword
CLIの詳細なドキュメントについては、こちらを参照してください。
🔧 技術詳細
motaword
CLIアプリケーションは、.motaword/
ディレクトリを探して自身を設定します。設定を探す順序は以下の通りです。
- 作業ディレクトリ
$HOME/.motaword
/etc/.motaword
このディレクトリには、2つのファイルが保存されます。
- credentials.json
- config.json
credentials.json
には、MotaWord APIのクライアントIDとクライアントシークレットが保存されます。このファイルは、motaword
CLI自体を使用して生成できます。詳細については、以下の「認証」を参照してください。
config.json
を使用すると、motaword
CLIのあらゆる側面を設定できます。特に、開発やCI/CD環境で一般的に使用されるmotaword translate
コマンドに合わせて設定することができます。translate
コマンドの詳細については、上記の「翻訳」を参照してください。
translate
コマンドを使用しない限り、config.json
ファイルはオプションです。
🔧 デバッグ
すべてのmotaword
CLIコマンドには、デバッグフラグを指定できます。--help
を使用してフラグを確認してください。
以下の詳細表示フラグを使用して、出力レベルを設定できます。
フラグ |
説明 |
--v |
WARNレベルのログ |
--vv |
INFOレベルのログ |
--vvv または --verbose |
DEBUGレベルのログ |
config.json
設定ファイルのデバッグには、debug
コマンドも利用できます。
> motaword debug
これにより、検出されたソースファイルとそれに対応する翻訳パスが出力されます。
📄 ライセンス
READMEにライセンス情報は記載されていません。
📞 お問い合わせ
24時間年中無休の無料の技術またはビジネスのライブチャットサポートを提供しています。こちらからお問い合わせください。