Template:Lang-zh/doc
| This is a documentation subpage for Template:Lang-zh. It may contain usage information, categories and other content that is not part of the original template page. |
__EXPECTED_UNCONNECTED_PAGE__
| This template uses Lua: |
| This template is used on approximately 84,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
| This template should not be used in citation templates such as Citation Style 1 and Citation Style 2, because it includes markup that will pollute the COinS metadata they produce; see Wikipedia:COinS. |
This is a unified template for displaying various varieties of Chinese, in various orthographies. It can display (and link to): both simplified and traditional Chinese characters; literal translation; Zhuyin (Bopomofo); the Hanyu Pinyin, Tongyong Pinyin, and Wade–Giles romanizations of Mandarin; the Jyutping, Yale, and Sidney Lau romanizations of Cantonese; and the Pe̍h-ōe-jī and Tâi-lô romanizations of Hokkien. It supports ordering and formatting the output for different use cases.
Usage
Parameters
To use the template, start with {{Lang-zh}} and add any parameters you like, along with what you want to be displayed. The template will display all, and only, the parameters that you give it. The following parameters are supported:
| Parameter | Description | Example | |
|---|---|---|---|
|t=or |t_hk=or |t_tw=[1]
|
traditional Chinese[2] | {{Lang-zh|t=中國}}Chinese: 中國 | |
|s=
|
simplified Chinese[2] | {{Lang-zh|s=中国}}Chinese: 中国 | |
|c=[3]
|
Chinese (here simplified forms) | {{Lang-zh|c=中国}}Chinese: 中国 | |
|p= or |hp= |
pinyin[4] | Mandarin | {{Lang-zh|p=Zhōngguó}}pinyin: Zhōngguó |
|tp= |
Tongyong Pinyin | {{Lang-zh|tp=Jhongguó}}Tongyong Pinyin: Jhongguó | |
|w= |
Wade–Giles[5] | {{Lang-zh|w=Chung1kuo2}}Wade–Giles: Chung1kuo2 | |
|j= |
Jyutping[6] | Cantonese | {{Lang-zh|j=Gwong2zau1}}Jyutping: Gwong2zau1 |
|cy= |
Cantonese Yale | {{Lang-zh|cy=Gwóngjāu}}Cantonese Yale: Gwóngjāu | |
|sl= |
Sidney Lau[5] | {{Lang-zh|sl=Gwong2jau1}}Sidney Lau: Gwong2jau1 | |
|poj= |
Pe̍h-ōe-jī | Hokkien | {{Lang-zh|poj=Tâi-tiong-koān}}Pe̍h-ōe-jī: Tâi-tiong-koān |
|tl= |
Tâi-lô | {{Lang-zh|tl=Tâi-tiong-kuān}}Tâi-lô: Tâi-tiong-kuān | |
|zhu=
|
Zhuyin Fuhao | {{Lang-zh|zhu=ㄊㄠˊ ㄩㄢˊ ㄒㄧㄢˋ}}Zhuyin Fuhao: ㄊㄠˊ ㄩㄢˊ ㄒㄧㄢˋ | |
|l=
|
literal meaning | {{Lang-zh|l=Middle Kingdom}}lit. 'Middle Kingdom' | |
|tr=
|
translation | {{Lang-zh|tr=China}}trans. "China" | |
|labels=
|
Display language labels | See below | |
|links=
|
Display language links | See below | |
|first=
|
Override default ordering | See below | |
|scase=
|
Use sentence case | See below | |
|out=
|
Choose a parameter to display outside of brackets | See below | |
- ↑ Use
|t_hk=or|t_tw=to specify an orthographic variant if needed. See this image for an example. - ↑ 2.0 2.1 If
|s=and|t=are both given and are the same – i.e. the simplified and traditional characters are identical – then they only appear once:{{Lang-zh|s=北京|t=北京}}gives Chinese: 北京. - ↑ If only one unnamed parameter is given, it will be treated as if it were passed to
|c=. - ↑ This will display as "Hanyu Pinyin", instead of just "pinyin", if Tongyong Pinyin is also included in the template; this way the two types of pinyin contrast and neither is treated as a "default".
- ↑ 5.0 5.1 Wade-Giles and SidneyLau romanizations use superscripted numbers for tones. The template automatically converts unsuperscripted tone numbers to superscripted ones.
- ↑ Can be automatically generated:
{{kCantonese|廣州}}→ gwong2 zau1
Label options
Add |labels=no anywhere in the template to disable labels, so only the text supplied as parameters appears, separated by semicolons. This minimises the length of the template, and can be used when the template is used more than once to lessen its impact. Disabling labels also suppresses links.
{{Lang-zh|t=中國|s=中国|hp=Zhōngguó|tp=Jhongguó|labels=no}}- 中国; 中國; Zhōngguó; Jhongguó
Add |links=no anywhere in the template to suppress label links. This is for preventing overlinking in an article or section where the template is used repeatedly.
{{Lang-zh|t=中國|s=中国|hp=Zhōngguó|tp=Jhongguó|links=no}}- simplified Chinese: 中国; traditional Chinese: 中國; Hanyu Pinyin: Zhōngguó; Tongyong Pinyin: Jhongguó
Add |scase=yes anywhere in the template to use sentence case, so the first label starts with a capital letter. This allows the template to be used at the start of a sentence for example.
{{Lang-zh|t=中國|s=中国|hp=Zhōngguó|tp=Jhongguó|scase=yes}}- Simplified Chinese: 中国; traditional Chinese: 中國; Hanyu Pinyin: Zhōngguó; Tongyong Pinyin: Jhongguó
Ordering
The template can be given more than one value (for example, on the article China, it has s, t, hp, tp, and w). By default, when multiple parameters are given they will be shown in the same order as the above table: first Chinese characters (simplified, then traditional), then romanizations (starting with Hanyu and Tongyong Pinyin).
This order can be overridden (for example for Hong Kong and Taiwan topics), using |first=. It accepts a comma delimited list of values, out of the following:
|first=tputs traditional characters before simplified characters|first=jputs the Cantonese romanizations (Jyutping, Yale, and Sidney Lau) before Mandarin and Hokkien romanizations|first=pojputs Hokkien romanizations (POJ and Tâi-lô) before Mandarin and Cantonese romanizations
They can be combined in any order, for example: |first=j,t or |first=t,j
Examples:
{{Lang-zh|t=臺北|s=台北|hp=Táiběi}}- simplified Chinese: 台北; traditional Chinese: 臺北; pinyin: Táiběi
{{Lang-zh|t=臺北|s=台北|hp=Táiběi|first=t}}- traditional Chinese: 臺北; simplified Chinese: 台北; pinyin: Táiběi
{{Lang-zh|t=九龍|s=九龙|p=Jiǔlóng|j=gau2lung4}}- simplified Chinese: 九龙; traditional Chinese: 九龍; pinyin: Jiǔlóng; Jyutping: gau2lung4
{{Lang-zh|t=九龍|s=九龙|p=Jiǔlóng|j=gau2lung4|first=t, j}}- traditional Chinese: 九龍; simplified Chinese: 九龙; Jyutping: gau2lung4; pinyin: Jiǔlóng
It is also possible to override the default ordering for an entire article, so all uses of the template default to |first=t (traditional characters before simplified characters).
This is done by adding the article to the list t1st at the top of Module:Lang-zh, following the formatting of the articles already there. The module is edit-protected, so you may need to use {{edit template-protected}} on the module's talk page Module talk:Lang-zh to request an article is added, if you cannot add it yourself.
Bracketing
|out= can be used to place a supplied parameter outside brackets, with the remainder placed within them. This is useful when a particular aspect of the text is being read inline or emphasized. If both |s= and |t= are specified, and |out=c, both sets of characters will be placed outside the brackets.
Examples:
{{Lang-zh|t=馬來西亞|s=马来西亚|hp=Mǎláixīyà|tr=Malaysia|labels=no|out=tr}}- "Malaysia" (马来西亚; 馬來西亞; Mǎláixīyà)
{{Lang-zh|t=馬來西亞|s=马来西亚|hp=Mǎláixīyà|tr=Malaysia|labels=no|out=c}}- 马来西亚; 馬來西亞 (Mǎláixīyà; "Malaysia")
{{Lang-zh|t=可口可樂|s=可口可乐|p=Kěkǒu Kělè|tr=[[Coca-Cola]]|labels=no|out=p}}- Kěkǒu Kělè (可口可乐; 可口可樂; "Coca-Cola")
TemplateData
TemplateData documentation used by VisualEditor and other tools
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
See a monthly parameter usage report for Template:Lang-zh in articles based on its TemplateData.
TemplateData for Lang-zh A template to facilitate consistent layout, proper formatting, categorisation and language labelling of Chinese text and its romanizations
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tracking categories
- Category:Articles containing Chinese-language text (0)
- Category:Articles containing simplified Chinese-language text (0)
- Category:Articles containing traditional Chinese-language text (0)
- Category:Pages using template Zh with sup tags (0)
See also
{{Infobox Chinese}}, an infobox that supports traditional and simplified Chinese as well as other common romanizations{{Old Chinese}}, for reconstructed Old Chinese phonology{{Rarely-used Chinese characters}}, to describe characters that may have trouble rendering properly
Aliases
{{zhc}}→{{lang-zh|labels=no|out=c}}{{zhi}}→{{lang-zh|labels=no}}{{zht}}→{{lang-zh|labels=no|out=tr}}{{zhp}}→{{lang-zh|labels=no|out=p}}
Similar templates
| Template | Languages | Scripts | Transliterations | Translation | Labels |
|---|---|---|---|---|---|
{{Hani}}
|
Any | N/a | No | ||
{{CJKV}}
|
Yes | Always | |||
{{lang-zh}}
|
Chinese |
|
|
Yes | Optional |
{{yue}}
|
Cantonese |
|
Jyutping | No | Optional |
{{Nihongo}}
|
Japanese | Japanese writing system[lower-alpha 1] | Hepburn | Yes | Optional |
{{Nihongo2}}
|
N/a | No | |||
{{Korean}}
|
Korean |
|
Yes | Optional | |
{{Hanja}}
|
Korean | Hanja | N/a | No | Always |
{{Vi-nom}}
|
Vietnamese | Chữ Nôm | N/a | No | |
{{Lang}}
|
Any | Any | Any | No | |
{{Langx}}
|
Yes | Optional | |||
Unicode templates | |
|---|---|
| General | |
| Inline | |
| Character properties | |
| Code points | |
| Scripts | |
| CJK-specific | |
| Wikipedia related |
- Template:Lang-zh invokes Module:Navbox using Lua.
Usage
This template can be used to make a standard navigation box. It is intended for use within another template that standardises the title and contents of the box (see Template:ShipNavbox). This template SHOULD NOT be used directly within articles, as it creates a maintenance burden to do so whenever the contents of the box have to be updated.
The purpose of this template is to standardise the attributes of all navigation boxes, for example, their colours and other CSS attributes. The template is fairly simple, and could be extended to add other features in the future. Using this template allows changes to be implemented much quicker and easier than editing each template separately.
Syntax
{{navbox
|state = uncollapsed, collapsed, plain, autocollapse (default)
|name = mandatory - name of the template
|style = optional - style for the whole table
|title = mandatory - navbox header
|gtitleN = optional - title of N-th group of items
|styleN = optional - style for groupN; i.e. text-align
|groupN = mandatory - list of groups of items
|fstyle = optional - style for footer ; i.e. text-align
|footer = optional - navbox footer
}}
- Groups: Currently there is no technical limit to the maximum number of groups.
- Groups of items can be added as parameters: group1, group2, group3, ... up to groupN.
- Group title: Each group has its own title parameter: gtitle1, gtitle2, gtitle3, ... up to gtitleN. Note that the default width for the first column is 15%.
- Group style: Style may also be customised to each group in: style1, style2, style3, ... up to styleN.
- Note that neither the title nor the items have any wiki-links built into the template. As a result, users of the template are free to use wiki-links as they wish.
- Line breaks: Line-breaks (
<br />) are unnecessary, as text wrapping is done automatically by the template. This also includes links and text in gtitleN and groupN. - Bullets: Create unordered lists with lines beginning with *.
- Pipe links: Because of the nature of template syntax, it may be necessary to use Template:! (
{{!}}).
States
- Autocollapse: By default, the state of a navbox is "autocollapsed". This means that if the number of navboxes in a page exceeds the maximum allocation of the collapsible navboxes, then the remaining navboxes are collapsed automatically. For more information (or to change the setting), see MediaWiki:Common.js.
- Currently, the autocollapse allocation is 2 (see MediaWiki:Common.js). This means that if there are 3 navboxes in a page, the third and subsequent navboxes will be collapsed automatically.
- Uncollapsed: Forces the navbox to be displayed.
- All of the navboxes in this documentation are in the uncollapsed state.
- Collapsed: The reverse of uncollapsed. Forces the navbox to be hidden instead.
- Navboxes with a height of more than 300 pixels will also be collapsed automatically. For more information (or to change the setting), see MediaWiki:Common.js.
- Plain: Removes the "show/hide" link.
Sub-groups
- For larger navboxes, it may be necessary to include sub-groups within a particular group of items. It is also possible to collapsible navboxes within the parent navbox, see Collapsible sub-groups.
- To create sub-groups within
{{navbox}}, certain parameters are to be included:- The parent navbox group (i.e. group2 in the example below) requires the type parameter (gtype2 = Subgroup).
- The nested navbox (sub-group) requires the inclusion of the sub-group parameter (subgroup = yes). This enables the template to differentiate between the sub-group and the parent navbox.
{{navbox
|name =
|title =
|gtitle1 =
|group1 =
|gtitle2 =
|gtype2 = Subgroup (mandatory)
|group2 =
{{navbox
|subgroup = yes (mandatory)
|gtitle1 =
|group1 =
|gtitle2 =
|group2 =
}}
}}
Collapsible sub-groups
- For extremely long navboxes, it is recommended to use collapsible navboxes within the parent navbox. Further sub-groups can then be added to these collapsible navboxes.
- To create collapsible sub-groups within
{{navbox}}, these parameters need to be included:- The parent navbox is almost always uncollapsed (state=uncollapsed).
- The parent navbox group (i.e. group1 in the example below) requires the type parameter (gtype1 = Subgroup).
- The nested collapsible navbox requires the inclusion of the collapsible parameter (collapsible = yes). This enables the template to differentiate between the collapsible navbox and the parent navbox.
- The nested collapsible navbox is forcefully collapsed (state=collapsed).
{{navbox
|state = uncollapsed
|name =
|gtype1 = Subgroup
|group1 =
{{navbox
|collapsible = yes
|state = collapsed
|title =
|gtitle1 =
|group1 =
|gtitle2 =
|group2 =
}}
}}
Use of images
- The use of images in navboxes is permitted, but please resize the images to keep them small. Inventory-sized images (25-30 pixels) are recommended.
- Please use {{t|plink}} to create links with images. Use {{t|plink}} for any case where text is not desired after the link. It functions the same as {{t|plink}}, but it does not produce a wikilink in text. Use {{t|chatl}} to link chatheads. These templates create links for both the image and text (except for {{t|plink}}) using far less wikicode than the standard syntax.
Link and file share the same name
{{plink|Item}}
File name differs from the link
{{plink|Item|File}}
Link and file share the same name, but different text is desired to display
{{plink|Item|alt=Text}}
File name differs from the link and different text is desired to display
{{plink|Item|File|alt=Text}}
Categorising
Navboxes are very useful for transcluding categories onto a large number of pages that share both a trait and the navigation box. For example: Template:ShipNavbox transcludes Category:Ships onto every page that uses it.
There are 2 methods of categorising pages with navboxes:
The first way is with {{t|Ctg}}. This is the preferred method, and can be used in most cases. The rules and operations for the Category handler template are very simple; however, they are enough to produce the desired results on most pages.
Categorisation should only be used on a template for large-scale addition. It is unhelpful, for example, to use a rule that only applies to 1 page.
Examples
To see the following navboxes in action, see Template:Navbox.
Single line navbox with centered list
{{navbox
|name =
|title =
|style1 = text-align:center
|group1 =
}}
Navbox with standard footer
{{navbox
|name =
|title =
|gtitle1 =
|group1 =
|footer = Centered footer
}}
Navbox with styled footer
{{navbox
|name =
|title =
|gtitle1 =
|group1 =
|fstyle = text-align:right
|footer = Right-aligned footer
}}
Multiple line navbox
{{navbox
|name =
|title =
|gtitle1 = Group title 1
|group1 =
|gtitle2 = Group title 2
|group2 =
|gtitle3 = Group title 3
|group3 =
}}
Collapsed navbox
{{navbox
|state = collapsed
|name =
|title =
|style1 = text-align:center
|group1 =
}}
Plain navbox with Tnavbar
{{navbox
|state = plain
|name =
|title =
|style1 = text-align:center
|group1 =
}}
Plain navbox without Tnavbar
{{navbox
|state = plain
|title =
|style1 = text-align:center
|group1 =
}}
Complicated navbox
{{navbox
|state = uncollapsed
|name =
|title =
|gtitle1 = Level 1 Title 1
|group1 =
|gtitle2 = Level 1 Title 2
|group2 =
|gtitle3 = Level 1 Title 3
|group3 =
|gtitle4 = Level 1 Title 4
|group4 =
|gtitle5 = Level 1 Title 5
|gtype5 = Subgroup
|group5 =
{{navbox
|subgroup = Yes
|gtitle1 = Level 2 Title 1
|group1 =
|gtitle2 = Level 2 Title 2
|group2 =
|gtitle3 = Level 2 Title 3
|gtype3 = Subgroup
|group3 =
{{navbox
|subgroup = Yes
|gtitle1 = Level 3 Title 1
|group1 =
|gtitle2 = Level 3 Title 2
|group2 =
}}
|gtitle4 = Level 2 Title 4
|group4 =
}}
|gtitle6 = Level 1 Title 6
|group6 =
|gtitle7 = Level 1 Title 7
|group7 =
|fstyle =
|footer =
}}
Preventing unwanted documentation
The Navbox template's documentation is automatically transcluded under the navbox on any Template namespace page. It is not transcluded when used as a sub-group or collapsible sub-group template (subgroup= yes or collapsible=yes).
Should the documentation appear when it is unwanted, it can be hidden by setting the doc parameter doc=no on the template. In most cases, the doc parameter is NOT used and the parameter is removed completely.
Cite error: <ref> tags exist for a group named "lower-alpha", but no corresponding <references group="lower-alpha"/> tag was found