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:Autotranslate/doc: Difference between revisions

Template page
mNo edit summary
duplicated argument
 
(56 intermediate revisions by 28 users not shown)
Line 1: Line 1:
文件子( ( ) )
{{Shared Template Warning|Template:Autotranslate|origin=Commons}}
这个模板是用来显示一个模板中的用户界面语言。
<!-- 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
  ,例如见[ http://commons.wikimedia.org/w/index.php?title=Template:Cc-by-1.0&oldid=12667239模板:抄送按1.0之前的变化] 。 <br />  
| 3label-en = Language
首先,您必须选择一个模板,自动翻译。 <br />  
| 3d-en = display language
''本文档中,我们将我们的名字“选择模板”为: ''的<code> [ [模板:模板名称|模板: <var>模板名称“ /无功>]]</代码”
| 3type = string
*见[ [商品:模板本土化] ]的列表模板需要翻译或翻译。
| 3def = <code>{{Magic word|int|lang}}</code>
| 3def-td = <nowiki>{{int:lang}}</nowiki>
| 3stat = optional-


===创建布局模板===  
| 4 = default
看到例如[ [范本: Cc-by-1.0/layout ] ] 。 <br />
| 4label-en = default
您必须创建一个布局模板,名为<code> [ [模板:模板名称/布局|模板: <var>模板名称“ /无功” /布局] ] “ /代码” ,以遏制布局的所有语言版本的范本。 <br />
| 4d-en = default language sub-page which will be called in case all language sub-pages in the fallback chain are missing
此模板不应添加任何类别时transcluded 。
| 4type = string
| 4def  = en
| 4def-td = en
| 4stat = optional-


在此网页,您必须添加代码,使模板识别自动翻译时,可用:
| name = Autotranslate
 的<code> <nowiki> ( (自动翻译/语言| ( (物质:名字空间}}:{{物质: BASEPAGENAME }}}}</ nowiki “ ” /代码“
| 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.
看到例如[ [范本: Cc-by-1.0/en ] ] 。 <br />
所有版本必须子的<code> [ [模板:模板名称|模板: <var>模板名称“ /无功>]]</代码” ,他的名字必须使用适当的前缀, [ [男: List_of_Wikipedias |为维基百科上使用] ]当添加一个新的语言, ISO 639语言代码。 Posibilities列[ [范本:自动翻译/语言/文件# Supported_languages |这里] ] 。例如,西班牙子必须名为<code> [ [模板:模板名称/中心|模板: <var>模板名称“ /无功” /中心] ] “ /代码” <br />通常英文链接主要范本-的<code>模板: <var>模板名称“ /无功” “ /代码” -.这是不正确的,指向它的<code> [ [模板:模板名称/恩|模板: <var>模板名称“ /无功” /英文] ] “ /代码”子。


每个语言版本的模板应检查并转换为使用布局模板-的<code> [ [模板:模板名称/布局|模板: <var>模板名称“ /无功” /布局] ] “ /代码” & ndash ; 。首先是英文版本,并进行比较,以目前的范本。
| namespace = template
| usergroup = all
| placement = top


请注意,这是不应该包括与模板,类似<code> <nowiki> ( (翻译标记|清理) ) “ / nowiki ” “ /代码”或<code>文件<nowiki> ( ( ) ) “ / nowiki ” “ /代码” ,必须在一个<code> <noinclude> “ /代码”标记。
| i18n-method = -
| i18n-desc = Used by {{C|templates using Autotranslate for internationalisation}} and {{C|templates using the Translate extension for internationalisation}}.


这是sintaxis您必须使用的<code> [ [模板:模板名称/恩|模板: <var>模板名称“ /无功” / “ <var>前缀” /无功>>]]</代码“ ,其中<code> “ <var>前缀” /无功“ ” “ /代码”是[ [范本:自动翻译/语言/文件# Supported_languages |一本] ] 。
| seealso =  
  <nowiki> ( ( “ / nowiki ”的<code> [ [模板:模板名称/布局|模板: <var>模板名称“ /无功” /布局] ] “ /代码”
* {{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.
  |郎= “ ''前缀'' ”
  <nowiki> ) ) “ / nowiki ” <br /> <nowiki> <noinclude> ( ( “ / nowiki ”翻译标记|许可证<nowiki> ) ) “ / noinclude ” “ / nowiki ”


===创建一个文件页===  
| setscats = [[:Category:Autotranslated templates]]
看到例如[ [范本: Cc-by-1.0/doc ] ] 。 <br />
| relieson = [[Module:Autotranslate]]
创建一个文件页面在<code> [ [模板:模板名称/文件|模板: <var>模板名称“ /无功” /文件] ] “ /代码” 。这页的文件应包括一些代码创造语言版本的模板。


===转换主要范本===  
| print = multi
看到例如[ [范本:抄送按1.0 ] ] 。 <br />
| useTemplateData = 1
最后一步是使模板。请务必检查前的所有启用范本。您可能会导致真正的大混乱!
}}
为了使模板,把这个代码模板-的<code> [ [模板:模板名称|模板: <var>模板名称“ /无功>]]</代码” -.
  <nowiki> ( (自动翻译| 1 = ( ( ( 1 |}}}| 2 = ( ( ( 2 |}}}| 3 = ( ( ( 3 |}}}|基地= “ / nowiki ” ''模板名称'' <nowiki> ) ) “ / nowiki ”
  <nowiki>文件<noinclude> ( ( ) ) “ / noinclude ” “ / nowiki ”


===保护模板===  
== How to convert a template ==
主要范本网页很可能已受到保护。你或许应该也保护的<code> /布局“ /代码”和<code> /恩“ /代码” 。
Before you apply this template, first you have to prepare the template.


== ==代码段
=== Pick a template ===
要使用此模板,包括下面的代码:
&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 />
<PRE> ( (自动翻译| 1 = ( ( ( 1 |}}}| 2 = ( ( ( 2 |}}}| 3 = ( ( ( 3 |}}}| 4 = ( ( ( 4 | ) ) ) | 5 = ( ( ( 5 |}}}| 6 = ( ( ( 6 |}}}| 7 = ( ( ( 7 |}}}| 8 = ( ( ( 8 |}}}| 9 = ( ( ( 9 | ) ) )
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 ===
&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.
 
=== Convert existing language versions ===
&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.
 
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.
 
Here is the syntax you must use for <code>Template:<var>Template name</var>/&lt;<var>prefix</var>&gt;</code>.
<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>
 
=== 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 ===
&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!
To enable the template, put this code in the template &ndash;<code>Template:<var>Template name</var></code>&ndash;.
<nowiki>{{#invoke:Autotranslate|autotranslate|</nowiki>base=<var>template name</var>}}
 
==See also==
{{#invoke:Autotranslate|autotranslate|base=I18n templates}}
<includeonly>{{Sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Internationalization templates]]
[[Category:Autotranslated templates| *]]
[[Category:Lua-based templates]]
}}</includeonly>

Latest revision as of 15:59, 29 June 2025

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:

{{#invoke:Autotranslate|autotranslate|base={{subst:PAGENAME}}/i18n}}

The template automatically sets the following categories: Category:Autotranslated templates

Usage

{{Autotranslate
 |base =
}}

Template parameters

ParameterDescriptionDefaultStatus
baseTranslation parent pageParent 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.emptyrequired
...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.emptyoptional
langLanguagedisplay language{{int:lang}}optional
defaultdefaultdefault language sub-page which will be called in case all language sub-pages in the fallback chain are missingenoptional
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-specific information

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.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
...

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**.

Unknownoptional
Translation parent pagebase

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'''.

Auto value
{{subst:PAGENAME}}/i18n
Templaterequired
defaultdefault

default language sub-page which will be called in case all language sub-pages in the fallback chain are missing

Default
en
Stringoptional
Languagelang

display language

Default
{{int:lang}}
Stringoptional

Additional information

The template is intended to be used in the following namespaces: the Template namespace

The template is intended to be used by the following user groups: all users

Placement: At the top of the page

Relies on:
Module:Autotranslate

See also

Localization

This template is not intended to be localized.

How to convert a template

Before you apply this template, first you have to prepare the template.

Pick a template

—See for example Template:Cc-by-1.0 before changes.
First you have to pick a template to autotranslate.
In this documentation, we will name our "selected template" as: Template:Template name

Create a layout template

—See for example Template:Apache/layout.
You must create a layout template, named Template:Template name/layout, 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.
This template should not add any categories when transcluded.

Convert existing language versions

—See for example Template:Apache/en.
All versions must be subpages of Template:Template name, and this name must use the appropriate prefix, as used on Wikipedia when adding a new language –ISO 639 language code–.

For example, the Spanish subpage must be named Template:Template name/es

Usually the English-language template links to the main template –Template:Template name–. This is incorrect, point it instead to the Template:Template name/en subpage.

Each language version of the template should be checked and converted to use the layout template –Template:Template name/layout–.
Start with the English language version and compare it to the current template.

Note that everything that is not supposed to be included together with the template, like {{translated tag|cleanup}} or {{documentation}}, must be inside a <noinclude> tag.

Here is the syntax you must use for Template:Template name/<prefix>.

{{Template name/layout
|text=<translated text of the template>
|lang=<prefix>
}}<noinclude>
{{translated tag|license}}
</noinclude>

Create a documentation page

—See for example Template:Apache/doc.
Create a documentation page at Template:Template name/doc. This documentation page should include some code for creating language versions of the template. {{TemplateBox}} has a |il8n=autotranslate option which provides a standard explanation of how to localise an autotranslated template.

Convert the main template

—See for example Template:Apache.
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 –Template:Template name–.

{{#invoke:Autotranslate|autotranslate|base=template name}}

See also

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}})
Cookies help us deliver our services. By using our services, you agree to our use of cookies.