Jump to content

Template:LC zh/zh

From mediawiki.org
This page is a translated version of the page Template:LC zh and the translation is 69% complete.
模板文档

描述

此模板用於處理中文(「zh」)頁面標題及內容的字詞轉換(language conversion,「LC」),特別是在包含/去除命名空間名稱(「nsp」參數)的頁面標題、會同時用於含字詞轉換/不含字詞轉換頁面的內容。

用法

不同内容类型的用法各不相同。

除非是特定的Wikitext语法(如章节标题、列表),否则不要将内容碎片化。

Green tickY {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}

N 按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}

Green tickY {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = '''按需求配置。'''|zh-hant = '''按需求設定組態。'''}}

N '''{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}'''

Green tickY == {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}} ==

N {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = == 按需求配置。 ==|zh-hant = == 按需求設定組態。 ==}}

N == 按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}。 ==

Green tickY * {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}

N {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = * 按需求配置。|zh-hant = * 按需求設定組態。}}

N * 按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}

N - 命名空间名称

请勿在页面显示标题中使用此类型。

仅命名空间名称:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = <namespace name in en>}}

包含伪命名空间名称:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = <namespace name in en>|ns_2 = <pseudo namespace name in en>}}

示例:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = Help}} → Help
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = Help|ns_2 = Extension}} → Help:Extension

T - 頁面顯示標題

僅用於主命名空間的頁面標題:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = |zh-hans = <zh-Hans(中文,简化汉字)页面名称>|zh-hant = <zh-Hant(中文,傳統漢字)頁面名稱>}}

对于包含命名空间名称的页面标题:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英語命名空間名稱>|zh-hans = <zh-Hans(中文,简化汉字)页面名称>|zh-hant = <zh-Hant(中文,傳統漢字)頁面名稱>}}
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英語命名空間名稱>|zh-hans = <zh-Hans(中文,简化汉字)页面名称>|zh-hant = <zh-Hant(中文,傳統漢字)頁面名稱>|zh-hk = <zh-Hant-HK(中文,傳統漢字,香港用詞)頁面名稱>}}

对于包含伪命名空间名称的页面标题:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <namespace name in en>|ns_2 = <pseudo namespace name in en>|zh-hans = <zh-Hans page name>|zh-hant = <zh-Hant page name>}}
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <namespace name in en>|ns_2 = <pseudo namespace name in en>|zh-hans = <zh-Hans page name>|zh-hant = <zh-Hant (zh-Hant-TW) page name>|zh-hk = <zh-Hant-HK page name>}}

示例:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = Project|zh-hans = 关于|zh-hant = 關於}} → Project:关于

H - 章节标题

标题可为不同语言版本自动生成多个锚点。

  • == {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = <zh-Hans section heading>|zh-hant = <zh-Hant section heading>}} ==
  • == {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = <zh-Hans section heading>|zh-hant = <zh-Hant (zh-Hant-TW) section heading>|zh-hk = <zh-Hant-HK section heading>}} ==

Example:

  • == {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 关于|zh-hant = 關於}} == → == 关于 ==

C - 內容

  • {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = <zh-Hans(中文,简化汉字)內容>|zh-hant = <zh-Hant(中文,傳統漢字)內容>}}
  • {{LC zh|lang = {{{lang|}}}|C|zh-hans = <zh-Hans(中文,简化汉字)內容>|zh-hant = <zh-Hant(zh-Hant-TW,中文,傳統漢字,臺灣用詞)內容>|zh-hk =<zh-Hant-HK(中文,傳統漢字,香港用詞)內容>}}

示例:

  • {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 关于|zh-hant = 關於}} → 关于

整合其他模板及模組

备注

如果模板是用户页模板、全域公告等,无法使用字词转换器转换,则应考虑使用Template:Conversion-zh 而不是此模板。

模板数据

[查看 · 讨论 · 编辑]

这是该模板的模板数据,用于可视化编辑器及其它工具。

LC zh

Language conversion template for Mandarin namespace names, page display titles, section headings and content. Only support zh-hans, zh-hant, zh-hk

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
输出语言/语言变体lang

要输出的语言/语言变体。("zh-hans"、"zh-hans"、"zh-hk")

Example
zh-hant
Auto value
{{{lang|}}}
Stringoptional
是否隐藏命名空间前缀hide_ns

(type = N, T) Whether to hide the namespace prefix (only apply to parameter "ns", does not affect parameter "ns_2"). Value is passed from the "nsp" parameter of [[Template:Localized link]]. Aliases: "2", "nsp".

Example
1
Auto value
{{{nsp|}}}
Booleanoptional
内容类型type

The content type, values: "N" - Namespace names, "T" - Page display title, "H" - Section heading, "C" - Text content. Aliases: "1".

Example
T
Auto value
C
Stringrequired
English canonical namespace namens

(type = N, T) The canonical name of the namespace in English. Aliases: "3", "namespace".

Example
Help
Stringoptional
2nd English canonical namespace namens_2

(type = N, T) The canonical name of the secondary pseudo-namespace in English. For example, "Extension" in "Help:Extension:Example".

Example
Extension
Stringoptional
Mandarin - Simplified Han scriptzh-hans

The text content in Mandarin - Simplified Han script.

Default
{{{zh-hant|{{{zh-hk|}}}}}}
Example
Example_zh-Hans
Contentsuggested
Mandarin - Traditional Han scriptzh-hant

The text content in Mandarin - Traditional Han script.

Default
{{{zh-hk|{{{zh-hans|}}}}}}
Example
Example_zh-Hant
Contentsuggested
Mandarin - Traditional Han script, Hong Kongzh-hk

The text content in Mandarin - Traditional Han script, Hong Kong.

Default
{{{zh-hant|{{{zh-hans|}}}}}}
Example
Example_zh-Hant-HK
Contentoptional
编辑参数翻译

测试用例

All tests passed.

test_main:

Text Expected Actual
Yes {{#invoke:LC zh|main}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N}} An error Caught expected error: Lua error: Missing parameter "ns".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = }}
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = User}} User User
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = Help}} Help Help
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User}} An error Caught expected error: Lua error in Module:LC_zh at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} User:Example User:Example
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} Help:示例 Help:示例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} Help:範例 Help:範例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} 示例 示例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H}} An error Caught expected error: Lua error in Module:LC_zh at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} 用户 用户
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = C}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} 示例 示例

test_template:

Text Expected Actual
Yes {{LC zh}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{LC zh|lang = {{{lang|}}}}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{LC zh|lang = {{{lang|}}}|type = N}} An error Caught expected error: Lua error: Missing parameter "ns".
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = }}
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = User}} User User
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = Help}} Help Help
Yes {{LC zh|lang = {{{lang|}}}|type = T}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = User}} An error Caught expected error: Lua error in Module:LC_zh at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} User:Example User:Example
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} Help:示例 Help:示例
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} Help:範例 Help:範例
Yes {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} 示例 示例
Yes {{LC zh|lang = {{{lang|}}}|type = H}} An error Caught expected error: Lua error in Module:LC_zh at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} 用户 用户
Yes {{LC zh|lang = {{{lang|}}}|type = C}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} 示例 示例

test_template_localized_link:

Text Expected Actual
Yes {{Localized link}} [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span>
Yes {{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
Yes {{Localized link/sandbox}} [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span>
Yes {{Localized link/sandbox}} [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span>

追踪分类