Difference between revisions of "Template:Translate-link"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Test)
m
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#ifeq: 1 | 1
+
<includeonly>{{#if: {{{3|}}}
<!-- Если язык текущей страницы извлечь не получилось -->
+
<!-- If 3rd param is defined -->
 
|
 
|
   [[{{{1}}}]]
+
   <!-- Use it as current language -->
<!-- Если язык текущей страницы извлечь удалось -->
+
  {{#ifexist: {{{1}}}/{{{3}}}
 +
  <!-- If exist page has been translated into current language -->
 +
  |
 +
    <!-- Create a link to translated page -->
 +
    {{#if: {{{2|}}}
 +
    |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{{3}}}|{{{2}}}]]
 +
    |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{{3}}}|{{{1}}}]]
 +
    }}
 +
  <!-- If not exist page has been translated into current language -->
 +
  |
 +
    <!-- Create a link to translated and original page -->
 +
    {{#if: {{{2|}}}
 +
    |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{{3}}}|{{{2}}}]] [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}|(en)]]
 +
    |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{{3}}}|{{{1}}}]] [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}|(en)]]
 +
    }}
 +
  }}   
 +
<!-- If 3rd param is not defined -->
 
|
 
|
   {{#ifexist: {{{1}}}/{{#titleparts:{{PAGENAME}}|1|2}}
+
   {{#ifeq: {{#titleparts:{{PAGENAME}}|1|2}} | {{#language:{{#titleparts:{{PAGENAME}}|1|2}}}}
   <!-- Если существует переведенная на текущий язык страница -->
+
   <!-- If the language of the current page could not be extracted -->
 
   |
 
   |
     <!-- Создаем ссылку на страницу текущего языка -->
+
     <!-- Create a link to original page and print error mesage -->
     [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/ru|{{{2|{{{1}}}}}}]]
+
     [[{{{1}}}|Translate-link: <span style="color:#CC2200">GETTING_LANGUAGE_ERROR</span>]]
   <!-- Если не существует переведенная на текущий язык страница -->
+
   <!-- If the language of the current page has been extracted -->
 
   |
 
   |
     <!-- Создаем ссылку на страницу текущего языка и ссылку на оригинал -->
+
    {{#ifexist: {{{1}}}/{{#titleparts:{{PAGENAME}}|1|2}}
     [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{#titleparts:{{PAGENAME}}|1|2}}|{{{2|{{{1}}}}}}]] [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}|(en)]]
+
     <!-- If exist page has been translated into current language -->
 +
     |
 +
      <!-- Create a link to translated page -->
 +
      {{#if: {{{2|}}}
 +
      |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{#titleparts:{{PAGENAME}}|1|2}}|{{{2}}}]]
 +
      |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{#titleparts:{{PAGENAME}}|1|2}}|{{{1}}}]]
 +
      }}
 +
    <!-- If not exist page has been translated into current language -->
 +
    |
 +
      <!-- Create a link to translated and original page -->
 +
      {{#if: {{{2|}}}
 +
      |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{#titleparts:{{PAGENAME}}|1|2}}|{{{2}}}]] [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}|(en)]]
 +
      |[[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}/{{#titleparts:{{PAGENAME}}|1|2}}|{{{1}}}]] [[{{{1|:{{NAMESPACE}}:{{BASEPAGENAME}}}}}|(en)]]
 +
      }}
 +
    }}
 
   }}
 
   }}
 
}}</includeonly><noinclude>
 
}}</includeonly><noinclude>
 +
== Description ==
 +
Template allows you to quickly create links to translated page DA Builder Wiki using the language of the current page:
  
In dev. Please wait.
+
{|border="1"
 +
!style="background:#EEEEFF"|Source code
 +
!style="background:#EEEEFF"|Condition
 +
!style="background:#EEEEFF"|Output
 +
|-
 +
|rowspan="3" |<pre>{{Translate-link|Main Page}}</pre>
 +
|If the language of the current page could not be extracted
 +
|[[Main Page|Translate-link: <span style="color:#CC2200">GETTING_LANGUAGE_ERROR</span>]]
 +
|-
 +
|If the page translated into current language exists (i.e. this page in Russian)
 +
|[[Main Page/ru|Main Page]]
 +
|-
 +
|If the page translated into current language does not exist (i.e. this page in Russian)
 +
|[[Main Page/ru|<span style="color:#CC2200">Main Page</span>]] [[Main Page|(en)]]
 +
|-
 +
|rowspan="3" |<pre>{{Translate-link|Main Page|Other name}}</pre>
 +
|If the language of the current page could not be extracted
 +
|[[Main Page|Translate-link: <span style="color:#CC2200">GETTING_LANGUAGE_ERROR</span>]]
 +
|-
 +
|If the page translated into current language exists (i.e. this page in Russian)
 +
|[[Main Page/ru|Other name]]
 +
|-
 +
|If the page translated into current language does not exist (i.e. this page in Russian)
 +
|[[Main Page/ru|<span style="color:#CC2200">Other name</span>]] [[Main Page|(en)]]
 +
|-
 +
|rowspan="2" |<pre>{{Translate-link|Main Page||ru}}</pre><pre>{{Translate-link|Main Page|3=ru}}</pre>
 +
|If the page translated into specified language exists (language of the current page is ignored)
 +
|[[Main Page/ru|Main Page]]
 +
|-
 +
|If the page translated into specified language does not exist (language of the current page is ignored)
 +
|[[Main Page/ru|<span style="color:#CC2200">Main Page</span>]] [[Main Page|(en)]]
 +
|-
 +
|rowspan="2" |<pre>{{Translate-link|Main Page|Other name|ru}}</pre>
 +
|If the page translated into specified language exists (language of the current page is ignored)
 +
|[[Main Page/ru|Other name]]
 +
|-
 +
|If the page translated into specified language does not exist (language of the current page is ignored)
 +
|[[Main Page/ru|<span style="color:#CC2200">Other name</span>]] [[Main Page|(en)]]
 +
|}
  
{{#ifeq: {{#titleparts:{{PAGENAME}}|1|2}} | {{#language:{{#titleparts:{{PAGENAME}}|1|2}}}}
+
== Note ==
</noinclude>
+
This template has a short version [[Template:Ulink|ulink]].
 +
[[Category:Link_templates]]</noinclude>

Latest revision as of 21:31, 9 November 2010

Description

Template allows you to quickly create links to translated page DA Builder Wiki using the language of the current page:

Source code Condition Output
{{Translate-link|Main Page}}
If the language of the current page could not be extracted Translate-link: GETTING_LANGUAGE_ERROR
If the page translated into current language exists (i.e. this page in Russian) Main Page
If the page translated into current language does not exist (i.e. this page in Russian) Main Page (en)
{{Translate-link|Main Page|Other name}}
If the language of the current page could not be extracted Translate-link: GETTING_LANGUAGE_ERROR
If the page translated into current language exists (i.e. this page in Russian) Other name
If the page translated into current language does not exist (i.e. this page in Russian) Other name (en)
{{Translate-link|Main Page||ru}}
{{Translate-link|Main Page|3=ru}}
If the page translated into specified language exists (language of the current page is ignored) Main Page
If the page translated into specified language does not exist (language of the current page is ignored) Main Page (en)
{{Translate-link|Main Page|Other name|ru}}
If the page translated into specified language exists (language of the current page is ignored) Other name
If the page translated into specified language does not exist (language of the current page is ignored) Other name (en)

Note

This template has a short version ulink.