Шаблон:Percent/doc

Матеріал з Terraria Wiki
Перейти до навігації Перейти до пошуку

This template is used to apply a standard format to percentage values in an input string. It is mainly to be used inside other templates, and especially intended for proper localization of percentages, since different countries use different formats. Note that this means that the template may have no effect if used in the English wiki, since the input values are likely already in the correct English format.

Usage

{{ percent | <input string> }}

First unnamed parameter

The input string. The template will detect and process the following:

  • Percentages (natural and decimal, positive and negative)
  • Decimals (positive and negative)
  • Fractions (positive and negative)
  • Any other valid {{#expr:}} string

Notes

  • Decimals, fractions, and the results of other expressions will be rounded to two decimal places.
  • If the input string does not consist of any of the valid formats outlined above, a percentage sign will be simply be added to it.
  • The template is faster if the percentage sign is omitted. Therefore, if the input (or the result of it, if it is an expression) is purely numerical, the percentage sign should be left out.

Examples

Code Result
English German Turkish
{{percent|100%}} 100% 100 % %100
{{percent|16.67   %}} 16.67  % 16,67  % %16,67
{{percent|50% {{note|paren=y|Hardmode}} / {{eicons|1.3.0.1}} {{expert|12.5%}}}} 50% (Hardmode) / (Desktop, Console and Mobile versions) 12.5% 50 % (Hardmode) / (Desktop-, Konsolen- und Mobilversions) 12,5 % %50 (Hardmode) / (Desktop, Console and Mobile versions) %12,5
{{percent|1–3%}} 1–3% 1–3 % %1–3
{{percent|1.25–6.67%}} 1.25–6.67% 1,25–6,67 % %1,25–6,67
{{percent|0.12}} 12% 12 % %12
{{percent|2}} 200% 200 % %200
{{percent|1/8}} 12.5% 12,5 % %12,5
{{percent|22/39}} 56.41% 56,41 % %56,41
{{percent|(35/11 mod 2) - (10^-2 / ceil(21/6))}} 99.75% 99,75 % %99,75
{{percent|NaN}} NaN% NaN % %NaN