Template:Convert/doc

From Teampedia
Jump to: navigation, search



Template:Convertを使用している記事一覧

Template purpose

This is a template for converting numbers with units to another unit and writing them together. For example, a unit of weightG(g)をグレーン(gr)という単位に置き換えるには、{{convert|10|g|gr}}Will write 10  (Expression error: Missing operand for *. ), side by side. Initially, when I copied the English version of the article, Template:FontIf 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.

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.{{convert2}}

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

変換 記法 表示 Convert Notation Show
kilometers to Miles {{convert|18.75|km|mi}} 18.75 kilometres (11.65070985 mi)
From kilogram to pound {{convert|3.215|kg|lb}} 3.215  (Expression error: Missing operand for *. )
単位を略号にする場合 {{convert|3.215|kg|lb|abbr=on}} 3.215  (Expression error: Missing operand for *. )
さらに単位の記事への内部リンクを作成 {{convert|3.215|kg|lb|lk=on|abbr=on}} 3.215 [[]] (Expression error: Missing operand for *. [[]])
表示を"/"区切りで並べる場合 {{convert|3.215|kg|lb|disp=s}} 3.215 /Expression error: Missing operand for *. 
単位の前に"-"を付ける場合 {{convert|3.215|kg|lb|adj=on}} 3.215  (Expression error: Missing operand for *. )
小数点以下1桁となるよう四捨五入する場合 {{convert|3.215|kg|lb|1}} 3.215  (Expression error: Unexpected round operator. )
(変換後の単位を省略すると、最も一般的な単位に変換する) {{Convert|7|lb}} 7  (Expression error: Missing operand for *. )
誤差を併記する場合 {{convert|60|+/-|10|m|ft}} 60  (Expression error: Unexpected round operator. )
複数単位への変換
(スペースで区切って並べる)
{{convert|1|R|C F K}} °R (Expression error: Missing operand for *. [[]])
Miles to Kilometers {{convert|10|mi|km}} 10 miles (16.09344 km)

注意

  • 上記のスイッチ(abbr=onとか)は、その組み合わせ毎にテンプレートを作っています。そのため、スイッチのon、offの組み合わせによっては新たにテンプレートを作成または移植する必要があります。
  • 複数単位への変換の場合もその組み合わせに対応するテンプレートを新たに作成する必要がある場合があります。


変換精度

変換後の精度は入力の精度に依存します。

入力の精度 記述例 表示
1 {{convert|1|R|K}} 1 °R (0.55555555555556 K)
1.0000 {{convert|1.0000|R|K}} 1.0000 °R (0.55555555555556 K)
1.00000000 {{convert|1.00000000|R|K}} 1.00000000 °R (0.55555555555556 K)

英語版から移植する場合の注意

{{convert/{{#ifeq:{{{4}}}|in|and/in|{{{d}}}}}|{{{1}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}|s={{{s|}}}|r={{{r}}}|d={{{d}}}
|u=ft
|n=foot
|l=feet
|t=Foot (length)
|o=m
|b=0.3048
|j=-0.515985037-0}}<noinclude>{{pp-template|small=yes}}
[[Category:Subtemplates of Template Convert]]
</noinclude>
となっています。そのままコピーしても一応動作しますが、
  • {{pp-template}}または{{pp-template|small=yes}}は、英語版で「影響が大きいため保護されているテンプレート」を意味しますので、日本語版では削除してください。(現在のところ、日本語版の{{pp-template}}は「何もしない」設定になっています。)
  • tで始まる引数(上の例では「t=Foot (length)」)は、単位の説明記事への内部リンクの記事名ですので、これは日本語版の相当する記事名(上の例では「フィート」)に変更する必要があります。引数tがない場合には引数nの文字で代用されます。
  • nで始まる引数とlで始まる引数(上の例では「n=foot」と「l=feet」)は、省略せずに(abbr=offで)書いた場合の表示単位です。引数nは結果が1(単数)の場合、引数lは結果が1以外の場合に表示されます。引数lを省略した場合で、結果が1以外の場合には、単位の末尾に複数形の「s」が付きます。そのため、引数nを日本語に訳す場合には、必ず引数lも定義してください(通常は引数nと同じ文字でよい)。
  • <noinclude></noinclude>の間に、英語版への言語間リンクを記載してください。
  • 上記の例の場合、例えば
{{convert/{{#ifeq:{{{4}}}|in|and/in|{{{d}}}}}|{{{1}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}|s={{{s|}}}|r={{{r}}}|d={{{d}}}
|u=ft
|Template:Font
|Template:Font
|Template:Font
|o=m
|b=0.3048
|j=-0.515985037-0}}<noinclude>
[[Category:Subtemplates of Template Convert]]
Template:Font
</noinclude>
とするとよいでしょう。