markdown 占位符t()函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 占位符t()函数相关的知识,希望对你有一定的参考价值。

# Make Strings Translatable
## Placeholders
### @variable
   
Use this style of placeholder for most use-cases. Special characters in the text will be converted to HTML entities.
```
t('Hello @name, welcome back!', array('@name' => $user->getDisplayName()));
```
Output example:
```
Hello Dries, welcome back!
```
### %variable

Use this style of placeholder to pass text through drupal_placeholder() which will result in the text being HTML escaped, and then wrapped with `<em>` tags.
```
t('The file was saved to %path.', array('%path' => $path_to_file));
```
Output example:
```
The file was saved to <em class="placeholder">sites/default/files/myfile.txt</em>.
```
### :variable

Use this style of placeholder when substituting the value of an href attribute. Values will be HTML escaped and filtered for dangerous protocols.
```
t('Hello <a href=":url">@name</a>', array(':url' => 'http://example.com', '@name' => $name));
```
Output example:
```
Hello <a href="http://example.com">Dries</a>
```

以上是关于markdown 占位符t()函数的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Rails 3 的占位符中使用 <br />?

如何在 T-SQL 查询中针对连接到 SAP-HANA 的链接服务器使用“占位符”?

Scala 基础—— 占位符_和部分应用函数

占位符 Internet Explorer 11 未显示

Kotlin泛型 ① ( 泛型类 | 泛型参数 | 泛型函数 | 多泛型参数 | 泛型类型约束 )

占位符的使用