模板:LC zh

From Test Wiki
Revision as of 03:54, 24 January 2026 by Peterxy12 (talk | contribs) (Created page with "== 追踪分类 ==")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
模板文檔

簡要

此模板負責處理普通話(zh)頁面標題和內容的語言轉換(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 = <英文中的命名空間名稱>}}

包含偽命名空間名稱:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = <英文中的命名空間名稱>|ns_2 = <英文中的偽命名空間名稱>}}

示例:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = Help}} → 說明
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = N|ns = Help|ns_2 = Extension}} → 說明:擴充功能

T - 頁面顯示標題

在主命名空間的頁面標題:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = |zh-hans = <簡體中文頁面名稱>|zh-hant = <繁體中文頁面名稱>}}

包含命名空間名稱的頁面標題:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英文中的命名空間名稱>|zh-hans = <簡體中文頁面名稱>|zh-hant = <繁體中文頁面名稱>}}
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英文中的命名空間名稱>|zh-hans = <簡體中文頁面名稱>|zh-hant = <繁體中文(台灣)頁面名稱>|zh-hk = <繁體中文(香港)頁面名稱>}}

包含偽命名空間名稱的頁面標題:

  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英文中的命名空間名稱>|ns_2 = <英文中的偽命名空間名稱>|zh-hans = <簡體中文頁面名稱>|zh-hant = <繁體中文頁面名稱>}}
  • {{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = <英文中的命名空間名稱>|ns_2 = <英文中的偽命名空間名稱>|zh-hans = <簡體中文頁面名稱>|zh-hant = <繁體中文(台灣)頁面名稱>|zh-hk = <繁體中文(香港)頁面名稱>}}

示例:

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

H - 章節標題

標題可以為不同的語言變體自動生成多個描點。

  • == {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = <簡體中文章節標題>|zh-hant = <繁體中文章節標題>}} ==
  • == {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = <簡體中文章節標題>|zh-hant = <繁體中文(台灣)章節標題>|zh-hk = <繁體中文(香港)章節標題>}} ==

示例:

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

C - 內容

  • {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = <簡體中文內容>|zh-hant = <繁體中文內容>}}
  • {{LC zh|lang = {{{lang|}}}|C|zh-hans = <簡體中文內容>|zh-hant = <繁體中文(台灣)內容>|zh-hk =<繁體中文(香港)內容>}}

示例:

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

與其他模板和模塊整合

注釋

如果該模板屬於用戶頁模板、全域公告等無法通過字詞轉換器轉換的類型,建議使用Template:Conversion-zh 替代此模板。

模板數據

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:LC zh in articles based on its TemplateData.

TemplateData for LC zh

<templatedata>{"paramOrder":["lang","hide_ns","type","ns","ns_2","zh-hans","zh-hant","zh-hk"],"description":"Language conversion template for Mandarin namespace names, page display titles, section headings and content. Only support zh-hans, zh-hant, zh-hk","params":{"ns_2":{"suggested":false,"type":"string","required":false,"label":"2nd English canonical namespace name","example":"Extension","description":"(type = N, T) The canonical name of the secondary pseudo-namespace in English. For example, \"Extension\" in \"Help:Extension:Example\"."},"type":{"suggested":false,"type":"string","required":true,"label":"內容類型","example":"T","description":"The content type, values: \"N\" - Namespace names - Do not use this type in page display title, \"T\" - Page display title, \"H\" - Section heading, \"C\" - Text content, \"U\" - Unconvertible content - Only use this type in unconvertible content, e.g., global announcements, syntax highlight blocks, system messages, user page templates. Aliases: \"1\".","autovalue":"C"},"zh-hk":{"suggested":false,"type":"content","default":"{{{zh-hant|{{{zh-hans|}}}}}}","label":"Mandarin - Traditional Han script, Hong Kong","description":"The text content in Mandarin - Traditional Han script, Hong Kong.","example":"Example_zh-Hant-HK","required":false},"hide_ns":{"suggested":false,"type":"boolean","required":false,"label":"是否隱藏命名空間前綴","example":"1","description":"(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\".","autovalue":"{{{nsp|}}}"},"zh-hant":{"suggested":true,"type":"content","default":"{{{zh-hk|{{{zh-hans|}}}}}}","label":"Mandarin - Traditional Han script","description":"The text content in Mandarin - Traditional Han script.","example":"Example_zh-Hant","required":false},"zh-hans":{"suggested":true,"type":"content","default":"{{{zh-hant|{{{zh-hk|}}}}}}","label":"Mandarin - Simplified Han script","description":"The text content in Mandarin - Simplified Han script.","example":"Example_zh-Hans","required":false},"lang":{"suggested":false,"type":"string","required":false,"label":"輸出語言/語言變體","example":"zh-hant","description":"要輸出的語言/語言變體。(\"zh-hans\"、\"zh-hans\"、\"zh-hk\")","autovalue":"{{{lang|}}}"},"ns":{"suggested":false,"type":"string","required":false,"label":"English canonical namespace name","example":"Help","description":"(type = N, T) The canonical name of the namespace in English. Aliases: \"3\", \"namespace\"."}}}</templatedata>編輯參數翻譯

測試樣例

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}} 使用者 使用者
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = 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}} 使用者:Example 使用者:Example
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} 說明:範例 說明:範例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} 說明:範例 說明:範例
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}} 使用者 使用者
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = 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}} 使用者:Example 使用者:Example
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} 說明:範例 說明:範例
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} 說明:範例 說明:範例
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>

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>

追蹤分類