书写系统/语法
zh:Help:高级字词转换语法
此页面是一个软重定向。
This page describes special markups found in LanguageConverter, a system which converts between language variants via means of character/word replacement. In all examples below, characters in lowercase are used to represent Simplified Chinese, and UPPERCASE ones represent Traditional Chinese.
概念
LanguageConverter markups looks like:
-{ text }-
-{ flag | variant1 : text1 ; variant2 : text2 ; }-
-{ flag1 ; flag2 | from => variant : to ; }-
Where flags are described below, and variant names are language codes (like zh-cn
or zh-tw
).
Fallback among variants is available.
In the following examples designed for Chinese, zh-cn
and zh-sg
are variants written in the zh-hans
script, while zh-hk
, zh-mo
are variants written in the zh-hant
script.
For example, according to the $variantfallbacks
definition in LanguageZh.php
, if no rules for zh-hk
were found, the converter would try using definitions for zh-hant
, zh-mo
, and zh-tw
.
In this example you may notice that zh-mo
and zh-sg
are absent from most examples.
This is due to their high similarity to other variants, zh-hk
and zh-cn
respectively.
语法
基本语法
称谓 | 功能 | 示例 | 备注 | |
---|---|---|---|---|
源码 | 输出结果 | |||
双向转换 | 实现双向转换,可带有转换标签, 为手动转换语法中最常用的功能 |
computer |
|
|
单向转换 | 实现单向转换,可带有转换标签, 主要用于新增全文转换规则,比双向转换效率高
Mainly useful for unifying language variance and preventing erratic conversion. |
Test: HUGEBLOCK, macro |
|
单向转换不带继承特性, 如左例中“zh-hans ”和“zh-sg ”并未使用zh-cn 的用词。 使用zh-hans 亦只会应用到“zh-hans ”而不会应用“zh-cn ”。
|
禁止字词转换 | 同时禁止繁简和地区词的转换 |
SimpTrad
<!--Alternatively, with the "R" flag: SimpTrad-->
|
|
这种写法将完全禁止字词转换,在某些场合(如只需禁止地区词转换)或不适用 |
禁止地区词转换 | 禁止被切断的地区词转换,但允许個別字之繁简转换 (breaking words apart, won't affect character transcription) Useful for stopping erratic conversion by splitting words correctly. |
HANGUK, chosun (假定系统转换表中有“ |
hanguk, chosun
|
还有另一种组合转换标签的方式也可以实现同样的功能,并且便于在模板中使用, 详见后文 例如: HANGUK chosun
|
转换标签
常用标签
标签 | 功能 | 示例 | 备注 | |
---|---|---|---|---|
源码 | 输出结果 | |||
H | 添加全文转换规则,并隐藏H转换文本 |
Test: blog, WEBJOURNAL, WEBLOG |
|
zh-hans and zh-hant are simply scripts and won't apply bidirectional rules. See also the $manualLevel parameter in LanguageConverter.
|
A | 添加全文转换规则,并输出A转换解析文本 |
blog → blog, WEBJOURNAL, WEBLOG |
|
注意和H转换对比结果 |
- | 移除全文转换规则 |
<!-- Add rule --> + blog, WEBJOURNAL, WEBLOG <!-- Remove rule --> - blog, WEBJOURNAL, WEBLOG |
|
Compare test (+), test (-), and basic hans/hant |
T | 强制覆盖页面原有标题 |
(假定页面原始标题为“TomHanks”) |
(显示在页面标题处)
|
|
D | 描述转换规则 |
大陆:tom hanks;香港:SOUP HANS;臺灣:TOM HANKS; |
|
Good for generating overviews in public conversion rule-groups. |
组合转换标签
标签 | 功能 | 示例 | 备注 | |
---|---|---|---|---|
源码 | 输出结果 | |||
zh
zh-hans zh-hant zh-cn zh-hk zh-sg zh-tw |
限制要顯示的語言的有效範圍。 |
Test 1: blog, WEBJOURNAL, WEBLOG Test 2: blog, WEBJOURNAL, WEBLOG (假定这是在中文维基中运行的) |
|
除了测试1和测试2之間有差異外,跟上方使用 H 標籤作转换的例子之間也有差異 |
不转换的内容
自动转换程序会自动规避“程序码”类的标签,包括<pre>...</pre>
、<code>...</code>
和用于直接执行JavaScript的<script>...</script>
三种。
如果要将前两种用于条目内的程序范例,可以使用空转换标签-{}-
强制启用转换。
This hack can be useful for code samples nested in these tags.
A caveat, however, is that this switch doesn't seem to work for the extension-provided <syntaxhighlight>
tags which eventually generates a <pre>...</pre>
nested with elements (T34943).
The switch also won't work with scripts not originally included with the page's HTML source that LC is designed to operate on.
MediaWiki messages are not processed by LC. This inconvenience is tracked in T170916.
参见
- Help:魔术字 - for switches related to the converter
- Parsoid/Language conversion - which collects additional documentation relating to Language Conversion