Module:Multilingual/doc: Difference between revisions

Content deleted Content added
Setup
 
TFD closed as no consensus (XFDcloser)
 
(20 intermediate revisions by 6 users not shown)
Line 1:
<onlyinclude>'''<code>Multilingual</code>''' – Module with functions in context of languages, language codes, language names.
{{LuaModuleDoc}}
<onlyinclude>'''<code>Multilingual</code>''' – Module with functions in context of languages, language codes, language names.
 
== {{Anker|template}} Functions for templates ==
All functions expect one unnamed parameter <code>1</code> with the key information, and sometimes more optionals. Whitespace ahead and after any content is ignored. Upcasing of language code segments like in <code>en-US</code> does not matter; results are downcased.
 
The return value is an empty string (“nothing”), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space.
 
; fair
; findCode {{Anker|findCode}}
: Format language code according to RFC 5646 and check validity
:* ''Result:'' empty, if invalid
; findCode
: Retrieve code of language name in local (current project) language.
: A code itself will be identified, too.
; format {{Anker|format}}
: Format one or more languages.
:* <code>1</code> – language list or single item
Line 21 ⟶ 23:
:** <code>d</code> – downcase everything
:** <code>f</code> – capitalize first item only
:** <code>m</code> – downcase every first word in item only
:* <code>link=1</code> – link items
:* <code>scream</code> – category title in case of error
:* <code>split</code> – split pattern, if list expected; elsee.g. <code>split=,</code> – otherwise <code>1</code> is regarded as single item
:* <code>separator</code> – list separator, else <code>split</code>
:* <code>start</code> – prepend first list element, if any
; getBase {{Anker|getBase}}
; getBase
: Retrieve base language from possibly combined ISO language code.
; getName {{Anker|getName}}
: Which name is assigned to this language code?
:* <code>2</code> – language of the answer
Line 33 ⟶ 37:
:** <code>!</code> – in project language
:** Any ISO code.
; isLang {{Anker|isLang}}
: Could this be an ISO language code?
:* ''nothing'' – if not
; isLangWiki {{Anker|isLangWiki}}
: Could this be a Wiki language version?
:* ''nothing'' – if not
; kannDeutsch {{Anker|kannDeutsch}}
: Might someone with this language code understand German?
:* ''nothing'' – if not
; userLang {{Anker|userLang}}
: Try to support user language by application.
:* <code>1</code> – space separated list of available ISO 639 codes
Line 49 ⟶ 53:
:** If the current user language is a variant like <code>en-US</code> or <code>en-GB</code> and that is not mentioned explicitly in list, base language (here&nbsp;<code>en</code>) will be tried.
:** If nothing matches and no list is provided, the project language (here&nbsp;<code>{{CONTENTLANGUAGE}}</code>), at least <code>en</code> for English will be returned.
; failsafe
</onlyinclude>
: Version ID: <code>{{#invoke:Multilingual|failsafe}}</code>
== {{Anker|Lua}} Functions for Lua modules (API) ==
: optional parameter <code>1</code> – required version
:: result: empty, if requirement not met
 
=== Examples (test page) ===
A [[Wikipedia:Lua/Modul/Multilingual/Test|test page]] illustrates practical use.
== {{Anker|Lua}} Functions for Lua modules (API) ==
 
All functions described above can be used by other modules:
Line 63 ⟶ 73:
</syntaxhighlight>
Subsequently there are available:
; Multilingual.[[#findCode|findCode]]fair( ask ) {{Anker|findCode()}}
:* ''ask'' – string, or table according to getLang()
; Multilingual.[[#format|format]]( apply, alien, alter, active, alert, frame, assembly, adjacent ) {{Anker|format()}}
; Multilingual.findCode( ask )
; Multilingual.[[#format|format]]( apply, alien, alter, active, alert, frame, assembly, adjacent ) {{Anker|format()}}
:* ''apply'' – string with language list or single item
:* ''alien'' – language of the answer
Line 72 ⟶ 84:
:* ''alter'' – capitalization
:** <code>"c"</code> – capitalize
:** <code>"d"</code> – downcase, if everything
:** <code>"f"</code> – capitalize first item only, downcase anything else
:* ''active'' – link items, if <code>true</code>
:* ''alert'' – string with category title in case of error
Line 79 ⟶ 91:
:* ''assembly'' – string with split pattern, if list expected
:* ''adjacent'' – string with list separator, else ''assembly''
:* ''ahead'' – string for optional prepending first element, if any
; Multilingual.[[#getBase|getBase]]( ask ) {{Anker|getBase()}}
; Multilingual.[[#getName|getName]]getBase( ask, alien ) {{Anker|getName()}}
; Multilingual.getLang( ask )
: Split language code into components
: Returns: ''table''
:: <code>.base</code> – Basic language (2–3 lowercase letters)
:: <code>.region</code> – Country (2 uppercase letters)
:: <code>.script</code> – Scripting (4 letters, capitalized)
:: <code>.year</code> – year (4 digits)
:: <code>.extension</code> – Extension (1 lowercase letter)
:: <code>.other</code> – More
:: <code>.legal</code> – ''true'' if valid
:: <code>.n</code> – Number of components
; Multilingual.getName( ask, alien )
:* ''alien'' – language of the answer
:** <code>nil false "*"</code> – native
:** <code>"!"</code> – current project
:** Any ISO code.
; Multilingual.[[#isLang|isLang]]( ask ) {{Anker|isLang()}}
; Multilingual.[[#isLangWiki|isLangWiki]]( ask ) {{Anker|isLangWiki()}}
; Multilingual.[[#kannDeutsch|kannDeutsch]]( ask ) {{Anker|kannDeutsch()}}
; Multilingual.[[#userLang|userLang]]( accept, frame ) {{Anker|userLang()}}
:* ''accept'' – string with space separated list of available ISO 639 codes
:* ''frame'' – if available
; Multilingual.failsafe( atleast )
:* atleast<br />''optional''<br />''nil'' or required version
:* Returns: ''string'' or ''false''
If succeeding, the ''Multilingual.get*()'' return a string, the ''Multilingual.is*()'' <code>true</code>; on failure <code>false</code>.
 
Line 97 ⟶ 124:
 
== Dependencies ==
* [[../../Module:WLink|WLink]]
None.
* [[..Module:Multilingual/config|/config]] – optional project specific adaption
* [[../../WLink|WLink]]
* [[../config|/config]] – optional project specific adaption
 
[[Kategorie:Wikipedia:Lua/Modul/Dokumentation|Multilingual/en]]