[English Version](README.md)

# sd-webui-bilingual-localization
[Stable Diffusion web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui)のバイリンガル対応拡張機能

## 特徴
- バイリンガル対応により、元のボタンを探す必要がありません。
- 日本語化拡張機能と互換性があり、ファイルを取り込み直す必要はありません。
- ツールチップの動的翻訳をサポートします。
- スコープと正規表現パターンによる柔軟な翻訳が可能です。
## インストール
以下の方法から選択します。
拡張機能に対応したWebUI(2023年以降のバージョン)が必要です。
#### 方法1
WebUIの`Install from URL`でインストールを行います。
Extensions - Install from URLを順にクリックします。
1個目のテキストボックスに`https://github.com/journey-ad/sd-webui-bilingual-localization`を入力し、Installボタンをクリックします。

その後、Installedパネルに切り替え、Apply and restart UIボタンをクリックします。

#### 方法2
拡張機能のディレクトリに手動でcloneします。
```bash
git clone https://github.com/journey-ad/sd-webui-bilingual-localization extensions/sd-webui-bilingual-localization
```
## 使用方法
> **⚠️重要⚠️**
> Settings - User interface - Localizationが`None`に設定されていることを確認してください。
Settings - Bilingual Localizationパネルで、有効にしたい言語ファイル名を選択し、Apply settingsボタンとReload UIボタンを順にクリックします。

## スコープ
ローカライゼーションは、スコープ化されており、グローバルな影響を防止することができます。構文ルールは`####`です。
スコープを指定するIDが祖先要素のIDと一致する場合にのみ、スコープ化されたテキストが有効になります。
```json
...
"##tab_ti##Normal": "正常", // id="tab_ti"要素の下の`Normal`のみが`正常`として変換されます
"##tab_threedopenpose##Normal": "法線マップ", // id="tab_threedopenpose"要素の下の`Normal`のみが `法線マップ`として変換されます
...
```
## 正規表現パターン
正規表現を使った日本語化が可能です。構文ルールは`@@`、キャプチャグループは`$n`です。ドキュメント:[String.prototype.replace()](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replace)。
```json
{
...
"@@/^(\\d+) images in this directory, divided into (\\d+) pages$/": "このディレクトリには$1枚の画像、$2ページ",
"@@/^Favorites path from settings: (.*)$/": "お気に入りのディレクトリパス:$1",
...
}
```
## 日本語化ファイルの取得
内蔵の日本語化ファイルは提供されなくなりました。サードパーティーの日本語化拡張機能をインストールし、当ページの[使用方法](#使用方法)に記載されている方法でセットアップしてください。