Difference between revisions of "Template:Translation of"
(17 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{#if: {{{1|}}} | {{#if: {{{1|}}} | ||
− | | {{#if: {{#ask:[[ | + | | {{#if: {{#ask:[[{{{2|{{FULLPAGENAME}}}}}]]|?Has language=}} |
− | | {{#if: {{#ask: [[Has language::{{# | + | | {{#if: {{#ask: [[Translated from::{{{1}}}]] [[Has language::{{#show: {{{2|{{FULLPAGENAME}}}}} | ?Has language = | link=none}}]] |
+ | }} | ||
+ | | {{#ask: [[Translated from::{{{1}}}]] [[Has language::{{#show: {{{2|{{FULLPAGENAME}}}}} | ?Has language = | link=none}}]] | ||
+ | | link=none | ||
}} | }} | ||
− | |||
− | |||
− | |||
| {{{1}}} | | {{{1}}} | ||
}} | }} | ||
Line 11: | Line 11: | ||
}} | }} | ||
}}<noinclude> | }}<noinclude> | ||
− | Template '''{{PAGENAME}}''' returns the translation of page X in | + | Template '''{{PAGENAME}}''', which takes the form <code><nowiki>{{Translation of|Page X|Page Y}}</nowiki></code>, returns the translation of page X in the language of page Y. If page Y is not supplied, the current page (where the template is being used) applies. If a translation of page X in the language of page Y does not exist, page X itself is returned. |
==Use== | ==Use== | ||
<pre> | <pre> | ||
− | {{Translation of|X|Y}} | + | {{Translation of|Page X|Page Y}} |
</pre> | </pre> | ||
+ | |||
+ | The template can be used to create links to yet untranslated pages. Before the translated page exists, the link points at the original page. After the translation is created, the link automatically changes to the translated page. | ||
+ | |||
+ | For example, a user is translating [[Content Directories]] to Pt, in [[Pt:Listas de Conteúdos]]. The page contains a link to [[Add content directory howto]], which hasn't been translated to Pt yet. This link can be replaced by <code><nowiki>[[{{Translation of|Add content directory howto}}]]</nowiki></code>. Before the translation is created, the link will show as [[{{Translation of|Add content directory howto|xxxxxx}}]]. After the translation is created, the link will automatically change to [[{{Translation of|Add content directory howto|Pt:Listas de Conteúdos}}]]. | ||
+ | |||
+ | Since the use of the template is more performance intensive than a direct link, if you detect that the template is being used in a page but the translation already exists, the template call should be replaced by a direct link to the translated page. | ||
==Examples== | ==Examples== | ||
Line 32: | Line 38: | ||
{{Translation of|Main Page|Hr:Odabir licence}} | {{Translation of|Main Page|Hr:Odabir licence}} | ||
</pre> | </pre> | ||
− | returns the translation of [[Main Page]] in the same language as page [[Hr:Odabir licence]], that is, the translation of [[Main Page]] in language Hr (at the time of writing this translation | + | returns the translation of [[Main Page]] in the same language as page [[Hr:Odabir licence]], that is, the translation of [[Main Page]] in language Hr (at the time of writing this translation does not exist so "Main Page" is returned): |
{{Translation of|Main Page|Hr:Odabir licence}} | {{Translation of|Main Page|Hr:Odabir licence}} | ||
− | ===3. Language | + | ===3. Language is not defined=== |
<pre> | <pre> | ||
{{Translation of|Main Page|Non existent page}} | {{Translation of|Main Page|Non existent page}} | ||
</pre> | </pre> | ||
− | returns the translation of [[Main Page]] in the same language as page [[Non existent page]], that is, the translation of [[Main Page]] in an | + | returns the translation of [[Main Page]] in the same language as page [[Non existent page]], that is, the translation of [[Main Page]] in an undefined language: |
{{Translation of|Main Page|Non existent page}} | {{Translation of|Main Page|Non existent page}} | ||
+ | ===4. Category namespace=== | ||
+ | <pre> | ||
+ | [[:{{Translation of|Category:Untranslated}}]] | ||
+ | </pre> | ||
+ | |||
+ | [[:{{Translation of|Category:Untranslated}}]] | ||
+ | |||
+ | <pre> | ||
+ | [[:{{Translation of|Category:Untranslated|Pt:Página principal}}]] | ||
+ | </pre> | ||
+ | |||
+ | [[:{{Translation of|Category:Untranslated|Pt:Página principal}}]] | ||
+ | |||
+ | [[Category:Support translation templates|{{PAGENAME}}]] | ||
</noinclude> | </noinclude> |
Latest revision as of 19:55, 1 February 2012
{{#if:
| {{#if: {{#ask:Template:Translation of|?Has language=}} | {{#if: {{#ask: [[Translated from::{{{1}}}]] [[Has language::{{#show: Template:Translation of | ?Has language = | link=none}}]] }} | {{#ask: [[Translated from::{{{1}}}]] [[Has language::{{#show: Template:Translation of | ?Has language = | link=none}}]] | link=none }} | {{{1}}} }} | {{{1}}} }}
}} Template Translation of, which takes the form {{Translation of|Page X|Page Y}}
, returns the translation of page X in the language of page Y. If page Y is not supplied, the current page (where the template is being used) applies. If a translation of page X in the language of page Y does not exist, page X itself is returned.
Contents
Use
{{Translation of|Page X|Page Y}}
The template can be used to create links to yet untranslated pages. Before the translated page exists, the link points at the original page. After the translation is created, the link automatically changes to the translated page.
For example, a user is translating Content Directories to Pt, in Pt:Listas de Conteúdos. The page contains a link to Add content directory howto, which hasn't been translated to Pt yet. This link can be replaced by [[{{Translation of|Add content directory howto}}]]
. Before the translation is created, the link will show as [[{{#if: Add content directory howto
| {{#if: {{#ask:xxxxxx|?Has language=}} | {{#if: {{#ask: Translated from::Add content directory howto [[Has language::{{#show: xxxxxx | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Add content directory howto [[Has language::{{#show: xxxxxx | ?Has language = | link=none}}]] | link=none }} | Add content directory howto }} | Add content directory howto }}
}}]]. After the translation is created, the link will automatically change to [[{{#if: Add content directory howto
| {{#if: {{#ask:Pt:Listas de Conteúdos|?Has language=}} | {{#if: {{#ask: Translated from::Add content directory howto [[Has language::{{#show: Pt:Listas de Conteúdos | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Add content directory howto [[Has language::{{#show: Pt:Listas de Conteúdos | ?Has language = | link=none}}]] | link=none }} | Add content directory howto }} | Add content directory howto }}
}}]].
Since the use of the template is more performance intensive than a direct link, if you detect that the template is being used in a page but the translation already exists, the template call should be replaced by a direct link to the translated page.
Examples
1. Translation exists
{{Translation of|Main Page|CC Wiki:De:Übersetzen}}
returns the translation of Main Page in the same language as page CC Wiki:De:Übersetzen, that is, the translation of Main Page in language De:
{{#if: Main Page
| {{#if: {{#ask:CC Wiki:De:Übersetzen|?Has language=}} | {{#if: {{#ask: Translated from::Main Page [[Has language::{{#show: CC Wiki:De:Übersetzen | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Main Page [[Has language::{{#show: CC Wiki:De:Übersetzen | ?Has language = | link=none}}]] | link=none }} | Main Page }} | Main Page }}
}}
2. Translation does not exist
{{Translation of|Main Page|Hr:Odabir licence}}
returns the translation of Main Page in the same language as page Hr:Odabir licence, that is, the translation of Main Page in language Hr (at the time of writing this translation does not exist so "Main Page" is returned):
{{#if: Main Page
| {{#if: {{#ask:Hr:Odabir licence|?Has language=}} | {{#if: {{#ask: Translated from::Main Page [[Has language::{{#show: Hr:Odabir licence | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Main Page [[Has language::{{#show: Hr:Odabir licence | ?Has language = | link=none}}]] | link=none }} | Main Page }} | Main Page }}
}}
3. Language is not defined
{{Translation of|Main Page|Non existent page}}
returns the translation of Main Page in the same language as page Non existent page, that is, the translation of Main Page in an undefined language:
{{#if: Main Page
| {{#if: {{#ask:Non existent page|?Has language=}} | {{#if: {{#ask: Translated from::Main Page [[Has language::{{#show: Non existent page | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Main Page [[Has language::{{#show: Non existent page | ?Has language = | link=none}}]] | link=none }} | Main Page }} | Main Page }}
}}
4. Category namespace
[[:{{Translation of|Category:Untranslated}}]]
[[:{{#if: Category:Untranslated
| {{#if: {{#ask:Template:Translation of|?Has language=}} | {{#if: {{#ask: Translated from::Category:Untranslated [[Has language::{{#show: Template:Translation of | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Category:Untranslated [[Has language::{{#show: Template:Translation of | ?Has language = | link=none}}]] | link=none }} | Category:Untranslated }} | Category:Untranslated }}
}}]]
[[:{{Translation of|Category:Untranslated|Pt:Página principal}}]]
[[:{{#if: Category:Untranslated
| {{#if: {{#ask:Pt:Página principal|?Has language=}} | {{#if: {{#ask: Translated from::Category:Untranslated [[Has language::{{#show: Pt:Página principal | ?Has language = | link=none}}]] }} | {{#ask: Translated from::Category:Untranslated [[Has language::{{#show: Pt:Página principal | ?Has language = | link=none}}]] | link=none }} | Category:Untranslated }} | Category:Untranslated }}
}}]]