Template:Percent

来自Terraria Wiki
跳转到导航 跳转到搜索
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Percent/l10n for the localization of this template.
此模板使用了 Lua。
此模板使用了用 Lua 编程语言编写的 模块:Percent。要了解 Lua 的更多信息,参见 en:Terraria Wiki:Lua
Template-info.svg 文档 以下文档来自Template:Percent/doc。(编辑 | 历史

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) / (Desktopversion, Konsolenversion und Mobilversion) 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