> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ローカライズ

### Overleaf の i18n 設定

<Info>
  このドキュメントでは、セルフホストの **Overleaf** インスタンスで国際化（i18n）を設定する方法について説明します。
</Info>

Overleaf は複数の言語に翻訳されています。適切に設定することで、次のことが可能です。

* Overleaf インスタンスを**単一の固定言語**で運用する
* **複数の言語**を有効にし、`www.overleaf.com` と同様にユーザーが言語を動的に切り替えられるようにする

***

#### 単一言語の設定

サイトの言語は環境変数 `OVERLEAF_SITE_LANGUAGE`（Overleaf の **4.x 以前**のバージョンでは `SHARELATEX_SITE_LANGUAGE`）で設定します。

サポートされている言語コードは次のとおりです。

* `en` - 英語（デフォルト）
* `es` - スペイン語
* `pt` - ポルトガル語
* `de` - ドイツ語
* `fr` - フランス語
* `cs` - チェコ語
* `nl` - オランダ語
* `sv` - スウェーデン語
* `it` - イタリア語
* `tr` - トルコ語
* `zh-CN` - 中国語（簡体字）
* `no` - ノルウェー語
* `da` - デンマーク語
* `ru` - ロシア語
* `ko` - 韓国語
* `ja` - 日本語
* `pl` - ポーランド語
* `fi` - フィンランド語

デフォルトの言語は英語です。インターフェースの言語を変更するには（たとえば簡体字中国語に）、`config/variables.env` に次の行を追加します。

```bash title="config/variables.env" theme={null}
OVERLEAF_SITE_LANGUAGE=zh-CN
```

次に、設定を適用します。

```bash theme={null}
bin/up
```

サービスが再起動すると、Web UI のメニューのインターフェース言語に新しい設定が反映されます。

#### 複数言語の設定

ユーザーが**ログアウトせずに言語を切り替えられる**ようにするには、ドメイン名に応じて異なる言語を提供するよう Overleaf インスタンスを設定する必要があります。

このセクションでは、次のことを前提としています。

* プライマリドメインが `overleaftest.com` である
* **ワイルドカード TLS 証明書**（例：`*.overleaftest.com`）を持っている
* **`localhost` を使用していない**（サブドメインベースの言語ルーティングに対応できないため）

ローカルでテストする場合は、`dev-overleaf.com` などのドメインを使用できます。

<Steps>
  <Step title="TLS プロキシの設定（Nginx）">
    Overleaf がユーザーのアクセスした言語ドメインを判別できるように、TLS リバースプロキシは元の `Host` ヘッダーを転送する必要があります。

    次のディレクティブが含まれていることを確認してください。

    ```nginx theme={null}
    proxy_set_header Host $host;
    ```

    Nginx の設定例を次に示します。

    ```nginx theme={null}
    server {
        listen 443 ssl;
        server_name    _; # Catch all, see http://nginx.org/en/docs/http/server_names.html
        server_name *.overleaftest.com;
        ssl_certificate /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key /etc/nginx/ssl/nginx.key;
        ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers   on;
        # used cloudflares ciphers https://github.com/cloudflare/sslconfig/blob/master/conf
        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

        # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
        # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping	
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
        server_tokens off;
        add_header X-Frame-Options SAMEORIGIN;
        add_header X-Content-Type-Options nosniff;
        client_max_body_size 50M;

        location / {
            proxy_pass http://localhost:5000; # change to whatever host/port the docker container is listening on.
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 3m;
            proxy_send_timeout 3m;
            
            # add this to your nginx conf
            proxy_set_header Host $host;
        }
    }
    ```
  </Step>

  <Step title="Cookie ドメインを設定する">
    言語を切り替えたときにユーザーがログアウトされないようにするには、言語ごとのサブドメイン間で Cookie を共有する必要があります。

    `config/variables.env` に次の行を追加します。

    ```env title="config/variables.env" theme={null}
    # Note the leading dot
    COOKIE_DOMAIN=.overleaftest.com
    ```

    これにより、認証用 Cookie が `overleaftest.com` 配下のすべてのサブドメインで有効になります。
  </Step>

  <Step title="言語とドメインのマッピング">
    次に、`OVERLEAF_LANG_DOMAIN_MAPPING` を使用して、言語コードとサブドメインの対応を定義します。

    #### 設定例

    ```dotenv title="config/variables.env" wrap theme={null}
    OVERLEAF_LANG_DOMAIN_MAPPING='{"www": {"lngCode": "en","url": "https:\/\/www.overleaftest.com"},"cn": {"lngCode": "zh-CN","url": "https:\/\/cn.overleaftest.com"}}'
    ```

    この設定では次のようになります。

    * `https://www.overleaftest.com` → 英語のインターフェース
    * `https://cn.overleaftest.com` → 簡体字中国語のインターフェース

    必要に応じて、このマッピングに言語とサブドメインを追加できます。
  </Step>

  <Step title="Apex ドメインをリダイレクトする">
    最後に、Apex ドメイン（`overleaftest.com`）をデフォルト言語のドメイン（`www.overleaftest.com`）にリダイレクトします。

    ```nginx theme={null}
    server{
        listen 80;
        server_name overleaftest.com;
        return 301 https://www.overleaftest.com$request_uri;
    }

    server {
        listen 443 ssl http2;
        server_name overleaftest.com;
        ssl_certificate     /path/to/fullchain.cer;
        ssl_certificate_key /path/to/overleaftest.com.key;
        return 301 https://www.overleaftest.com$request_uri;
    }
    ```
  </Step>
</Steps>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.