Module:Script utilities/documentation: Difference between revisions

From The Languages of David J. Peterson
Jump to navigation Jump to search
No edit summary
 
Line 5: Line 5:
== Exported functions ==
== Exported functions ==


=== lang_t ===
{{module documentation|section_level=3}}
<code><nowiki>{{#invoke:script utilities|lang_t}}</nowiki></code>
 
This is used by {{temp|lang}} to wrap portions of text in a language tag. See there for more information.
 
=== tag_text ===
<code>tag_text(text, lang, sc, face, class)</code>
 
Wraps the given text in HTML tags with appropriate CSS classes (see [[WT:CSS]]) for the [[Module:languages#Language objects|language]] and script. This is required for all non-English text on Wiktionary.
 
The actual tags and CSS classes that are added are determined by the <code>face</code> parameter. It can be one of the following:
; {{code|lua|"term"}}
: The text is wrapped in {{code|html|2=<i class="(sc) mention" lang="(lang)">...</i>}}.
; {{code|lua|"head"}}
: The text is wrapped in {{code|html|2=<strong class="(sc) headword" lang="(lang)">...</strong>}}.
; {{code|lua|"hypothetical"}}
: The text is wrapped in {{code|html|2=<span class="hypothetical-star">*</span><i class="(sc) hypothetical" lang="(lang)">...</i>}}.
; {{code|lua|"bold"}}
: The text is wrapped in {{code|html|2=<b class="(sc)" lang="(lang)">...</b>}}.
; {{code|lua|nil}}
: The text is wrapped in {{code|html|2=<span class="(sc)" lang="(lang)">...</span>}}.
 
The optional <code>class</code> parameter can be used to specify an additional CSS class to be added to the tag.
 
=== tag_translit ===
<code>tag_translit(translit, lang, kind, attributes)</code>
 
Tags the transliteration for given text <code>translit</code> and language <code>lang</code>. It will add the language, script subtag (as defined in [https://www.rfc-editor.org/rfc/bcp/bcp47.txt BCP 47 2.2.3]) and [https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir dir] (directional) attributes as needed.
 
The optional <code>kind</code> parameter can be one of the following:
; {{code|lua|"term"}}
: tag transliteration for {{temp|mention}}
; {{code|lua|"usex"}}
: tag transliteration for {{temp|usex}}
; {{code|lua|"head"}}
: tag transliteration for {{temp|head}}
; {{code|lua|"default"}}
: default
 
The optional <code>attributes</code> parameter is used to specify additional HTML attributes for the tag.
 
=== request_script ===
<code>request_script(lang, sc)</code>
 
Generates a request to provide a term in its native script, if it is missing. This is used by the {{temp|rfscript}} template as well as by the functions in [[Module:links]].
 
The function will add entries to one of the subcategories of [[:Category:Terms needing native script by language]], and do several checks on the given language and script. In particular:
* If the script was given, a subcategory named "needing (script) script" is added, but only if the language has more than one script. Otherwise, the main "needing native script" category is used.
* Nothing is added at all if the language has no scripts other than Latin and its varieties.
 
=== template_rfscript ===
<code><nowiki>{{#invoke:script utilities|template_rfscript}}</nowiki></code>
 
This is used by {{temp|rfscript}}. See there for more information.


== See also ==
== See also ==
Line 67: Line 14:
<includeonly>
<includeonly>
[[Category:General utility modules]]
[[Category:General utility modules]]
[[Category:Wiktionary modules]]
</includeonly>
</includeonly>

Latest revision as of 20:47, 18 September 2023

This module provides access to Module:scripts from templates, so that they can make use of the information stored there. It also provides a number of functions that can be used by other modules.

Data is found in Module:script utilities/data.

Exported functions

(The generated documentation is located at the module page.)

See also