> ## 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/cn/template-editor/liquid-money-and-currency.md)。
* `{{ customer_locale }}` 打印客户的语言代码，例如 `de` 或 `fr-CA`。
* 用于所有选定订单的模板无法使用**客户语言**：一个批次包含多位客户。
* **自动选择合适的模板**下的**以客户语言打印**会同时为多个模板开启**客户语言**。请参阅[自动选择合适的模板](https://foliant-help.iforiti.com/cn/templates/automatic-template-choices.md)。

## 相关文章

* [预览、纸张尺寸和缩放](https://foliant-help.iforiti.com/cn/template-editor/preview-paper-and-zoom.md)
* [模板中的金额和货币](https://foliant-help.iforiti.com/cn/template-editor/liquid-money-and-currency.md)
* [区块参考](https://foliant-help.iforiti.com/cn/template-editor/block-catalogue.md)
* [以客户的语言打印](https://foliant-help.iforiti.com/cn/templates/print-in-customers-language.md)


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