Difference between revisions of "Template:Lang2iso/doc"

From blackwiki
Jump to navigation Jump to search
imported>Gonnym
imported>Gonnym
(added {{High-use}} and updated /doc)
 
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE. -->
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE. -->
 +
{{High-use}}
 
{{Lua|Module:ISO 639 name}}
 
{{Lua|Module:ISO 639 name}}
'''Template:Lang2iso''', should not be transcluded directly from article namespace. Template:Lang2iso takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter [[ISO 639]] language code. This table's values are based on [[List of ISO 639-1 codes]].
+
 
 +
'''Template:Lang2iso''' takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter [[ISO 639]] language code. This table's values are based on [[List of ISO 639-1 codes]]. The template should not be transcluded directly from article namespace.
  
 
==Examples==
 
==Examples==
* <nowiki>{{Lang2iso|German}}</nowiki> returns "{{Lang2iso|German}}"
+
* {{Tlx|Lang2iso|German}} returns: {{Lang2iso|German}}
* <nowiki>{{Lang2iso|Greek}}</nowiki> returns "{{Lang2iso|Greek}}"
+
* {{Tlx|Lang2iso|Greek}} returns: {{Lang2iso|Greek}}
* <nowiki>{{Lang2iso|Spanish}}</nowiki> returns "{{Lang2iso|Spanish}}"
+
* {{Tlx|Lang2iso|Spanish}} returns: {{Lang2iso|Spanish}}
  
 
==Purpose==
 
==Purpose==
Since most users will know a language's name but not its ISO code, this template/macro is meant to facilitate invocations of other templates such as [[Template:Lang]]. Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding:
+
Since most users will know a language's name but not its ISO code, this template is meant to facilitate invocations of other templates such as [[Template:Lang]]. Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding {{Tlx|Lang|de|Mädchen}}, one can type: {{Tlx|Lang|{{Tlx|Lang2iso|subst=y|German}}|Mädchen}}.
 
 
:<nowiki>{{lang|de|Mädchen}}</nowiki>
 
 
 
one can type:
 
 
 
:<nowiki>{{lang|{{subst:lang2iso|German}}|Mädchen}}</nowiki>
 
  
This also reduces the number of parameters that need to be passed to some language routines (such as those similar to [[Template:Language with name]]) since the ISO Language Code can now be derived from the ISO Language Name.
+
This also reduces the number of parameters that need to be passed to some language routines (such as those similar to [[Template:Language with name]]) since the ISO language code can now be derived from the ISO language name.
  
 
==See also==
 
==See also==

Latest revision as of 16:48, 3 October 2020

Template:Lang2iso takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter ISO 639 language code. This table's values are based on List of ISO 639-1 codes. The template should not be transcluded directly from article namespace.

Examples

Purpose

Since most users will know a language's name but not its ISO code, this template is meant to facilitate invocations of other templates such as Template:Lang. Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding {{Lang|de|Mädchen}}, one can type: {{Lang|{{subst:Lang2iso|German}}|Mädchen}}.

This also reduces the number of parameters that need to be passed to some language routines (such as those similar to Template:Language with name) since the ISO language code can now be derived from the ISO language name.

See also