Template:Native name/doc: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>CsDix
→‎Annotated code: paren, updated altered nbsp functioning
meta>CsDix
m →‎Annotated code: parfenthesis
Line 80: Line 80:
[c] If icon or paren=no, omit following linked language name (in brackets).
[c] If icon or paren=no, omit following linked language name (in brackets).
[d] If placename in italics,
[d] If placename in italics,
[e] then, unless nbsp=no, add an extra space after it to stop the italics
[e] then, unless nbsp=no, add an extra space after it (to stop the italics
                                      leaning into the parenthesis that follows.
                                    leaning into the parenthesis that follows).
[f] If a link for this language name exists, include it as:
[f] If a link for this language name exists, include it as:
           "[[(name) language|(name)]]", e.g. "([[French language|French]])"....
           "[[(name) language|(name)]]", e.g. "([[French language|French]])"....

Revision as of 23:11, 1 December 2012

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:{{{paren|{{{icon|}}}}}}|no |                               <!--[c]-->
    |&nbsp;{{#ifeq:{{{italic|}}}|no |                                 <!--[d]-->
            |{{#ifeq:{{{nbsp|}}}|no |                                 <!--[e]-->
              |&nbsp;}}<!--
          -->}}<!--
   --><span class="languageicon"
            style="{{{fontsize|90%}}};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 placename, in italics unless italic=no.
[c] If icon or paren=no, omit following linked language name (in brackets).
[d] If placename in italics,
[e] then, unless nbsp=no, add an extra space after it (to stop the italics
                                     leaning into the parenthesis 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?)".