Jump to content


From Meta, a Wikimedia project coordination wiki
This page is a translated version of the page Meta:Internationalization guidelines and the translation is 16% complete.

元維基致力於成為一個多語言的維基,因此預期大部分頁面將能夠被翻譯。為了能通過翻譯擴充功能進行翻譯,一頁應當被標記為 <translate>...</translate>(即「國際化」),接著被一名翻譯管理員「標記為翻譯」。本頁面旨在提出元維基上 「頁面國際化準則」




  • 如果您想將一個列表分割成幾個單元,您不應在應該成為一個單元的文本內加入換行。同時,您也應該將項目符號或編號的井字號從translate標籤中排除。
  • 如果您在模板呼叫的參數值內插入一個translate標籤,請確保該參數已命名(否則添加一個數值,如1=)。


需要改善的語法 優良語法
== <translate>章節段落</translate> ==
<translate>This is a paragraph.</translate>

<translate>This is another paragraph.</translate>


== <translate>Another heading<translate> ==
== 章節段落 ==

This is a paragraph.

This is another paragraph.


== Another heading ==
* This is a long list:
** There are more than 160 words in this list,
** or there are more than 8 items.
* So it is better to split it in several smaller units.
* But we must exclude bullet points from translate tags to keep the list accessible.
* <translate>This is a long list:</translate>
** <translate>There are more than 160 words in this list,</translate>
** <translate>or there are more than 8 items.</translate>
* <translate>So it is better to split it in several smaller units.</translate>
* <translate>But we must exclude bullet points from translate tags to keep the list accessible.</translate>

Specific elements


Any page which could be translated should be linked with Special:MyLanguage/ prefix, even if it not actually internationalized. The main pages which do not need this prefix are talk pages and templates without textual content. To make translation easier, please wrap target of internal links inside <tvar name=1> … </tvar> (tvar name can be a number only, this is sufficient).

For links to Wikipedia article, you should use {{lwp}} template for the target and wrap it inside a tvar. E.g. [[{{lwp|Rosa Parks}}</tvar>]] produces en:Rosa Parks in English pages and fr:Rosa Parks in French pages.

For other cross-wiki and external links, if a translation exists, you should not put the link target inside tvar. Of course, if the target website has a language detection system (like MediaWiki's Special:MyLanguage/), you may use this system and put the full link inside tvar.

需要改善的語法 優良語法
This is a text with an [[internal link]] and an [https://openstreetmap.org external link].
This is a text with an [[<tvar name=1>Special:MyLanguage/internal link</tvar>|internal link]] and an [<tvar name="url">https://openstreetmap.org</tvar> external link].


You should exclude category declarations from translate tags. Instead, add {{#translation:}} after the category name: [[Category:Target category{{#translation:}}]]. This way, only the main English page is categorized into the target categories, translation pages are categorized in per-language categories.

需要改善的語法 優良語法


Thumbs and large images

If the image can be localized (e.g. it contains some text and a translated version exists), it should be fully included in translate tags.

Else, you should only wrap alt= value in <translate nowrap> tags and caption in <translate> tags.

If left or right is used as image parameter: remove it if it is useless (thumbnails default to right in English), or replace it respectively with {{dirstart}} or {{dirend}}.

需要改善的語法 優良語法
[[File:landscape.jpg |thumb |left |alt=sunset |Photo of a beautiful landscape]]
[[File:landscape.jpg |thumb |{{dirleft}} |alt=<translate nowrap>sunset</translate> |<translate>Photo of a beautiful landscape</translate>]]
[[File:English Wikipedia screenshot.png|thumb|right|<translate>Wikipedia homepage</translate>]]
[[File:English Wikipedia screenshot.png|thumb|Wikipedia homepage]]


Inline icons may be simply wrapped in a <tvar name="img">.

需要改善的語法 優良語法
[[File:pretty hello word.png|alt=Hello]] everybody! [[File:smiley.png|alt=🙂]] How are you?
[[File:pretty hello word.png|alt=Hello]] everybody! <tvar name="icon">[[File:smiley.png|alt=🙂]] How are you?

Translation variables

Translation variables (<tvar name="name"></tvar> syntax) should be used to hide text from translators in order to prevent them from translating it.

The following examples should be wrapped inside tvar:

  • automatically-localized or non-localizable link targets,
  • 用户名,
  • numbers likely to change (they should be wrapped inside {{formatnum:}} then inside tvar),
  • tag attributes (e.g. <span class="css_class" style="background-color:blue"</tvar>>hello</span>),
  • template name and parameters (e.g. {{<tvar name=1>center|5px</tvar>|hello}}),
  • parts of complex wikitext or HTML (but please ensure the resulting wikitext for translators is balanced).

The following examples should not be wrapped inside tvar:

  • people and place names (even if they are rarely translated, they may be transliterated),
  • XML tags without attributes, like <code> (the translation interface handles them),
  • localizable link targets (i.e. links to multilingual website).

Translation variable names

To help translators, please keep tvar names as short and readable as possible. If translators don’t need to know their content, using numbered names is a good idea because digits are quick to type for most translators and are common in many languages (so that most beginners do not accidentally translate them).

However if tvar is inside a sentence, it should have an explicit name to allow translators to understand what it contains and so write it easily in the right place in their translation (it is pretty common for an email address, URL, wikitext tag name…).

需要改善的語法 優良語法
[[<tvar name="HelpLink">Special:MyLanguage/Help:Links|See help page]]
[[Special:MyLanguage/Help:Links|See help page]]
The meeting will take place on <tvar name=1>{{dateT||9|24}}</tvar> on <tvar name=2>{{int string|Zoom}}</tvar>.
The meeting will take place on <tvar name="date">{{dateT||9|24}}</tvar> on <tvar name="software">{{int string|Zoom}}</tvar>.

Avoid using spaces, underscores or letters with diatrics in tvar names as well.

需要改善的語法 優良語法
<tvar name="max_count of café">84</tvar> cafés
<tvar name="max-count">84</tvar> cafés


You may prepare a template for translation like any page, but you should ensure the “为该页面启用翻译感知嵌入” checkbox is checked when you mark the page for translation.

If your template is expected to be included in non-translatable pages (e.g. user pages) and should be even translated in these pages, you can use the pre-2021 hack with switch, replacing uselang={{PAGELANGUAGE}} with uselang={{int:lang}} in the code shown below.

Pre-2021 hacks

Before MediaWiki 1.36.0-wmf.32 (2021-02-23), you should ensure English pages include the /en subpage of a template instead of a template directly.

One way was to replace each occurrence of {{my translated template|param}} with {{TNT|my translated template|param}}, except in templates or transcluded pages which should contain {{ {{TNTN|my translated template}} |param}} instead.

Another way was to edit the template to make it call itself {{TNT}}. To this end, you should put the full template code inside a switch which evaluated an empty translate tag, with a default case which called {{TNT}}.

|=<span lang="en" dir="ltr" class="mw-content-ltr"><full template code></span>
|#default={{#invoke:Template translation|renderTranslatedTemplate|template={{subst:FULLPAGENAME}}|uselang={{PAGELANGUAGE}}|noshift=1}}

See also