Help:制作导航模板

来自Terraria Wiki
IsConeNotConical讨论 | 贡献2020年8月9日 (日) 01:26的版本 (创建页面,内容为“{{Translation|needed}} When making a navigational template, please follow the process below to get good performance and facilita…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索
此页面的(部分)内容需要被翻译。
你可以帮助我们来翻译此页面

When making a navigational template, please follow the process below to get good performance and facilitate localization.

We will use {{gems}} as an example below.

Template skeleton[编辑源代码]

Here is a quick template for navigational templates:

{{navbox|key=<template_name>|purge=<noinclude>y</noinclude>
|$collapsed$ = {{#if:{{{collapsed|}}}|mw-collapsed|}}
|$show-potion$ = {{#if:{{{show-potion|}}}||mw-collapsed}}
}}<noinclude>{{i18n-ready}}{{doc}}<noinclude>

Some explanations:

  • The <template_name> is the index key for this navigational template, usually should be the name of this template (without "Template:"). For example, for Template:gems, it should be gems. Its value will be {{ucfirst:}}ed.
  • The |purge=<noinclude>y</noinclude> is used to purge the cache value when visit the template page directly. {{navbox}} uses LuaCache to improve performance; by doing this, we will always see the latest result.
  • Those $for$ are used to take input parameters to control whether the navbox itself or sections of navbox are collapsed.

For Template:gems, it should be:

{{navbox|key=gems|purge=<noinclude>y</noinclude>}}<noinclude>{{i18n-ready}}{{doc}}<noinclude>

The skeleton of this navigation template is complete. Now it is i18n-ready and benefits from the cache mechanism.

Next, we need to create its content.

Default (English) content[编辑源代码]

The default content of this navigation template should be in a /content subpage. For example, for Template:gems, it is Template:gems/content.

The default content should be in English. It will be used when the current wiki language is English, or when there is no l10n version for the current wiki language.

You can use |class = $placeholder$ in {{navbox/start}} to work with {{navbox}} to take collapsed control input.

L10n for other languages[编辑源代码]

Different languages will auto-use different content subpages. For English and languages with their own wiki (de, fr, hu, ko, ru, pl, pt, uk, zh), it will use /content; for languages within the main wiki (bg, cs, da, el, es, fi, id, it, ja, lt, lv, nl, no, sk, sv, th, tr, vi), it will use /content/<langcode>. This facilitates easy localization of the content without modifying the transclusion code, and the content of different languages will not conflict with each other, and the English version is automatically used as a fallback for languages without an l10n version.

You can follow this process for l10n:

  1. Transclude the navigation template on any page of your language. For example, use {{gems}} on Amber/it, and submit.
  2. Click the "e" link at the top left corner of the navbox; it will take you to the right content subpage for your language. If it does not exist yet, it will be pre-filled with the English version as the basis for translation.