Jump to content
Toggle menu
  • 3 articles
  • 75 files
  • 7 users
  • 37.9K 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:Autotranslate/doc: Difference between revisions

Template page
duplicated argument
 
(68 intermediate revisions by 37 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Shared Template Warning|Template:Autotranslate|origin=Commons}}
This template is used to show a template in the users interface language.
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
{{Lua|Module:Autotranslate}}
{{TemplateBox
| 2 = ...
| 2d-en = Any additional parameter passed to {{tl|Autotranslate}} will be passed to {{tl|Autotranslate}}'s subtemplates. Parameter names are case independent and the subtemplates '''will only ''see lower case'' names'''.
| 2d-td-en = <nowiki>Any additional parameter passed to {{Autotranslate}} will be passed to {{Autotranslate}}'s subtemplates. Parameter names are case independent and the subtemplates **will only *see lower case* names**.</nowiki>
| 2stat = optional-
 
| 1 = base
| 1label-en = Translation parent page
| 1d-en = Parent page of the translated sub-pages. For example, if a template '''Foo''' keeps translations in sub-templates [[Template:Foo/en]], [[Template:Foo/de]], etc. then base is '''Template:Foo''', or just '''Foo'''. If a template '''Foo''' uses translation extension, then the language sub-templates will be most likely stored in  [[Template:Foo/i18n/en]], [[Template:Foo/i18n/de]], etc., then the base is '''Foo/i18n'''.
| 1type = wiki-template-name
| 1av  = {{((}}subst:PAGENAME{{))}}/i18n
| 1stat = required
 
| 3 = lang
| 3label-en = Language
| 3d-en = display language
| 3type = string
| 3def  = <code>{{Magic word|int|lang}}</code>
| 3def-td = <nowiki>{{int:lang}}</nowiki>
| 3stat = optional-
 
| 4 = default
| 4label-en = default
| 4d-en = default language sub-page which will be called in case all language sub-pages in the fallback chain are missing
| 4type = string
| 4def  = en
| 4def-td = en
| 4stat = optional-
 
| name = Autotranslate
| desc-en = This template is used as a part of the larger mechanism to show a template content in the user's interface language. It allows you to set up set of language subtemplates and call proper subtemplate based on users chosen language. All parameters passed to Autotranslate will be passed to the subtemplates. See [[Help:Autotranslate]] for help on the whole process. In most cases to use this template, you can use the following code snippet:
<pre style="overflow:auto">
{{#invoke:Autotranslate|autotranslate|base={{subst:PAGENAME}}/i18n}}
</pre>
 
| desc-td-en = This template is used as a part of the larger mechanism to show a template content in the user's interface language. It allows you to set up set of language subtemplates and call proper subtemplate based on users chosen language. All parameters passed to Autotranslate will be passed to the subtemplates. See “Help:Autotranslate” for help on the whole process.
 
| namespace = template
| usergroup = all
| placement = top
 
| i18n-method = -
| i18n-desc = Used by {{C|templates using Autotranslate for internationalisation}} and {{C|templates using the Translate extension for internationalisation}}.
 
| seealso =
* {{tl|LangSwitch}} for all-translations-on-one-page template i18n mechanism template.
* {{tl|Multilingual link}} chooses link to Wikipedia article in the user interface language.
 
| setscats = [[:Category:Autotranslated templates]]
| relieson = [[Module:Autotranslate]]
 
| print = multi
| useTemplateData = 1
}}


== How to convert a template ==
== How to convert a template ==
Line 6: Line 61:


=== Pick a template ===
=== Pick a template ===
First you have to pick a template to autotranslate. See [[User:Multichill/Template i18n]] for a list.
&mdash;See for example [http://commons.wikimedia.org/w/index.php?title=Template:Cc-by-1.0&oldid=12667239 Template:Cc-by-1.0 before changes].<br />
First you have to pick a template to autotranslate.<br />
''In this documentation, we will name our "selected template" as:'' <code>Template:<var>Template name</var></code>
*See [[Commons:Template i18n]] for a list of templates needing translation or translated.


=== Create a layout template ===
=== Create a layout template ===
If the template is not to difficult you should create a layout template to contain the layout of all language versions of the template. See for example [[Template:Cc-by-1.0/layout]].
&mdash;See for example [[Template:Apache/layout]].<br />
You must create a layout template, named <code>Template:<var>Template name</var>/layout</code>, to contain the layout of all language versions of the template. The easiest way to do this is to copy a layout template of a similar template.<br />
This template should not add any categories when transcluded.
This template should not add any categories when transcluded.


=== Modify the en language link ===
=== Convert existing language versions ===
Usually the English link points to the main template, point it to the /en subpage. See for example [[Template:Cc-by-1.0/en]]
&mdash;See for example [[Template:Apache/en]].<br />
All versions must be subpages of <code>Template:<var>Template name</var></code>, and this name must use the appropriate prefix, [[m:List_of_Wikipedias|as used on Wikipedia]] when adding a new language &ndash;ISO 639 language code&ndash;.
:For example, the Spanish subpage must be named <code>Template:<var>Template name</var>/es</code>
Usually the English-language template links to the main template &ndash;<code>Template:<var>Template name</var></code>&ndash;. This is incorrect, point it instead to the <code>Template:<var>Template name</var>/en</code> subpage.
 
Each language version of the template should be checked and converted to use the layout template &ndash;<code>Template:<var>Template name</var>/layout</code>&ndash;.<br />Start with the English language version and compare it to the current template.


=== Create a documentation page ===
Note that everything that is not supposed to be included together with the template, like <code><nowiki>{{translated tag|cleanup}}</nowiki></code> or <code><nowiki>{{documentation}}</nowiki></code>, must be inside a <code>&lt;noinclude&gt;</code> tag.
Create a documentation page at ''template name''/doc. This documentation page should include some code for creating language versions of the template. See for example [[Template:Cc-by-1.0/doc]]. Include this documentation in the main template by adding <nowiki>{{documentation}}</nowiki>


=== Convert existing language versions ===
Here is the syntax you must use for <code>Template:<var>Template name</var>/&lt;<var>prefix</var>&gt;</code>.
Each language version of the template should be checked and converted to use the layout template. Start with the English language versio and compair it to the current template.
<nowiki>{{</nowiki><code><var>Template name</var>/layout</code>
|text=&lt;''translated text of the template''&gt;
|lang=&lt;''prefix''&gt;
<nowiki>}}&lt;noinclude>
{{translated tag|license}}
&lt;/noinclude></nowiki>


Note that everything that is not supposed to be included together with the template, like “<nowiki>{{translated tag|cleanup}}</nowiki>” and documentation, must be inside a “<tt>&lt;noinclude&gt;</tt>” tag.
=== Create a documentation page ===
&mdash;See for example [[Template:Apache/doc]].<br />
Create a documentation page at <code>Template:<var>Template name</var>/doc</code>. This documentation page should include some code for creating language versions of the template. {{tl|TemplateBox}} has a <code>|il8n=autotranslate</code> option which provides a standard explanation of how to localise an autotranslated template.


=== Convert the main template ===
=== Convert the main template ===
&mdash;See for example [[Template:Apache]].<br />
The last step is to enable the template. Be sure to check everything before you enable the template. You can cause a really big mess!
The last step is to enable the template. Be sure to check everything before you enable the template. You can cause a really big mess!
To enable the template, put this code in the template for the layout part:
To enable the template, put this code in the template &ndash;<code>Template:<var>Template name</var></code>&ndash;.
<nowiki>{{Autotranslate|1={{{1|}}}|2={{{2|}}}|3={{{3|}}}|base=</nowiki>''template name''<nowiki>}}</nowiki>
<nowiki>{{#invoke:Autotranslate|autotranslate|</nowiki>base=<var>template name</var>}}
See for example [[Template:Cc-by-1.0]]
 
=== Protect templates ===
The main template page is probably already protected. You should probably also protect /layout, /lang & /en.
 
== Code snippet ==
To use this template, include the following code:


<PRE>
==See also==
{{Autotranslate|1={{{1|}}}|2={{{2|}}}|3={{{3|}}}|4={{{4|}}}|5={{{5|}}}|6={{{6|}}}|base={{subst:PAGENAME}}}}
{{#invoke:Autotranslate|autotranslate|base=I18n templates}}
</PRE>
<includeonly>{{Sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Internationalization templates]]
[[Category:Autotranslated templates| *]]
[[Category:Lua-based templates]]
}}</includeonly>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.