Changes

Jump to: navigation, search

Template:Convert/doc

11,250 bytes added, 18:36, 10 April 2020
no edit summary
<noinclude>{{Documentation subpage|種類=[[Help:テンプレート|テンプレート]]}}</noinclude><includeonly>{{複雑なテンプレート}}{{#ifeq:{{#titleparts:{{FULLPAGENAME}}|1|}}|Template:Convert2|{{混同|Template:Convert|x1=機能と使用法はほぼ同じですが、テンプレート版の}} {{lua|モジュール:Convert}}|{{混同|Template:Convert2|x1=機能と使用法はほぼ同じですが、Luaモジュールを使用している}}}}</includeonly>__NOTOC__{{Infobox| title = | data1 = {{Infobox | child = yes | title = [[Special:Whatlinkshere/{{#titleparts:{{FULLPAGENAME}}|1|}}{{!}}{{#titleparts:{{FULLPAGENAME}}|1|}}を使用している記事一覧]] | label1 = | data1 = }}| below = <!--最下部テキスト-->}}==Template purpose==This is a template converts measurements from one for converting numbers with units to another unit and presents writing them together. For example, a unit of weight[[G]](g)を[[グレーン]](gr)という単位に置き換えるには、<nowiki>{{convert|10|g|gr}}</nowiki>Will write {{convert|10|g|gr}}, side by side.Initially, when I copied the resultsEnglish version of the article,{{font|color=red|Template:Convert/DWton}}If it appears like this, it means that the internal template has not been ported to the English version yet, and to display it, you may need to port it yourself or wait for someone to port it. did. In addition, in some cases, multiple templates had to be ported, even if it appeared to be a single template.
For example:If it appears like this, it means that the internal template has not been ported to the Japanese version yet, and to display it, you may need to port it yourself or wait for someone to port it. did. In addition, in some cases, multiple templates had to be ported, even if it appeared to be a single template.
However, the English version of Wikipedia has shifted to using Lua modules, and internal templates are no longer used.{{ttl|convert|1|km|mi}} → {{convert|1|km|mi}}<br>{{t|convert|7|mi|km}} → {{convert|7|mi|kmconvert2}}
;UsageBasic examples:It is better to rewrite it.
This template is used relatively frequently in the English version. When creating a new conversion formula, make sure that there are no similar templates in the English version. In particular, do not create a template with the same title as the English version but another meaning.
==Example==
<!--For a single number:--><!-- Left character, omit until you write an example of the range-->
{| class="wikitable"
!変換!!記法!!表示
!Convert!!Notation!!Show
|-
||kilometers to Miles||<nowiki>{{convert|18.75|km|mi}}</nowiki>||{{convert|18.75|km|mi}}
|-
|From kilogram to pound||<nowiki>{{convert|3.215|kg|lb}}</nowiki>||{{convert|3.215|kg|lb}}
|-
|単位を略号にする場合||<nowiki>{{convert|3.215|kg|lb|abbr=on}}</nowiki>||{{convert|3.215|kg|lb|abbr=on}}
|-
|さらに単位の記事への内部リンクを作成||<nowiki>{{convert|3.215|kg|lb|lk=on|abbr=on}}</nowiki>||{{convert|3.215|kg|lb|lk=on|abbr=on}}
|-
|表示を"/"区切りで並べる場合||<nowiki>{{convert|3.215|kg|lb|disp=s}}</nowiki>||{{convert|3.215|kg|lb|disp=s}}
|-
|単位の前に"-"を付ける場合||<nowiki>{{convert|3.215|kg|lb|adj=on}}</nowiki>||{{convert|3.215|kg|lb|adj=on}}
|-
|小数点以下1桁となるよう四捨五入する場合||<nowiki>{{convert|3.215|kg|lb|1}}</nowiki>||{{convert|3.215|kg|lb|1}}
|-
|(変換後の単位を省略すると、最も一般的な単位に変換する)||<nowiki>{{Convert|7|lb}}</nowiki>||{{Convert|7|lb}}
|-
|誤差を併記する場合||<nowiki>{{convert|60|+/-|10|m|ft}}</nowiki>||{{convert|60|+/-|10|m|ft}}
|-
|複数単位への変換<br/>(スペースで区切って並べる)||<nowiki>{{convert|1|R|C F K}}</nowiki>||{{convert|1|R|C F K|lk=on}}
|}
'''注意'''
*上記のスイッチ(abbr=onとか)は、その組み合わせ毎にテンプレートを作っています。そのため、スイッチのon、offの組み合わせによっては新たにテンプレートを作成または移植する必要があります。
*複数単位への変換の場合もその組み合わせに対応するテンプレートを新たに作成する必要がある場合があります。
 
<!--まだ赤リンクばかりだから省略
範囲の指定:
{| class="wikitable"
|'''Input'''||'''Displays as'''
|-
|<nowiki>{{convert|3.2160|and|170|kg|lb}}</nowiki>||{{convert|3.2160|and|170|kg|lb}}
|-
|<nowiki>{{convert|3.2160|to|170|kg|lb|0}}</nowiki>||{{convert|3.2160|to|170|kg|lb|0}}
|-
|<nowiki>{{convert|1060|to(-)|170|kg|lb|disp=or}}</nowiki>||{{convert|1060|to(-)|170|kg|lb|disp=or}}
|-
|<nowiki>{{convert|660|ft-|5170|inkg|mlb}}</nowiki>||{{convert|660|ft-|5170|inkg|mlb}}<!--This is currently broken
|-
|<nowiki>{{convert|260|by|120|m|ftinft}}</nowiki>||{{convert|260|by|120|m|ftinft}}-->
|-
|<nowiki>{{convert|1060|mix|120|m|ft}}</nowiki>||{{convert|1060|x|120|m|mift}}
|-
|<nowiki>{{convert|10060|mpgus+/-|10|m|ft}}</nowiki>||{{convert|10060|mpgus+/-|10|m|ft}}|}--> ===変換精度===変換後の精度は入力の精度に依存します。 {| class="wikitable"!入力の精度!!記述例!!表示
|-
|1||<nowiki>{{convert|1201|km/hR|K}}</nowiki>||{{convert|1201|km/hR|K}}
|-
|1.0000||<nowiki>{{convert|181.0000|°CR|°FK}}</nowiki>||{{convert|181.0000|°CR|°FK}}
|-
|1.00000000||<nowiki>{{convert|-151.00000000|CR|FK}}</nowiki>||{{convert|1.00000000|R|K}}|} ==英語版から移植する場合の注意==*通常の移植と同様に、[[Wikipedia:FAQ 翻訳]]、[[Wikipedia:翻訳のガイドライン]]をよくお読みのうえ、要約欄に必要事項を記載してください。以下はそれに付け加えての注意です。 *[[:en:Template:Convert/ft]](21:37, 29 March 2008の版)を例にとると、ソースは::<nowiki>{{convert/{{#ifeq:{{{4}}}|in|and/in|{{{d}}}}}|{{{1}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}|s={{{s|}}}|r={{{r}}}|d={{{d}}}</nowiki>::|u=ft ::|n=foot::|l=feet::|t=Foot (length)::|o=m::|b=0.3048::|j=-150.515985037-{{{j|C0}}}}}<nowiki><noinclude>{{pp-template|Fsmall=yes}}</nowiki>::<nowiki>[[Category:Subtemplates of Template Convert]]</nowiki>::<nowiki></noinclude></nowiki>:となっています。そのままコピーしても一応動作しますが、:*<nowiki>{{pp-template}}または{{pp-template|small=yes}}</nowiki>は、英語版で「影響が大きいため保護されているテンプレート」を意味しますので、日本語版では削除してください。(現在のところ、日本語版の<nowiki>{{pp-template}}</nowiki>は「何もしない」設定になっています。):*tで始まる引数(上の例では「t=Foot (length)」)は、単位の説明記事への内部リンクの記事名ですので、これは日本語版の相当する記事名(上の例では「[[フィート]]」)に変更する必要があります。引数tがない場合には引数nの文字で代用されます。:*nで始まる引数とlで始まる引数(上の例では「n=foot」と「l=feet」)は、省略せずに(abbr=offで)書いた場合の表示単位です。引数nは結果が1(単数)の場合、引数lは結果が1以外の場合に表示されます。引数lを省略した場合で、結果が1以外の場合には、単位の末尾に複数形の「s」が付きます。そのため、引数nを日本語に訳す場合には、必ず引数lも定義してください(通常は引数nと同じ文字でよい)。:*<nowiki><noinclude></noinclude></nowiki>の間に、英語版への言語間リンクを記載してください。:*上記の例の場合、例えば::<nowiki>{{convert/{{#ifeq:{{{4}}}|in|and/in|{{{d}}}}}|{{{1}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}|s={{{s|}}}|r={{{r}}}|d={{{d}}}</nowiki>::|u=ft ::|{{font|color=red|n=フィート}}::|{{font|color=red|l=フィート}}::|{{font|color=red|t=フィート}}::|o=m::|b=0.3048::|j=-0.515985037-{{{j|0}}}}}<nowiki><noinclude></nowiki>::<nowiki>[[Category:Subtemplates of Template Convert]]</nowiki>::{{font|color=red|<nowiki>[[en:Template:Convert/ft]]</nowiki>}}::<nowiki></noinclude></nowiki>:とするとよいでしょう。<!--===Tricks==={| class="wikitable"
|-
|<nowiki>{{convert|9|e6USgal|abbr! colspan=off}}</nowiki>"2" ||{{convert|9|e6USgal|abbr=off}}<brbig>The "e6" scales the input '''In order to millions; the "abbr=off" yields the "mega" in the output...'''<br/big>Scaling is only available for Single value conversions. Not all units are supported.
|-
| Use [[United States|US]] spelling || attach <code><nowiki>{{convert|1250|sqft|m2|lk=in|sigfigsp=2}}us</nowiki> ||{{convert|1250|sqft|m2|lk=in|sigfig=2}}<br/code>
|-
|Make units [[Wikipedia:Manual of Style (links)|wikilinked]] || attach <code><nowiki>{{convert|20.5|m3|cuyd|lk=out|abbr=on}}</nowiki>||{{convert|20.5|m3|cuyd|1</code> to link all units<br> attach <code><nowiki>|lk=out|abbr=on}}in<br/nowiki>Note '</code> to link only the input units<br> attach <code><nowiki>|lk=out' links </nowiki></code> to link only the output unit, units<br>(The [[cu ydWikipedia:Only make links that are relevant to the context|manual of style]]suggests that you should not link common units of measurement).
|-
|Use the adjective form || attach <code><nowiki>{{convert|641|acre|ha sqmi|lkadj=on}}</nowiki></code> (e.g. "The 190-foot (58 m) bridge" as opposed to "The 190 feet..."). This produces the adjective form—the unit name in the singular with a hyphen (according to the [[WP:HYPHEN||{{convert|641|acre|ha sqmi|lk=on}}Manual of Style]]).
|-
|Abbreviate all units || attach <code><nowiki>{{convert|641abbr=on</nowiki></code>|acre-|ha sqmiUse a / instead of ( ) |2|lkattach <code><nowiki>|disp=on}}s</nowiki></code> (or <code><nowiki>|disp=/</nowiki></code>) (e.g. 190&nbsp;foot/58&nbsp;metre). Note that when using slashes all unit names either spelt out in full or abbreviated (where there exists an abbreviation).|{{convert-|641Use in a table |acre|ha sqmiattach <code><nowiki>|2disp=table</nowiki></code> Note: For use in tables the template must start on a new line after a pipe. Only the number will be displayed unless you set <code><nowiki>|abbr=on</nowiki></code>, <code><nowiki>|lk=on}</nowiki></code>, <code><nowiki>|lk=in</nowiki></code> or <code><nowiki>|lk=out</nowiki></code>. Example: [[Phnom_Penh#Highways_in_Phnom_Penh|here]]|-| Round to a specified number of significant figures|| attach <code><nowiki>|sigfig={some non-negative integer}<br/nowiki> Although 640 acres equals 1 square mile; 641 acres rounded </code>. In the case of temperatures Celsius or Fahrenheit this refers to the difference with the absolute-zero temperature. For example, at room temperature two decimal places equals 1significant digits means rounded to tens of degrees.00&nbsp;sq&nbsp;|-| Let ''Convert'' decide the unit to convert to|| skip the ''convert to'' parameter (which would otherwise be third unnamed parameter) e.g. <code><nowiki>{{convert|100|mi|0}}</nowiki></code> gives ''{{convert|100|mi|0}}''.
|}
More documentation can be found at [[wikipedia:Template:===Rounding===''Convert'' supports four types of rounding.;Rounding to a given precision :Specify the desired precision with the fourth unnamed parameter or third unnamed parameter in the case where the ''convert to'' parameter is skipped (see above). The conversion is rounded off to the nearest power of 1/doc]]10 this number. For instance, if the result is 8621 and the round number is '-2', the result will be 8600. If the result is '234.0283043' and the round number is '0', the result will be 234.
;Rounding to a given number of significant figures:Specify the desired number of significant figures using <includeonlycode>[[Category<nowiki>|sigfig={some non-negative integer}</nowiki></code> as noted above. ;Combine both of the above:Experimental templatesIf both the desired precision and the desired number of significant figures are specified, the conversion will be rounded to the least precise of these. ;Default rounding:If neither the desired precision nor the desired number of significant figures are specified, the conversion will be rounded either to a comparable precision as the input value (the number of decimals remains the same if the conversion is a multiplication by a number between 0.2 and 2, is decreased by 1 if the factor is between 2 and 20, etc.) or to two significant figures whichever is the most precise. An exception to this is temperature wherein the conversion will be rounded either to precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvin, whichever is the most precise. ==Units supported by <nowiki>{{Convert}}</nowiki>==The table below lists units supported by this template. It is divided up according to the quantity being measured. Not all supported units are listed here, there are links to complete lists for each quantity. The codes listed in the ''code'' column (column 3) are accepted as input by the template.These can be used as the second or third unnamed parameter. For some units there exist alternative codes. These are listed in brackets and have been incorporated to make the code more flexible for editors, e.g. °F ''or'' F may be entered. The codes listed in the ''combinations'' column (column 7) can be used to produce multiple conversions. They can only be used as the third unnamed parameter, e.g. <code><nowiki>{{convert|55|nmi|km mi}}</nowiki></code> produces ''{{PAGENAMEconvert|55|nmi|km mi}}]]''. Without box: [[CategoryTemplate:Inline templatesConvert/list of units]]. </includeonlydiv style="height: 400px; overflow: auto; padding: 3px; border:1px solid #AAAAAA; reflist4" >{{Convert/list of units}}<noinclude/div==Example/monitor page==Monitor quality or look at examples at [[CategoryTemplate:Convert/check]] ==See also==* {{tl|Inflation}} template for calculating inflated prices in USA, UK and other countries.--><includeonly>{{#ifeq:{{#titleparts:{{FULLPAGENAME}}|1|}}|Template documentation:Convert2|{{PAGENAMENavbox Convert|2}}|{{Navbox Convert|1}}}}<!-- カテゴリーはここに記載する -->{{DEFAULTSORT:Convert}}[[Category:単位関連のテンプレート]][[Category:数学関数テンプレート]][[Category:特殊効果テンプレート]][[Category:変換テンプレート]]</noincludeincludeonly>



Navigation menu