> ## Documentation Index
> Fetch the complete documentation index at: https://foliant-help.iforiti.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 日期、語言與翻譯

> 在 Liquid 中設定日期格式，以商店語言、顧客語言或固定語言列印文件，並翻譯用語和文字區塊。

每個範本都有一個**文件語言**。它決定日期中月份和星期名稱的語言，以及 Foliant 列印的用語，例如「Invoice」、「Subtotal」或「Ship to」。您可以用商店的語言、每位顧客的語言，或一律使用同一種語言列印文件。

## 選擇文件的語言

在編輯器的頂列（或範本的設定頁面）中，選擇**文件語言**：

| 選項 | 作用 |
| - | - |
| **商店語言（預設）** | 文件以您商店的語言列印。 |
| **顧客的語言** | 每份文件都以顧客購物時使用的語言列印。 |
| 某一種語言，例如**德文**或**法文** | 文件一律以該語言列印。 |

預覽會立即套用所選語言。選擇**顧客的語言**時，預覽會使用預覽訂單的語言。阿拉伯文、希伯來文、波斯文和烏爾都文的文件會由右至左列印。

如果 Foliant 沒有文件語言的用語，會改用您商店的語言，再來是英文。沒有翻譯的單一字詞會以英文列印。

## 設定日期格式

`created_at` 等日期會以原始格式列印。請使用 `date` 篩選器設定格式：

```liquid theme={null}
{{ created_at | date: '%d %B %Y' }}     → 15 January 2026
{{ created_at | date: '%b %-d, %Y' }}   → Jan 15, 2026
{{ created_at | date: '%d/%m/%Y' }}     → 15/01/2026
```

| 代碼 | 列印內容 |
| - | - |
| `%d` / `%-d` / `%e` | 日期（當月第幾天）：`05` / `5` / 前面加空格的 `5` |
| `%m` / `%-m` | 月份數字：`01` / `1` |
| `%B` / `%b` | 月份名稱：`January` / `Jan` |
| `%A` / `%a` | 星期名稱：`Monday` / `Mon` |
| `%Y` / `%y` | 年份：`2026` / `26` |
| `%H:%M` | 時間，24 小時制：`14:30` |
| `%I:%M %p` | 時間，12 小時制：`02:30 PM` |
| `%j` | 一年中的第幾天 |
| `%z` | 時區偏移 |

月份和星期名稱會使用文件語言：在德文文件中，`%B` 會列印「Januar」。若要以其他語言列印，請在格式後面加上該語言，例如顧客的語言：`{{ created_at | date: '%A %d %B', customer_locale }}`。

時間採用您商店的時區。`{{ 'now' | date: '%d %B %Y' }}` 會列印今天的日期。

## 在程式碼範本中翻譯用語

使用 `t` 篩選器（也稱為 `translate` 或 `label`），以文件語言列印 Foliant 的用語：

```liquid theme={null}
{{ 'subtotal' | t }}        → Subtotal / Zwischensumme / Sous-total…
{{ 'titles.invoice' | t }}  → Invoice / Rechnung / Facture…
{{ 'subtotal' | t: locale: 'en' }}   → always English
```

Shopify Order Printer 的用語鍵也能使用，因此匯入的範本會保留原有的翻譯。

### 列印兩種語言

在編輯器的頂列選擇**第二語言**，然後在需要同時顯示兩種語言的地方使用 `t_both`：

```liquid theme={null}
{{ 'titles.invoice' | t_both }}         → Rechnung / Invoice
{{ 'titles.invoice' | t_both: '<br>' }} → the two on separate lines
```

沒有第二語言，或兩種語言的文字相同時，`t_both` 只會列印一個。

## 在視覺化範本中翻譯文字

區塊會以文件語言列印各自的用語。至於您自行撰寫的文字（含自訂文字的**文字**和**法律資訊頁尾**區塊，以及**頁首**的自訂文字行）：

1. 選取區塊，然後開啟**內容**。
2. 在**語言**中選擇一種語言。已有翻譯的語言會顯示「(translated)」。
3. 輸入該語言的文字。

文件為該語言時，會列印翻譯。否則會列印**預設**文字。

## 須知事項

* 頂列的**數字格式**決定金額和數字要依照文件語言（`1.234,56 €`），還是您商店的格式。請參閱[範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)。
* `{{ customer_locale }}` 會列印顧客的語言代碼，例如 `de` 或 `fr-CA`。
* 用於所有選取訂單的範本無法使用**顧客的語言**：一個批次中有許多顧客。
* **自動選擇合適的範本**中的**以顧客的語言列印**，可一次為多個範本開啟**顧客的語言**。請參閱[自動選擇合適的範本](https://foliant-help.iforiti.com/zh-Hant/templates/automatic-template-choices.md)。

## 相關文章

* [預覽、紙張大小與縮放](https://foliant-help.iforiti.com/zh-Hant/template-editor/preview-paper-and-zoom.md)
* [範本中的金額與幣別](https://foliant-help.iforiti.com/zh-Hant/template-editor/liquid-money-and-currency.md)
* [區塊參考](https://foliant-help.iforiti.com/zh-Hant/template-editor/block-catalogue.md)
* [以顧客的語言列印](https://foliant-help.iforiti.com/zh-Hant/templates/print-in-customers-language.md)


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