Template:LC zh/zh

From Linux Web Expert

Revision as of 06:32, 14 April 2024 by imported>FuzzyBot (Updating to match new version of source page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Template documentation

描述

此模板用於處理中文(「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(-{中文,傳統漢字,香港用詞}-)頁面名稱>}}
      • -{zh-hans:示例:; zh-hant:範例:;}- {{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(-{中文,傳統漢字,香港用詞}-)內容>}}
      • -{zh-hans:示例:; zh-hant:範例:;}- {{LC zh|C|zh-hans=关于|zh-hant=關於}}

整合其他模板及模組

备注

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

-{zh-hans:模板数据; zh-hant:模板資料;}-

<templatedata> { "format": "inline", "params": { "variant": { "label": "Language variant", "description": "Specify the language variant to output", "type": "string" }, "type": { "label": "Content type", "description": "The content type to convert.\n\n* \"N\": namespace name\n* \"T\": page title\n* \"H\": headings\n* \"C\": content", "example": "T", "type": "string", "required": true, "suggestedvalues": [ "N", "T", "H", "C" ], "autovalue": "C", "aliases": [ "1" ] }, "hide_ns": { "label": "Hide namespace name", "description": "Only for title output mode (T).\n\nUsed for pass nsp parameter from \"Template:Localized link\".\n\nOnly required for non-main-namespace page title texts.", "example": "", "type": "number", "suggestedvalues": [ "" ], "autovalue": "", "suggested": true, "aliases": [ "2", "nsp" ] }, "ns": { "label": "English canonical namespace name", "description": "Only for namespace name (N) and title (T) output modes.\n\nThe English namespace name of the full page title text.", "example": "Help",

   		"type": "string",

"suggestedvalues": [ "User", "User talk", "Project", "Template", "Help", "Category", "Manual", "Extension", "API", "Skin" ], "suggested": true, "aliases": [ "3", "namespace" ] }, "ns_2": { "label": "2nd English canonical namespace name", "description": "Expecially for Help namespace cases like \"Help:Extension:\".\n\nOnly for namespace name (N) and title (T) output modes.\n\nThe English namespace name of the full page title text.", "example": "Extension",

   		"type": "string"

}, "zh-hans": { "type": "string", "description": "Mandarin (Simplified Han script) content", "suggested": true }, "zh-hant": { "type": "string", "description": "Mandarin (Traditional Han script, Taiwan) content", "suggested": true }, "zh-hk": { "type": "string", "description": "Mandarin (Traditional Han script, Hong Kong) content" } }, "paramOrder": [ "variant", "type", "hide_ns", "ns", "ns_2", "zh-hans", "zh-hant", "zh-hk" ] } </templatedata>

Test cases

All tests passed.

test_main:

Text Expected Actual
File:OOjs UI icon check-constructive.svg main}}
File:OOjs UI icon check-constructive.svg main|type=N}}
File:OOjs UI icon check-constructive.svg main|type=N|ns=User}} User User
File:OOjs UI icon check-constructive.svg main|type=N|ns=Help}} Help Help
File:OOjs UI icon check-constructive.svg main|type=T}}
File:OOjs UI icon check-constructive.svg main|type=T|ns=User}} User: User:
File:OOjs UI icon check-constructive.svg main|type=T|ns=Help}} Help: Help:
File:OOjs UI icon check-constructive.svg main|type=T|ns=User|zh=Example}} User:Example User:Example
File:OOjs UI icon check-constructive.svg main|type=T|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} Help:Example Help:Example
File:OOjs UI icon check-constructive.svg main|type=T|hide_ns=1|ns=Help}}
File:OOjs UI icon check-constructive.svg main|type=T|hide_ns=1|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} Example Example
File:OOjs UI icon check-constructive.svg main|type=H}}
File:OOjs UI icon check-constructive.svg main|type=C}}
File:OOjs UI icon check-constructive.svg main|type=C|zh=Example|zh-hans=示例|zh-hant=範例}} Example Example

test_template:

Text Expected Actual
File:OOjs UI icon check-constructive.svg {{LC zh}}
File:OOjs UI icon check-constructive.svg type=N}}
File:OOjs UI icon check-constructive.svg type=N|ns=User}} User User
File:OOjs UI icon check-constructive.svg type=N|ns=Help}} Help Help
File:OOjs UI icon check-constructive.svg type=T}}
File:OOjs UI icon check-constructive.svg type=T|ns=User}} User: User:
File:OOjs UI icon check-constructive.svg type=T|ns=Help}} Help: Help:
File:OOjs UI icon check-constructive.svg type=T|ns=User|zh=Example}} User:Example User:Example
File:OOjs UI icon check-constructive.svg type=T|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} Help:Example Help:Example
File:OOjs UI icon check-constructive.svg type=T|hide_ns=1|ns=Help}}
File:OOjs UI icon check-constructive.svg type=T|hide_ns=1|ns=Help|zh=Example|zh-hans=示例|zh-hant=範例}} Example Example
File:OOjs UI icon check-constructive.svg type=H}}
File:OOjs UI icon check-constructive.svg type=C}}
File:OOjs UI icon check-constructive.svg type=C|zh=Example|zh-hans=示例|zh-hant=範例}} Example Example