Template:Native name/doc

From Zoophilia Wiki
Revision as of 22:38, 1 December 2012 by meta>CsDix (annotated code)
Jump to navigationJump to search

Convenience template to indicate what language a native name of a place (like that of a country or town) belongs to, appending the language name in an icon. Uses {{lang}} and {{language icon}}. It makes the native name appear in italics by default, although this can be overridden, as can the language icon be excluded. Therefore, the template may make no visible changes to the text, but it does add a span tag with language attributes around the native name to the page's source code, which can help web browsers choose the right font, screen readers use the right pronunciation and more.

Usage

{{native name|language tag|text[|icon=no][|italic=no]}}
('[...]' means 'optional', do not include the square brackets when using this template)

where

  • language tag is the code for the native language (see the list of ISO 639 codes);
  • text is the native name;
  • icon is an optional parameter to exclude the language icon by setting the value to "no";
  • italic is an optional parameter to prevent the name from appearing in italics by setting the value to "no".

Examples

{{Infobox settlement
 |name=The Hague
 |native_name={{native name|nl|Den Haag}}
}}

results in

The Hague
Den Haag  (Dutch)

while

{{Infobox settlement
 |name=French Republic
 |native_name={{native name|fr|République française|icon=no}}
}}

results in

French Republic
République française

 

Note

When both the icon and italic parameters are set to "no" this template is equivalent to the {{lang}} template.

Annotated code

                              width 80 characters
--------------------------------------------------------------------------------

{{lang
 |{{{1}}}                                                             <!--[a]-->
 |{{#ifeq:{{{italic|}}}|no||''}}{{{2}}}{{#ifeq:{{{italic|}}}|no||''}} <!--[b]-->
}}<!--
-->{{#ifeq:{{{icon|}}}|no |                                           <!--[c]-->
    |&nbsp;{{#ifeq:{{{italic|}}}|no |                                 <!--[d]-->
            |{{#if:{{{nbsp|}}}                                        <!--[e]-->
              |&nbsp;}}<!--
          -->}}<!--
   --><span class="languageicon" style="font-size:95%;font-weight:normal;"><!--
    -->{{#ifexist:Template:ISO 639 name {{{1}}}                       <!--[f]-->
        |([[{{ISO 639 name|{{{1}}}}} language|{{ISO 639 name|{{{1}}}}}]])
        |(language?)                                                  <!--[g]-->
       }}<!--
   --></span><!--
-->}}


--------------------------------------------------------------------------------
Legend
[a] Two-letter ISO 639 language code.
[b] The foreign-language phrase, name, etc, in italics unless italic=no.
[c] If icon=no, omit following linked language-name (in brackets).
[d] If phrase in italics, then, if nbsp=yes....
[e] ....add an extra space after it, to stop the italics leaning into the
                                                           bracket that follows.
[f] If a link for this language name exists, include it as:
           "[[(name) language|(name)]]", e.g. "([[French language|French]])"....
[g] ....else return the error query "(language?)".