Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Translatable template/doc: Difference between revisions

Template page
fix italics
No edit summary
Line 1: Line 1:
<noinclude>{{Documentation subpage}}</noinclude>
<noinclude>{{Documentation subpage}}</noinclude>
{{Shortcut|{{tl|TNT}}|{{tl|tnt}}}}


== Purpose ==
== Purpose ==
Line 15: Line 16:
* <code><nowiki>{{{{tntn|</nowiki>''name of template''<nowiki>}}|</nowiki>''parameters....''<nowiki>}}</nowiki></code>
* <code><nowiki>{{{{tntn|</nowiki>''name of template''<nowiki>}}|</nowiki>''parameters....''<nowiki>}}</nowiki></code>


Example (from [[Meta:Administrator]]):
Example (from [[Commons:Privacy policy]]):


: <code><nowiki>{{Translatable template|User groups}}</nowiki></code> or <code><nowiki>{{TNT|User groups}}</nowiki></code>
:<code><nowiki>{{Translatable template|Commons policies and guidelines}}</nowiki></code> or <code><nowiki>{{TNT|Commons policies and guidelines}}</nowiki></code>
which includes translated versions of {{tl|User groups}} if it exists, or the English version if translations don't exist.
which includes translated versions of {{tl|Commons policies and guidelines}} if it exists, or the English version if translations don't exist.


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


Example with one parameters (from [[Global sysops]]):
Example with one parameter (from [[Global sysops]]):
* <code><nowiki>{{TNT|Special global permissions/Seealso|Global sysops}}</nowiki></code>
* <code><nowiki>{{TNT|Special global permissions/Seealso|Global sysops}}</nowiki></code>
where the second parameter "Global sysops" is the value of the first numbered parameter transferred into called page "Special global permissions/Seealso".
where the second parameter "Global sysops" is the value of the first numbered parameter transferred into called page "Special global permissions/Seealso".
Line 36: Line 37:
* [[Module:Template translation]] (standard version)
* [[Module:Template translation]] (standard version)
* [[Module:Template translation/sandbox]] (used when this template is called with optional dummy parameter <code>sandbox=/sandbox</code>, for testng only)
* [[Module:Template translation/sandbox]] (used when this template is called with optional dummy parameter <code>sandbox=/sandbox</code>, for testng only)
== See also ==
== See also ==
* {{tl|Translatable template name}}, alias {{tl|TNTN}} or {{tl|tntn}}
* {{tl|Translatable template name}}, alias {{tl|TNTN}} or {{tl|tntn}}
Line 44: Line 46:
[[Category:Lua-based templates]]
[[Category:Lua-based templates]]
</includeonly>
</includeonly>
<templatedata>
{
"params": {
"1": {},
"sandbox": {},
"uselang": {},
"namespace": {},
"noshift": {},
"template": {}
}
}
</templatedata>

Revision as of 01:42, 13 January 2021

Shortcuts: [[:|{{TNT}}]] • [[:|{{Tnt}}]]

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.

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 Global sysops):

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

where the second parameter "Global sysops" is the value of the first numbered parameter transferred into called page "Special global permissions/Seealso".

Dependency

See also

No description.

Template parameters

ParameterDescriptionTypeStatus
11

no description

Unknownoptional
sandboxsandbox

no description

Unknownoptional
uselanguselang

no description

Unknownoptional
namespacenamespace

no description

Unknownoptional
noshiftnoshift

no description

Unknownoptional
templatetemplate

no description

Unknownoptional
Cookies help us deliver our services. By using our services, you agree to our use of cookies.