i18next を使った国際化(i18n)対応を追加し、CLI のメッセージを日本語・英語の両方で表示できるようにしました。#39
Open
D-ske104 wants to merge 5 commits into
Open
i18next を使った国際化(i18n)対応を追加し、CLI のメッセージを日本語・英語の両方で表示できるようにしました。#39D-ske104 wants to merge 5 commits into
D-ske104 wants to merge 5 commits into
Conversation
…tion Add multi-language support using i18next. Default language is English, switching to Japanese when terminal locale (LC_ALL/LC_MESSAGES/LANG) starts with "ja". All hardcoded strings in commands, utilities, and Markdown output are now translated via translation keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hardcoded Japanese labels added in upstream merge with i18n t() calls Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
開発第一言語がjaのため、jaロケールファイルには必ず全キーが存在する前提で i18nextのfallbackLngをjaに設定。一方、環境変数からロケールを検出できない 場合はenにフォールバックし、日本語話者以外には英語を表示する。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@ShuntaToda
概要
i18next を使った国際化(i18n)対応を追加し、CLI のメッセージを日本語・英語の両方で表示できるようにしました。
モチベーション
backlog-exporter は Backlog のデータをMarkdownとしてエクスポートできる非常に便利なツールですが、現状ではすべてのCLIメッセージ・説明文・ラベルが日本語にハードコードされています。
Backlog は海外のチームでも利用されているケースがあり、このツールを日本語話者以外にも薦めたいと考えました。しかし、CLIの出力がすべて日本語では英語話者にとって使いづらいため、国際化対応が必要だと感じています。
既存の Issue はありませんが、ツールの利用者層を広げることでプロジェクトの価値がさらに高まると考え、今回 PR を作成しました。方針や実装について気になる点があれば、お気軽にフィードバックいただけると幸いです。
主な変更点
新規ファイル
src/utils/i18n.ts— i18next の初期化・ロケール検出ロジックsrc/locales/ja.json/src/locales/en.json— 日本語・英語の翻訳リソースsrc/i18next.d.ts— 翻訳キーの型安全性を担保する型定義src/locales/README.md— 新しい言語を追加する際の手順ガイド.vscode/settings.json— エディタで表示言語を容易に確認できるようにするため i18n-ally のインストールを推奨するようにしています既存ファイルの変更
all,issue,wiki,document,update)およびユーティリティファイルで、ハードコードされた日本語文字列をt()翻訳関数に置き換えロケール検出の仕組み
LC_ALL→LC_MESSAGES→LANGの順に参照し、ユーザーのロケールを自動検出en)にフォールバックja)に設定し、翻訳キーが未定義の場合でも既存の日本語メッセージが表示されるようにしています依存関係
i18nextを追加設計上の判断
LANG=ja_JP.*)では従来と同じ日本語メッセージが表示されるため、既存ユーザーへの影響はありませんsrc/locales/に JSON ファイルを追加するだけで新しい言語をサポートできますテスト計画
LANG=en_US.UTF-8で実行し、英語で出力されることを確認LANG=ja_JP.UTF-8で実行し、日本語で出力されることを確認