Template:Translatable template

(Redirected from Template:TNT)
Template documentationview · edit · history · purge ]

Purpose

This template is used to show translatable templates in the language of the current page. Templates, like all other MediaWiki pages, can be translated using the Translate extension, which creates subpages with the form "pagename/language code". The template first checks if the name of the page contains a language code. If it does, it then checks if the template name given as a first parameter has a translation in that language. If the page name does not contain a language code, or if the navigation template doesn't exist in that language, it will display the English template.


Help for choosing the right template for your use case:
I18n templates: {{Multilingual description|lang=
|de,en,default=Deutsch/English
|fr=français
|...
}}
{{de|Deutsch}}
{{en|English}}
{{fr|français}}
...
{{LangSwitch|lang=
|de,en,default=Deutsch/English
|fr=français
|...
}}
{{Autotranslate}} {{TNT}}
Recommended use at Categories, galleries File description pages (deprecated, can be safely replaced by {{Multilingual description}}) Small templates, whenever the previous options are not suitable (removes the visual indication of the language before each translated text) Data tables with translated cells or larger templates, when used on pages that do not have language subpages (e.g. not having Main page/en, Main page/de) and where the language displayed will be automatically determined by the language set in user preferences Data tables with translated cells or larger templates, when used on pages that do have language subpages; most of the time these will be pages prepared with the Translate Extension
Requires JavaScript enabled for folding Yes No
Folding can be disabled by user Yes No
Folding is done server-side No Yes
Folding when at least n languages are provided 1 (all translations are shown without folding if the preferred language selected by the user has no matching translation) 4 1
Detection of duplicate, incorrect, or unsupported language codes Yes No Yes
Allows the same translation to be used for several languages Yes No Yes
Supports language fallbacks No Yes No Yes
Collation order of languages (when not folded) Consistent order by native language name, languages grouped by script:
  • LTR scripts: Latin, Latin or Cyrillic, Cyrillic, Greek, other simple LTR alphabets (Armenian, Georgian, etc.), abugidas (North Indian, South Indian, other South-East Asian, etc.), syllabaries (European, American, African, Asian), Korean alphabets (basic Jamos, Hangul including some sinograms), Japanese syllabaries (including some sinograms), sinograms (including some syllabaries)
  • RTL scripts: Hebrew, Arabic, other RTL abjads (Divehi, etc.), RTL syllabaries (N'ko)
As provided by the user in the wikitext (any inconsistent order may be difficult to lookup visually) N/A
Search indexing issues No (all translations are included on the same page, however search results may be less relevant with many languages mixed) Yes (may not index all languages depending on search engines, unless there's a list of links for visiting other languages) Partially (where used; language subpages of templates are indexed) No (translated pages should include a <languages/> navigation bar for visiting other languages)
Page size issues Yes (may exhaust size or time limits in the wiki parser if many languages are included; larger pages to download for all visitors; slower navigation for visitors with slow Internet access; may be costly for visitors with limited data plans) No (only the content for the selected language or a suitable fallback language is present in the generated page)
Contains expensive parser functions No Yes (unless there's an editable /lang subpage listing all the existing translations selected with a {{LangSwitch}})

How to use

  • {{Translatable template|name of template|parameters....}}
  • {{TNT|name of template|parameters....}}
  • {{tnt|name of template|parameters....}}

The above simplied syntax cannot work if the named template also needs to be transcluded in other translatable templates, because it would cause self-recursion of {{Translatable template}}. An alternative is to use {{Translatable template name}} which does not expand the template with its parameters, but only returns the resolved template name, which can then be transcluded normally:

  • {{{{Translatable template name|name of template}}|parameters....}}
  • {{{{TNTN|name of template}}|parameters....}}
  • {{{{tntn|name of template}}|parameters....}}

Example (from Commons:Privacy policy):

{{Translatable template|Commons policies and guidelines}} or {{TNT|Commons policies and guidelines}}

which includes translated versions of {{Commons policies and guidelines}} if it exists, or the English version if translations don't exist.

Parameters

The current version of the template may now include any kind of named or numbered parameters, whose values will be transferred into the called template (with the exception of parameter 1 containing the basename of the translatable template to transclude). Numbered parameters will be shifted down by one position, all named parameters will be passed unchanged.

One named parameter is treated specially:

  • {{Translatable template|namespace=:somename:|page name|parameters....}}
  • {{TNT|namespace=:somename:|page name|parameters....}}
  • {{tnt|namespace=:somename:|page name|parameters....}}

This namespace will be used to specify another namespace from which the translatable pagename will be transcluded, instead of referencing the page name from the default :Template: namespace. Note that this parameter is also passed (without modification) within the parameters of the transclusion.

Example with one parameter (from meta:Global sysops):

  • {{TNT|:Special global permissions/Seealso|Global sysops}}

where "Global sysops" - is value of first unnamed parameter, transferred into called page meta:Special global permissions/Seealso.

See also