模板:Infobox settlement/pref

模板页面
文档图示 模板文档[查看] [编辑] [查看历史] [清除缓存]

This is a subtemplate of 模板链接:{{Infobox settlement}}. It is not intended to be used directly. It is called by the following templates:

  • 模板链接:{{Infobox settlement/areadisp}}
  • 模板链接:{{Infobox settlement/densdisp}}
  • 模板链接:{{Infobox settlement/lengthdisp}}

仅显示公制单位:

  • 模板链接:{{Infobox settlement/metric_only}}
  • 模板链接:{{Infobox settlement/metric_only/mag}}

Its purpose is to determine whether those templates call one of the subtemplates that displays metric units first (the default):

  • 模板链接:{{Infobox settlement/metric}}
  • 模板链接:{{Infobox settlement/metric/mag}}

or one of the subtemplates that displays imperial units (U.S. units) first:

  • 模板链接:{{Infobox settlement/impus}}
  • 模板链接:{{Infobox settlement/impus/mag}}

or the following subtemplates if an area is specified in dunams:

  • 模板链接:{{Infobox settlement/dunam}}
  • 模板链接:{{Infobox settlement/dunam/mag}}

Usage

The template handles up to three unnamed parameters.

  1. Text which specifies preference to display either metric or Imperial units first. It is specified as unit_pref in 模板链接:{{Infobox settlement}}, then passed as pref to one of three display subtemplates (/areadisp, /densdisp, /lengthdisp).
  2. Country name, used to determine preferene when not given in first parameter. It is specified as subdivision_name in 模板链接:{{Infobox settlement}}, then passed as name to one of three display subtemplates.
  3. The third parameter is only specified by the /areadisp subtemplate, which passes the text area.

The default is to display metric units first, so the template only checks these parameters for values that would indicate the need to display non-metric units first:

  1. Imperial, English, UK, US, U.S., US Customary, U.S. Customary, Standard
  2. United Kingdom, [[United Kingdom]], United States, [[United States]], United States of America, [[United States of America]], [[United States|United States of America]]
  3. if this template is called by the /areadisp subtemplate, then it also checks parameter #1 for dunam (after converting it to lowercase)

Examples

Code Result
{{Infobox settlement/pref|metric_only| }} metric_only
{{Infobox settlement/pref|JP | }} metric_only
{{Infobox settlement/pref| |日本 }} metric_only
{{Infobox settlement/pref | | }} metric
{{Infobox settlement/pref | Imperial | }} impus
{{Infobox settlement/pref | UK | }} impus
{{Infobox settlement/pref | US | }} impus
{{Infobox settlement/pref | | 英國}} impus
{{Infobox settlement/pref | | 美國}} impus
{{Infobox settlement/pref|Dunam|Other|area}} dunam
{{Infobox settlement/pref|Dunam|Other}} metric
{{Infobox settlement/pref|Dunam|United Kingdom|area}}
In this example, the template never checks for "Dunam" because it previously
found that parameter #2 contained the name of a country using imperial units.
dunam

See also

上述文档内容嵌入自Template:Infobox settlement/pref/doc编辑 | 历史
编者可以在本模板的沙盒编辑和测试样例创建页面进行实验。
请将模板自身所属的分类添加在文档中。本模板的子页面