Template:LC zh/zh
![]() | 使用Lua |
描述
此模板用於處理中文(「zh」)頁面標題及內容的字詞轉換(language conversion,「LC」),特別是在包含/去除命名空間名稱(「nsp」參數)的頁面標題、會同時用於含字詞轉換/不含字詞轉換頁面的內容。
用法
- 内容類型
- T:頁面標題
- 僅用於主命名空間:
{{LC zh|T|zh-hans=<zh-Hans(中文,简化汉字)页面名称>|zh-hant=<zh-Hant(中文,傳統漢字)頁面名稱>}}
{{LC zh|T|nsp={{{nsp|}}}|<英語命名空間名稱>|zh-hans=<zh-Hans(中文,简化汉字)页面名称>|zh-hant=<zh-Hant(中文,傳統漢字)頁面名稱>}}
{{LC zh|T|nsp={{{nsp|}}}|<英語命名空間名稱>|zh-hans=<zh-Hans(中文,简化汉字)页面名称>|zh-hant=<zh-Hant(中文,傳統漢字)頁面名稱>|zh-hk=<zh-Hant-HK(中文,傳統漢字,香港用詞)頁面名稱>}}
- 示例:
{{LC zh|T|nsp={{{nsp|}}}|Project|zh-hans=关于|zh-hant=關於}}
- 僅用於主命名空間:
- C:內容
{{LC zh|C|zh-hans=<zh-Hans(中文,简化汉字)內容>|zh-hant=<zh-Hant(中文,傳統漢字)內容>}}
{{LC zh|C|zh-hans=<zh-Hans(中文,简化汉字)內容>|zh-hant=<zh-Hant(zh-Hant-TW,中文,傳統漢字,臺灣用詞)內容>|zh-hk=<zh-Hant-HK(中文,傳統漢字,香港用詞)內容>}}
- 示例:
{{LC zh|C|zh-hans=关于|zh-hant=關於}}
- T:頁面標題
整合其他模板及模組
备注
如果模板是用户页模板、全域公告等,无法使用字词转换器转换,则应考虑使用Template:Conversion-zh 而不是此模板。
模板数据
Language conversion template for Chinese script.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Language Variant | variant | The fixed language variant to output. (e.g. `zh-hans`, `zh-hant`, etc.) | String | optional |
Content type | 1 | The content type, values:\n* "N" - Namespace Name\n* "T" - Full Page Title\n* "H" - Heading\n* "C" - Text Content\n\n;Aliases\n:"type"
| String | required |
Hide Namespace Prefix? | 2 | (type=N, T) Whether to hide the namespace prefix (value is passed to [[Template:Localized link]] as the "nsp" parameter).\n\n;Aliases\n:"hide_ns"\n:"nsp"
| Boolean | optional |
English Canonical Namespace Name | 3 | (type=N, T) The canonical name of the namespace in English.\n\n;Aliases\n:"ns"\n:"namespace"
| String | optional |
2nd English Canonical Namespace Name | ns_2 | (type=N, T) The canonical name of the secondary pseudo-namespace in English, used for example in Help:Extension:Example
| String | optional |
English Page Name | 4 | (type=T) The canonical name of the page in English without the namespace prefix (like the PAGENAME variable).
| String | optional |
Chinese | zh | The text content in Chinese script.
| Content | optional |
Simplified Chinese | zh-hans | The text content in simplified Chinese script.
| Content | suggested |
Traditional Chinese | zh-hant | The text content in traditional Chinese script.
| Content | suggested |
Chinese (China) | zh-cn | The text content in simplified Chinese script.
| Content | optional |
Chinese (Hong Kong) | zh-hk | The text content in traditional Chinese script used in Hong Kong.
| Content | optional |
Chinese (Macau) | zh-mo | The text content in traditional Chinese script used in Macau.
| Content | optional |
Chinese (Malaysia) | zh-my | The text content in simplified Chinese script.
| Content | optional |
Chinese (Singapore) | zh-sg | The text content in simplified Chinese script.
| Content | optional |
Chinese (Taiwan) | zh-tw | The text content in traditional Chinese script.
| Content | optional |
测试用例
4 tests failed.
test_main:
Text | Expected | Actual | |
---|---|---|---|
![]() |
{{#invoke:LC zh|main}} | An error | Caught expected error: Lua error in Module:LC_zh at line 482: Unknown or missing content type code: nil. |
![]() |
{{#invoke:LC zh|main|type=N}} | ||
![]() |
{{#invoke:LC zh|main|type=N|ns=User}} | User | User |
![]() |
{{#invoke:LC zh|main|type=N|ns=Help}} | Help | Help |
![]() |
{{#invoke:LC zh|main|type=T}} | ||
![]() |
{{#invoke:LC zh|main|type=T|ns=User}} | User: | User: |
![]() |
{{#invoke:LC zh|main|type=T|ns=Help}} | Help: | Help: |
![]() |
{{#invoke:LC zh|main|type=T|ns=User|zh=Example}} | User:Example | User:Example |
![]() |
{{#invoke:LC zh|main|type=T|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} | Help:Example | Help:Example |
![]() |
{{#invoke:LC zh|main|type=T|hide_ns=1|ns=Help}} | ||
![]() |
{{#invoke:LC zh|main|type=T|hide_ns=1|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} | Example | Example |
![]() |
{{#invoke:LC zh|main|type=H}} | An error | |
![]() |
{{#invoke:LC zh|main|type=C}} | An error | |
![]() |
{{#invoke:LC zh|main|type=C|zh=Example|zh-hans=示例|zh-hant=範例}} | Example | Example |
test_template:
Text | Expected | Actual | |
---|---|---|---|
![]() |
{{LC zh}} | An error | Caught expected error: Lua error in Module:LC_zh at line 482: Unknown or missing content type code: nil. |
![]() |
{{LC zh|type=N}} | ||
![]() |
{{LC zh|type=N|ns=User}} | User | User |
![]() |
{{LC zh|type=N|ns=Help}} | Help | Help |
![]() |
{{LC zh|type=T}} | ||
![]() |
{{LC zh|type=T|ns=User}} | User: | User: |
![]() |
{{LC zh|type=T|ns=Help}} | Help: | Help: |
![]() |
{{LC zh|type=T|ns=User|zh=Example}} | User:Example | User:Example |
![]() |
{{LC zh|type=T|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} | Help:Example | Help:Example |
![]() |
{{LC zh|type=T|hide_ns=1|ns=Help}} | ||
![]() |
{{LC zh|type=T|hide_ns=1|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} | Example | Example |
![]() |
{{LC zh|type=H}} | An error | |
![]() |
{{LC zh|type=C}} | An error | |
![]() |
{{LC zh|type=C|zh=Example|zh-hans=示例|zh-hant=範例}} | Example | Example |
test_template_localized_link:
Text | Expected | Actual | |
---|---|---|---|
![]() |
{{Localized link}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |
![]() |
{{Localized link}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |
test_template_localized_link_sandbox:
Text | Expected | Actual | |
---|---|---|---|
![]() |
{{Localized link/sandbox}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |
![]() |
{{Localized link/sandbox}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |