Template:LC zh
| This template uses Lua: |
Description
This template handles the language conversion ("LC") for Mandarin ("zh") page titles and content, especially for page titles with/without namespace names (the "nsp" parameter), content across language converter and non-language-converter pages.
Usage
The usage is different in each content types. Template:Note
Template:Check mark {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}
按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}。
Template:Check mark {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = '''按需求配置。'''|zh-hant = '''按需求設定組態。'''}}
'''{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}'''
Template:Check mark == {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}} ==
{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = == 按需求配置。 ==|zh-hant = == 按需求設定組態。 ==}}
== 按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}。 ==
Template:Check mark * {{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 按需求配置。|zh-hant = 按需求設定組態。}}
{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = * 按需求配置。|zh-hant = * 按需求設定組態。}}
* 按需求{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 配置|zh-hant = 設定組態}}。
N - Namespace names
Template:Note Namespace name-only:
[[:Template:Tmpl]]
Containing pseudo namespace name:
[[:Template:Tmpl]]
Example:
{{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 - Page display title
For page titles in main namespace:
[[:Template:Tmpl]]
For page titles containing namespace name:
[[:Template:Tmpl]][[:Template:Tmpl]]
For page titles containing pseudo namespace name:
[[:Template:Tmpl]][[:Template:Tmpl]]
Example:
{{LC zh|lang = {{{lang|}}}|hide_ns = {{{nsp|}}}|type = T|ns = Project|zh-hans = 关于|zh-hant = 關於}}→ Project:关于
H - Section headings
Headings can automatically generate multiple anchors for different language variants.
[[:Template:Tmpl]][[:Template:Tmpl]]
Example:
== {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 关于|zh-hant = 關於}} ==→ == 关于 ==
C - Content
[[:Template:Tmpl]][[:Template:Tmpl]]
Example:
{{LC zh|lang = {{{lang|}}}|type = C|zh-hans = 关于|zh-hant = 關於}}→ 关于
Integration with other templates and modules
Notes
If the template is a user page template, global announcement, etc., which cannot be converted using Language Converter, you should consider using Template:Conversion-zh instead of this template.
Template data
Test cases
2 tests failed.
test_main:
| Text | Expected | Actual | |
|---|---|---|---|
| {{#invoke:LC zh|main}} | An error | Caught expected error: Lua error: Unknown content type code "nil". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}}} | An error | Caught expected error: Lua error: Unknown content type code "nil". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N}} | An error | Caught expected error: Lua error: Missing parameter "ns". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = }} | |||
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = User}} | User | User | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = Help}} | Help | Help | |
| {{#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". | |
| {{#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". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} | User:Example | User:Example | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} | Help:示例 | Help:示例 | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} | Help:範例 | Help:範例 | |
| {{#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". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} | 示例 | 示例 | |
| {{#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". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} | 用户 | 用户 | |
| {{#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". | |
| {{#invoke:LC zh|main|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} | 示例 | 示例 |
test_template:
| Text | Expected | Actual | |
|---|---|---|---|
| {{LC zh}} | An error | Caught expected error: Lua error: Unknown content type code "nil". | |
| {{LC zh|lang = {{{lang|}}}}} | An error | Caught expected error: Lua error: Unknown content type code "nil". | |
| {{LC zh|lang = {{{lang|}}}|type = N}} | An error | Caught expected error: Lua error: Missing parameter "ns". | |
| {{LC zh|lang = {{{lang|}}}|type = N|ns = }} | |||
| {{LC zh|lang = {{{lang|}}}|type = N|ns = User}} | User | User | |
| {{LC zh|lang = {{{lang|}}}|type = N|ns = Help}} | Help | Help | |
| {{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". | |
| {{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". | |
| {{LC zh|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} | User:Example | User:Example | |
| {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} | Help:示例 | Help:示例 | |
| {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} | Help:範例 | Help:範例 | |
| {{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". | |
| {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} | 示例 | 示例 | |
| {{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". | |
| {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} | 用户 | 用户 | |
| {{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". | |
| {{LC zh|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} | 示例 | 示例 |
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> |
test_template_localized_link_sandbox:
| Text | Expected | Actual | |
|---|---|---|---|
| {{Localized link/sandbox}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[:Template:Localized link/sandbox]] |