> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/thymeleaf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/4-standard-expression-syntax/4.14-preprocessing.md).

# 4.14 预处理

除了所有这些表达式处理相关的特性，Thymeleaf还有预处理表达式的特性。

预处理指的是在通常的表达式之前处理表达式。这允许对最终执行的表达式进行修改。

预处理表达式和通常的表达式一样，但是被一双下划线包围（像`__${expression}__`）。

让我们想象一下：我们有一个国际化文件`Messages_fr.properties`，里面包含着一个OGNL表达式。这个表达式会调用一个指定语言的静态方法，就像：

```
article.text=@myapp.translator.Translator@translateToFrench({0})
```

同时还有一个`Messages_es.properties`文件：

```
article.text=@myapp.translator.Translator@translateToSpanish({0})
```

我们可以创建一段标记，根据地区信息对其中的一个表达式求值。为了达成目标，我们将首先选择表达式（使用预处理），然后让Thymeleaf执行它：

```markup
<p th:text="${__#{article.text('textVar')}__}">Some text here...</p>
```

注意：当地区信息是法国时，预处理将会创建如下的内容：

```markup
<p th:text="${@myapp.translator.Translator@translateToFrench(textVar)}">Some text here...</p>
```

预处理字符串`__`可以使用`\_\_`在属性里转义。
