来自Terraria Wiki
跳转到导航 跳转到搜索

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:

|$collapsed$ = {{#if:{{{collapsed|}}}|mw-collapsed|}}
|$show-potion$ = {{#if:{{{show-potion|}}}||mw-collapsed}}

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:


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, es-formal), it will use /content; for languages within the main wiki (ar, bg, cs, da, el, es, fi, hi, id, it, ja, lt, lv, nl, no, ro, sk, sv, th, tr, vi, yue), 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.