Meta:国际化指引
元維基致力於成為一個多語言的維基,因此預期大部分頁面將能夠被翻譯。為了能通過翻譯擴充功能進行翻譯,一頁應當被標記為 <translate>...</translate>(即「國際化」),接著由一名翻譯管理員「標記為翻譯」。本頁面旨在提出元維基上 「頁面國際化準則」 。
For a step-by-step guide to marking a page for translation, see the tutorial.
一般提醒:當翻譯已經完成時,請忍住不要進行任何可能讓它們過時的編輯,即使這個 <translate>標記並不符合這些準則,也是如此。 This would place an unnecessary burden on our translators, who are already voluntarily carrying a heavy workload. |
一般指引
一般來說,你應該遵循翻譯擴充功能關於標記頁面進行翻譯的指引:在可能的情況下,請避免手動分割那些靠近</translate>標籤的翻譯單元,你應該讓空行來實現分割。
Although you can edit translated content using the visual editor, you must use the source editor to add or change translation markup. To make it easier to add translation markup, use the buttons in the box under the editing interface.
Do not use section editing when editing translated pages since this adds extra whitespace to the page.[1] Always select the option to edit the entire page.
分拆示例
| 優良語法 | 需要改善的語法 |
|---|---|
Add <translate> tags on new lines around headings and paragraphs.
<translate>
== 段落的標題 ==
这是一个段落。
这是另一个段落。
</translate>
{{模板}}
<translate>
== 另一個段落的標題 ==
</translate>
|
Heading markup (for example: ==) must be included in translation units.
== <translate>段落的標題</translate> ==
<translate>这是一个段落。</translate>
<translate>这是另一个段落。</translate>
{{模板}}
== <translate>另一個段落的標題<translate> ==
|
Split list items into individual translation units without line breaks. Exclude list markup from the translation unit.
* <translate>這是一份長清單:</translate> ** <translate>此清單中有超過160個字</translate> ** <translate>或是有超過8個項目</translate> * <translate>所以最好將它分割成幾個較小的單元。</translate> * <translate>但我們必須將項目符號排除在翻譯標籤之外,以保持清單的可讀性。</translate> |
List markup (for example: * or #) must be excluded from translation units.
<translate> * 這是一份長清單: ** 此清單中有超過160個字 ** 或是有超過8個項目 </translate> <translate> * 所以最好將它分割成幾個較小的單元。 * 但我們必須將項目符號排除在翻譯標籤之外,以保持清單的可讀性。 </translate> |
特定元素
链接
Links require special markup to link to the correct language variant of the target page. Use localized link syntax for any page that could be translated, even if it hasn't been marked for translation. Pages which do not need localized link syntax include talk pages and templates without textual content.
To link to a page on a multilingual wiki, prefix links with Special:MyLanguage/. To make translation easier, include only the link text in the translation unit, not the link target. If the link is part of a larger translation unit, like a paragraph, you can exclude the link target from the translation unit by wrapping it inside a translation variable (<tvar name=1> … </tvar>).
For a standalone link to a page on the same wiki, such as in a list or a table, you can use the localized link template to simplify the syntax. This works on Meta-Wiki, mediawiki.org, Outreach Wiki, and other wikis where this template is available.
對於維基百科條目的連結,您應該針對對象使用{{lwp}}模板,並將其包在tvar之內。例如,[[{{lwp|Rosa Parks}}</tvar>]]在英文頁面產生的是en:Rosa Parks,在法文頁面產生的是fr:Rosa Parks。
對於其他跨維基和外部連結,如果存在有翻譯,您不應該把链接對象放在tvar內。當然,如果對象的網站有語言偵測系統 (像MediaWiki的Special:MyLanguage/),您可以使用這個系統,並將完整的链接放在tvar內。
| 優良語法 | 需要改善的語法 |
|---|---|
To link to a page on a multilingual wiki, prefix the link target with Special:MyLanguage/, and add link text. Use a translation variable to ensure that only the link text is included in the translation unit.
<translate> Learn about [[<tvar name=1>Special:MyLanguage/Wikimedia projects</tvar>|Wikimedia projects]] and how to request a [[<tvar name=2>Special:MyLanguage/New project process</tvar>|new project]]. </translate> |
The translation variable should include only the link target, not the link text.
<translate> Learn about [[<tvar name=1>Special:MyLanguage/Wikimedia projects</tvar>|Wikimedia projects]] and how to request a [[<tvar name=2>Special:MyLanguage/New project process|new project</tvar>]]. </translate> |
For a standalone link to a page on the same wiki, such as in a list or a table, use Template:ll, and translate only custom link text. You can use |nsp=0 to simplify the link text by omitting the namespace.
<translate>
See also:
</translate>
* {{ll|Help:Contents|2=<translate>Help pages</translate>}}
* {{ll|Meta:Discussion pages|nsp=0}}
|
A parameter name (2=) is required when adding <translate> tags inside template syntax.
<translate>
See also:
</translate>
* {{ll|Help:Contents|<translate>Help pages</translate>}}
* {{ll|Meta:Discussion pages|nsp=0}}
|
For external links, exclude the link target from the translation unit using a translation variable.
<translate> This is a text with an [<tvar name=url>https://openstreetmap.org</tvar> external link]. </translate> |
A translation variable is required to exclude the external link target from the translation unit.
<translate> 這是一個具有[[內部連結]]和[https://openstreetmap.org 外部連結]的文字。 </translate> |
分類
您應該排除<translate>標籤中的類別宣告。取而代之,在類別名稱:[[Category:對象類別{{#translation:}}]]之後加入 {{#translation:}}。這樣,只有英文主頁面會被歸類到對象類別中,翻譯頁面會被歸類到每種語言的類別中。
| 優良語法 | 需要改善的語法 |
|---|---|
[[Category:Wikipedia{{#translation:}}]]
|
<translate>[[Category:Wikipedia]]</translate> |
图片
縮圖和大圖像
如果圖片可以本地化 (例如它有文字且已有翻譯版存在),則應該完全包含在<translate>標籤中。
不然的話,您應該只要將alt=值包裝在<translate nowrap>標籤中,而將標題包裝在<translate>標籤中。
如果有使用 left 或 right 作為圖片的參數:無用的話,請將其移除 (在英文中,縮圖預設為靠右),否則請分別以 {{dirstart}} 或 {{dirend}} 取代。
| 優良語法 | 需要改善的語法 |
|---|---|
[[File:landscape.jpg |thumb |{{dirstart}} |alt=<translate nowrap>日落</translate> |<translate>美麗風景的照片</translate>]]
|
<translate>
[[File:landscape.jpg |thumb |left |alt=日落 |美麗風景的照片]]
</translate>
|
<translate> [[File:英文維基百科的截圖.png|thumb|alt=Homepage of English Wikipedia with featured article and news topics|維基百科首頁]] </translate> |
[[File:英文維基百科的截圖.png|thumb|right|alt=<translate nowrap>Homepage of English Wikipedia with featured article and news topics</translate>|<translate>維基百科首頁</translate>]]
|
圖示
內嵌圖示可以簡單地包裝在 <tvar name="icon"> 中。
| 優良語法 | 需要改善的語法 |
|---|---|
<translate> [[File:pretty hello word.png|alt=大家好!]], <tvar name="icon">[[File:smiley.png|alt=🙂]] 你好嗎? </translate> |
<translate> [[File:pretty hello word.png|alt=大家好!]], [[File:smiley.png|alt=🙂]] 你好嗎? </translate> |
翻譯變數
翻譯變數 (<tvar name="name"></tvar> 語法) 應該要用來隱藏文字,以便防止翻譯人員去翻譯。
以下範例應該被包裝在 tvar 之內:
- 可自動本地化的或不可本地化的連結對象,
- 用户名,
- 可能會改變的數字 (它們應該被包裝在
{{formatnum:}}之內,然後再被包裝到tvar之內), - 標籤屬性 (例如:
<span class="css_class" style="background-color:blue"</tvar>>hello</span>), - 模板名稱和參數 (例如:
{{<tvar name=1>center|5px</tvar>|hello}}), - 複雜 wikitext 或 HTML 的部份(但請確保翻譯者所得的wikitext是平衡的)。
以下範例應該不要被包裝在 tvar 之內:
- 人名和地名(即使很少翻譯,也可能會字母轉寫),
- 沒有屬性的XML標籤,如
<code>(翻譯介面會處理它們), - 可本地化的連結對象(即指向多語言網站的連結)。
翻譯變數名稱
為了幫助翻譯者,請儘量保持 tvar 名稱的簡短和可讀性。如果翻譯者不需要知道他們的內容,使用數字名稱是個好主意,因為數字對大多數翻譯者來說打字很快,而且在許多語言中都很常見 (這樣大多數初學者就不會不小心翻譯了)。
然而,如果 tvar 是在句子裡面,它應該有一個明確的名稱,讓翻譯者了解它包含什麼,以便會更容易寫在他們的翻譯的正確位置上(這個情形很常見的是電子郵件地址、URL、wikitext標籤名稱......)。
| 優良語法 | 需要改善的語法 |
|---|---|
[[<tvar name="1">Special:MyLanguage/Help:Links|請參閱說明頁面]] |
[[Special:MyLanguage/Help:Links|請參閱說明頁面]] |
會議將於<tvar name="date">{{dateT||9|24}}</tvar>日在<tvar name="software">{{int string|Zoom}}</tvar>上舉行。
|
會議將於<tvar name=1>{{dateT||9|24}}</tvar>日在<tvar name=2>{{int string|Zoom}}</tvar>上舉行。
|
也要避免在 tvar 名稱中使用空格、下劃線或帶有二進位的字母。
| 優良語法 | 需要改善的語法 |
|---|---|
<tvar name="max-count">84</tvar> cafés |
<tvar name="max_count of café">84</tvar> cafés |
模板
您可以準備某一個模板進行翻譯,就像準備任何頁面一樣,但您應該確保在標記頁面進行翻譯時,已勾選「为该页面启用翻译感知嵌入」核取方塊。
如果您要在模板呼叫的參數值內插入一個<translate>標籤,請確保該參數已命名(否則,請添加一個數值名稱,有如1=這個)。
如果預期您的模板會被包含在不可翻譯的頁面中(例如使用者頁面),甚至應該會在這些頁面中被翻譯,您可以使用帶有開關的pre-2021 hack,如在下圖所示的程式碼中用 uselang={{int:lang}} 取代 uselang={{PAGELANGUAGE}}。
Pre-2021 hacks
在MediaWiki 1.36.0-wmf.32 (2021-02-23)之前,您必應確保英文頁面是包含模板的 /en 子頁面,而不是直接包含模板。
其中一個方法是用{{TNT|my translated template|param}}來取代每一次出現的{{my translated template|param}},但在應該已包含{{ {{TNTN|my translated template}} |param}}的模板或嵌入的頁面中除外。
另一種方法是編輯模板,使其呼叫自己 {{TNT}}。為此,您應該把完整的模板程式碼放在一個開關之內,這個開關會去對一個空的 <translate> 標籤求值,預設情況下會呼叫 {{TNT}}。
{{#switch:<translate></translate>
|=<完整的模板程式碼>
|#default={{#invoke:Template translation|renderTranslatedTemplate|template={{subst:FULLPAGENAME}}|uselang={{PAGELANGUAGE}}|noshift=1}}
}}