Markdown
Lingo.dev CLIによるMarkdownファイルのAI翻訳
Markdownとは?
Markdownは、プレーンテキストの書式構文を使用して構造化されたドキュメントを作成する軽量マークアップ言語です。ドキュメント、READMEファイル、ブログ、コンテンツ管理システムで広く使用されています。
例:
---
title: "Product Launch Guide"
description: "Everything you need to know about our latest product features"
author: "Product Team"
---
# Welcome to Our New Dashboard
Discover powerful new features designed to streamline your workflow and boost productivity.
## Getting Started
Follow these simple steps to set up your account and begin using our platform effectively.

Lingo.dev CLIとは?
Lingo.dev CLIは、AIを使用してアプリやコンテンツを翻訳するための無料のオープンソースCLIです。従来の翻訳管理ソフトウェアを置き換えながら、既存のパイプラインと統合できるように設計されています。
詳細については、概要を参照してください。
このガイドについて
このガイドでは、Lingo.dev CLIを使用してMarkdownファイルを翻訳する方法を説明します。
以下の方法を学習します:
- ゼロからプロジェクトを作成する
- 翻訳パイプラインを設定する
- AIで翻訳を生成する
前提条件
Lingo.dev CLIを使用するには、Node.js v18以降がインストールされていることを確認してください:
❯ node -v
v22.17.0
ステップ 1. プロジェクトをセットアップする
プロジェクトのディレクトリに、i18n.jsonファイルを作成します:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
このファイルは、翻訳する言語やファイルシステム上のローカライズ可能なコンテンツの場所など、翻訳パイプラインの動作を定義します。
使用可能なプロパティの詳細については、i18n.jsonを参照してください。
ステップ 2. ソースロケールを設定する
_ソースロケール_は、コンテンツが記述された元の言語と地域です。ソースロケールを設定するには、i18n.jsonファイルのlocale.sourceプロパティを設定します:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
ソースロケールは、BCP 47言語タグとして指定する必要があります。
Lingo.dev CLIがサポートするロケールコードの完全なリストについては、サポートされているロケールコードを参照してください。
ステップ 3. ターゲットロケールを設定する
_ターゲットロケール_は、コンテンツを翻訳したい言語と地域です。ターゲットロケールを設定するには、i18n.jsonファイルのlocale.targetsプロパティを設定します:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
ステップ 4. ソースコンテンツを作成する
まだ作成していない場合は、翻訳するコンテンツを含む1つ以上のMarkdownファイルを作成します。これらのファイルは、パスのどこかにソースロケールを含むパスに配置する必要があります(例:en/のようなディレクトリ名、またはmessages.en.mdのようなファイル名の一部として)。
ステップ 5. バケットを作成する
-
i18n.jsonファイルで、bucketsオブジェクトに"markdown"オブジェクトを追加します:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "markdown": {} } } -
"markdown"オブジェクトで、1つ以上のincludeパターンの配列を定義します:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "markdown": { "include": ["./[locale]/example.md"] } } }これらのパターンは、翻訳するファイルを定義します。
パターン自体は:
- 設定されたロケールのプレースホルダーとして
[locale]を含む必要があります - ファイルパスを指定できます(例:
"[locale]/docs.md") - ワイルドカードプレースホルダーとしてアスタリスクを使用できます(例:
"[locale]/*.md")
再帰的なglobパターン(例:
**/*.md)はサポートされていません。 - 設定されたロケールのプレースホルダーとして
ステップ 6. LLMを設定する
Lingo.dev CLIは、大規模言語モデル(LLM)を使用してAIでコンテンツを翻訳します。これらのモデルのいずれかを使用するには、サポートされているプロバイダーからAPIキーが必要です。
できるだけ早く使い始めるために、Lingo.dev Engineの使用をお勧めします。これは、毎月10,000トークンの無料利用を提供する当社独自のホスト型プラットフォームです:
-
次のコマンドを実行します:
npx lingo.dev@latest loginデフォルトのブラウザが開き、認証を求められます。
-
プロンプトに従ってください。
ステップ7. 翻訳を生成する
i18n.jsonファイルが含まれるディレクトリで、次のコマンドを実行します:
npx lingo.dev@latest run
このコマンドは:
i18n.jsonファイルを読み込みます。- 翻訳が必要なファイルを検索します。
- ファイルから翻訳可能なコンテンツを抽出します。
- 設定されたLLMを使用して抽出されたコンテンツを翻訳します。
- 翻訳されたコンテンツをファイルシステムに書き戻します。
翻訳が初めて生成されるとき、i18n.lockファイルが作成されます。このファイルは、どのコンテンツが翻訳されたかを追跡し、後続の実行で不要な再翻訳を防ぎます。
例
en/example.md
---
title: "Product Launch Guide"
description: "Everything you need to know about our latest product features"
author: "Product Team"
date: 2024-01-15
tags: ["apples", "bananas", "pears"]
---
# Welcome to Our New Dashboard
Discover powerful new features designed to streamline your workflow and boost productivity.
## Getting Started
Follow these simple steps to set up your account and begin using our platform effectively.
---
Our advanced analytics help you make data-driven decisions with confidence.

The intuitive interface makes it easy to navigate between different features and tools.
[View documentation](https://example.com)
Need help getting started? Our support team is available 24/7 to assist you.
***
Join thousands of satisfied customers who have transformed their business with our platform.
es/example.md
---
title: Guía de lanzamiento de producto
description: Todo lo que necesitas saber sobre las últimas características de
nuestro producto
author: Equipo de producto
date: 2024-01-15
tags:
- apples
- bananas
- pears
---
# Bienvenido a nuestro nuevo panel de control
Descubre nuevas y potentes funciones diseñadas para optimizar tus flujos de trabajo y aumentar la productividad.
## Primeros pasos
Sigue estos sencillos pasos para configurar tu cuenta y comenzar a utilizar nuestra plataforma de manera efectiva.
---
Nuestros análisis avanzados te ayudan a tomar decisiones basadas en datos con confianza.

La interfaz intuitiva facilita la navegación entre diferentes funciones y herramientas.
[Ver documentación](https://example.com)
¿Necesitas ayuda para empezar? Nuestro equipo de soporte está disponible 24/7 para asistirte.
---
Únete a miles de clientes satisfechos que han transformado su negocio con nuestra plataforma.
i18n.json
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {
"markdown": {
"include": ["./[locale]/example.md"]
}
}
}
i18n.lock
version: 1
checksums:
eed9ef23a605b747d38b8916cee1d500:
md-section-0: d53f61b8c8922fb62d9df5678d9b44a8
md-section-1: 98aec271471bedce0e12b530c7060827
md-section-2: 9e5a786192608844493dfbb6e4100886
md-section-3: 1a5299c38bb20c1b8af0e64e33d7b2b0
md-section-4: 51adf33450cab2ef392e93147386647c
md-section-5: e56cc804e3e06b5f5fb2484e88c18adc
md-section-6: 0ea86a3338305070c865e8fe138da890
md-section-7: bbabf7f391569a72099001e3d81eb251
md-section-8: 36cbfd93f42528edce4faac2ac3c2c12
md-section-9: a1c50054ab23d70be8d453789b214580
md-section-10: 51adf33450cab2ef392e93147386647c
md-section-11: cb596c9608828f7b87a0ab8fa37beb07
fm-attr-title: f3469c4e3d3377c39a705c844930b3a5
fm-attr-description: 2e988d98001e44997a3f5fa3fb487ca6
fm-attr-author: ec8c8711fce61265a4fe296ce2ba3b6f
fm-attr-tags: 313ac6f17ee08e4f4a6a2ca95e5ae024