> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/on-premises/vi/cau-hinh/overleaf-toolkit/localization.md).

# Bản địa hóa

### Cấu hình i18n của Overleaf

{% hint style="info" %}
Tài liệu này mô tả cách cấu hình quốc tế hóa (i18n) cho một bản tự lưu trữ **Overleaf** phiên bản.
{% endhint %}

Overleaf đã được dịch sang nhiều ngôn ngữ. Với cấu hình phù hợp, bạn có thể:

* Chạy phiên bản Overleaf của bạn bằng **một ngôn ngữ cố định**, hoặc
* Bật **đa ngôn ngữ**, cho phép người dùng chuyển đổi ngôn ngữ linh hoạt, tương tự như `www.overleaf.com`.

***

#### Cấu hình một ngôn ngữ

Ngôn ngữ của trang web được cấu hình bằng biến môi trường `OVERLEAF_SITE_LANGUAGE`(hoặc `SHARELATEX_SITE_LANGUAGE` cho các phiên bản Overleaf **4.x trở xuống**).

Các mã ngôn ngữ được hỗ trợ gồm:

* `en` - Tiếng Anh (mặc định)
* `es` - Tiếng Tây Ban Nha
* `pt` - Tiếng Bồ Đào Nha
* `de` - Tiếng Đức
* `fr` - Tiếng Pháp
* `cs` - Tiếng Séc
* `nl` - Tiếng Hà Lan
* `sv` - Tiếng Thụy Điển
* `it` - Tiếng Ý
* `tr` - Tiếng Thổ Nhĩ Kỳ
* `zh-CN` - Tiếng Trung (giản thể)
* `no` - Tiếng Na Uy
* `da` - Tiếng Đan Mạch
* `ru` - Tiếng Nga
* `ko` - Tiếng Hàn
* `ja` - Tiếng Nhật
* `pl` - Tiếng Ba Lan
* `fi` - Tiếng Phần Lan

Tiếng Anh là ngôn ngữ mặc định. Để thay đổi ngôn ngữ giao diện (ví dụ, sang tiếng Trung giản thể), hãy thêm dòng sau vào `config/variables.env`:

{% code title="config/variables.env" %}

```bash
OVERLEAF_SITE_LANGUAGE=zh-CN
```

{% endcode %}

Sau đó áp dụng cấu hình:

```bash
bin/up
```

Sau khi các dịch vụ khởi động lại, ngôn ngữ giao diện trong các menu của web UI sẽ phản ánh thiết lập mới.

#### Cấu hình đa ngôn ngữ

Để cho phép người dùng **chuyển đổi ngôn ngữ mà không cần đăng xuất**, phiên bản Overleaf của bạn phải được cấu hình để phục vụ các ngôn ngữ khác nhau dựa trên tên miền.

Phần này giả định:

* Tên miền chính của bạn là `overleaftest.com`
* Bạn có một **chứng chỉ TLS wildcard** (ví dụ `*.overleaftest.com`)
* Bạn **không sử dụng `localhost`** (vì nó không thể hỗ trợ định tuyến ngôn ngữ dựa trên subdomain)

Để thử nghiệm cục bộ, bạn có thể dùng một tên miền như `dev-overleaf.com`.

{% stepper %}
{% step %}

### Cấu hình proxy TLS (Nginx)

Proxy ngược TLS của bạn phải chuyển tiếp `Host` header gốc để Overleaf có thể xác định người dùng đã truy cập miền ngôn ngữ nào.

Hãy đảm bảo rằng chỉ thị sau có mặt:&#x20;

```nginx
proxy_set_header Host $host;
```

Dưới đây là một ví dụ cấu hình Nginx:&#x20;

<pre class="language-nginx"><code class="lang-nginx">server {
    listen 443 ssl;
    server_name    _; # bắt tất cả, xem 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;
    # dùng bộ mã hóa của Cloudflare 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;

    # cấu hình để bật HSTS (HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
    # để tránh 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; # thay đổi thành host/cổng mà container docker đang lắng nghe.
        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;
        
        # thêm dòng này vào cấu hình nginx của bạn
<strong>        proxy_set_header Host $host;
</strong>    }
}
</code></pre>

{% endstep %}

{% step %}

### Cấu hình miền cookie

Để ngăn người dùng bị đăng xuất khi chuyển đổi ngôn ngữ, cookie phải được chia sẻ giữa các subdomain ngôn ngữ.

Thêm dòng sau vào `config/variables.env`:

{% code title="config/variables.env" %}

```env
# lưu ý dấu chấm ở đầu
COOKIE_DOMAIN=.overleaftest.com
```

{% endcode %}

Điều này đảm bảo rằng cookie xác thực có hiệu lực cho tất cả các subdomain dưới `overleaftest.com`.
{% endstep %}

{% step %}

### Ánh xạ ngôn ngữ–miền

Tiếp theo, xác định cách các mã ngôn ngữ ánh xạ sang subdomain bằng\
`OVERLEAF_LANG_DOMAIN_MAPPING`.

#### Cấu hình ví dụ

{% code title="config/variables.env" overflow="wrap" %}

```dotenv
OVERLEAF_LANG_DOMAIN_MAPPING='{"www": {"lngCode": "en","url": "https:\/\/www.overleaftest.com"},"cn": {"lngCode": "zh-CN","url": "https:\/\/cn.overleaftest.com"}}'
```

{% endcode %}

Với cấu hình này:

* `https://www.overleaftest.com` → giao diện tiếng Anh
* `https://cn.overleaftest.com` → giao diện tiếng Trung giản thể

Bạn có thể mở rộng ánh xạ này với các ngôn ngữ và subdomain bổ sung tùy nhu cầu.
{% endstep %}

{% step %}

### Chuyển hướng miền gốc

Cuối cùng, chuyển hướng miền gốc (`overleaftest.com`) đến miền ngôn ngữ mặc định (`www.overleaftest.com`).

<pre class="language-nginx"><code class="lang-nginx">server{
    listen 80;
    server_name overleaftest.com;
<strong>    return 301 https://www.overleaftest.com$request_uri;
</strong>}

server {
    listen 443 ssl http2;
    server_name overleaftest.com;
    ssl_certificate     /<a data-footnote-ref href="#user-content-fn-1">p</a>ath/to/fullchain.cer;
    ssl_certificate_key /path/to/overleaftest.com.key;
<strong>    return 301 https://www.overleaftest.com$request_uri;
</strong>}
</code></pre>

{% endstep %}
{% endstepper %}

[^1]:


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/on-premises/vi/cau-hinh/overleaf-toolkit/localization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
