Title: Module:Lang - freem URL Source: https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang Markdown Content: [Jump to content](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#bodyContent) - [x] Main menu Main menu move to sidebar hide Navigation * [Main page](https://freemwiki.com/wiki/Main_Page "Visit the main page [alt-shift-z]") * [Recent changes](https://freemwiki.com/wiki/Special:RecentChanges "A list of recent changes in the wiki [alt-shift-r]") * [Random page](https://freemwiki.com/wiki/Special:Random "Load a random page [alt-shift-x]") * [Help about MediaWiki](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents) Legal * [Terms](https://freemwiki.com/wiki/Terms_of_Service) * [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy) * [About](https://freemwiki.com/wiki/About) * [Contact](https://freemwiki.com/wiki/Contact) [![Image 1](https://freemwiki.com/images/freem.svg)**freem**](https://freemwiki.com/wiki/Main_Page) [Search](https://freemwiki.com/wiki/Special:Search "Search freem [alt-shift-f]") Search - [x] Appearance * [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3ALang&returntoquery=oldid%3D579704 "You are encouraged to create an account and log in; however, it is not mandatory") * [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3ALang&returntoquery=oldid%3D579704 "You are encouraged to log in; however, it is not mandatory [alt-shift-o]") - [x] Personal tools * [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3ALang&returntoquery=oldid%3D579704 "You are encouraged to create an account and log in; however, it is not mandatory") * [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3ALang&returntoquery=oldid%3D579704 "You are encouraged to log in; however, it is not mandatory [alt-shift-o]") Pages for logged out editors [learn more](https://freemwiki.com/wiki/Help:Introduction) * [Contributions](https://freemwiki.com/wiki/Special:MyContributions "A list of edits made from this IP address [alt-shift-y]") * [Talk](https://freemwiki.com/wiki/Special:MyTalk "Discussion about edits from this IP address [alt-shift-n]") # Module:Lang - [x] Add languages * [Module](https://freemwiki.com/wiki/Module:Lang "View the module page [alt-shift-c]") * [Discussion](https://freemwiki.com/index.php?title=Module_talk:Lang&action=edit&redlink=1 "Discussion about the content page (page does not exist) [alt-shift-t]") - [x] English * [Read](https://freemwiki.com/wiki/Module:Lang) * [Edit source](https://freemwiki.com/index.php?title=Module:Lang&action=edit "Edit the source code of this page [alt-shift-e]") * [View history](https://freemwiki.com/index.php?title=Module:Lang&action=history "Past revisions of this page [alt-shift-h]") - [x] Tools Tools move to sidebar hide Actions * [Read](https://freemwiki.com/wiki/Module:Lang) * [Edit source](https://freemwiki.com/index.php?title=Module:Lang&action=edit "Edit the source code of this page [alt-shift-e]") * [View history](https://freemwiki.com/index.php?title=Module:Lang&action=history) General * [What links here](https://freemwiki.com/wiki/Special:WhatLinksHere/Module:Lang "A list of all wiki pages that link here [alt-shift-j]") * [Related changes](https://freemwiki.com/wiki/Special:RecentChangesLinked/Module:Lang "Recent changes in pages linked from this page [alt-shift-k]") * [Special pages](https://freemwiki.com/wiki/Special:SpecialPages "A list of all special pages [alt-shift-q]") * [Printable version](javascript:print(); "Printable version of this page [alt-shift-p]") * [Permanent link](https://freemwiki.com/index.php?title=Module:Lang&oldid=579704 "Permanent link to this revision of this page") * [Page information](https://freemwiki.com/index.php?title=Module:Lang&action=info "More information about this page") Appearance move to sidebar hide From freem Revision as of 06:18, 21 October 2025 by [Lukegao](https://freemwiki.com/index.php?title=User:Lukegao&action=edit&redlink=1 "User:Lukegao (page does not exist)")([talk](https://freemwiki.com/index.php?title=User_talk:Lukegao&action=edit&redlink=1 "User talk:Lukegao (page does not exist)") | [contribs](https://freemwiki.com/wiki/Special:Contributions/Lukegao "Special:Contributions/Lukegao"))(1 revision imported) ([diff](https://freemwiki.com/index.php?title=Module:Lang&diff=prev&oldid=579704 "Module:Lang")) [← Older revision](https://freemwiki.com/index.php?title=Module:Lang&direction=prev&oldid=579704 "Module:Lang") | Latest revision (diff) | Newer revision → (diff) _Documentation for this module may be created at [Module:Lang/doc](https://freemwiki.com/index.php?title=Module:Lang/doc&action=edit&redlink=1 "Module:Lang/doc (page does not exist)")_ [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1)--[=[[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-3)Lua support for the {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}, {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}, {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}, and {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}} templates and replacement of various supporting templates. [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-4)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-5)]=][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-6)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-7)require('strict');[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-8)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-9)local getArgs = require (['Module:Arguments'](https://freemwiki.com/wiki/Module:Arguments)).getArgs;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-10)local unicode = require (["Module:Unicode data"](https://freemwiki.com/wiki/Module:Unicode_data));-- for is_Latin() and is_rtl()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-11)local yesno = require (['Module:Yesno'](https://freemwiki.com/wiki/Module:Yesno));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-12)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-13)local sandbox = (mw.getCurrentFrame():getTitle():match ('/sandbox') or '');-- when called from a sandbox template or module load sandbox data and sandbox configuration[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-14)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-15)local lang_data = mw.loadData ('Module:Lang/data' .. sandbox);-- language name override and transliteration tool-tip tables[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-16)local lang_name_table = lang_data.lang_name_table;-- language codes, names, regions, scripts, suppressed scripts[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-17)local lang_table = lang_data.lang_name_table.lang;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-18)local lang_dep_table = lang_data.lang_name_table.lang_dep;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-19)local script_table = lang_data.lang_name_table.script;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-20)local region_table = lang_data.lang_name_table.region;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-21)local variant_table = lang_data.lang_name_table.variant;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-22)local suppressed_table = lang_data.lang_name_table.suppressed;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-23)local override_table = lang_data.override;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-24)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-25)local synonym_table = mw.loadData (['Module:Lang/ISO 639 synonyms'](https://freemwiki.com/wiki/Module:Lang/ISO_639_synonyms));-- ISO 639-2/639-2T code translation to 639-1 code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-26)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-27)local cfg = mw.loadData ('Module:Lang/configuration' .. sandbox);-- for internationalization[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-28)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-29)local is_latn_data = mw.loadData (['Module:Lang/data/is latn data'](https://freemwiki.com/wiki/Module:Lang/data/is_latn_data));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-30)local sizeof_ranges_t = is_latn_data.sizeof_ranges_t;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-31)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-32)local namespace = mw.title.getCurrentTitle().namespace;-- used for categorization[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-33)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-34)local content_lang = mw.language.getContentLanguage();[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-35)local this_wiki_lang_tag = content_lang.code;-- get this wiki's language tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-36)local this_wiki_lang_dir = content_lang:getDir();-- get this wiki's language direction[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-37)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-38)local initial_style_state;-- set by lang_xx_normal() and lang_xx_italic()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-39)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-40)local maint_cats = {};-- maintenance categories go here[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-41)local maint_msgs = {};-- and their messages go here[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-42)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-43)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-44)--[[--------------------------< M A K E _ E R R O R _ S P A N >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-45)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-46)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-47)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-48)local function make_error_span (template, msg)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-49)return table.concat ({'', cfg.misc_text_t.error, ': ', template, msg, ''})[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-50)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-51)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-52)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-53)--[[--------------------------< S U B S T I T U T E >----------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-54)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-55)Substitutes $1, $2, etc in with data from . Returns plain-text substituted string when[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-56) not nil; returns else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-57)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-58)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-59)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-60)local function substitute (message, data_t)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-61)return data_t and mw.message.newRawMessage (message, data_t):plain() or message;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-62)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-63)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-64)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-65)--[[--------------------------< M A K E _ E R R O R _ M S G >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-66)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-67)Assembles an error message from template name, message text, help link, and error category.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-68)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-69)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-70)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-71)local function make_error_msg (msg, args_t, template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-72)local category;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-73)local text;-- handle the oddity that is {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-74)if cfg.templates_t.langxx == template then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-75)text = args_t.text or args_t[1];-- for {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-76)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-77)text = args_t.text or args_t[2];-- for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}, {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}, and {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-78)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-79)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-80)if cfg.templates_t.transliteration == template then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-81)category = cfg.make_error_msg_t.xlit_err_cat;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-82)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-83)category = cfg.make_error_msg_t.lang_err_cat;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-84)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-85)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-86)local category_link = ((0 == namespace or 10 == namespace) and not args_t.nocat) and substitute ('[[Category:$1]]', {category}) or '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-87)return substitute ('[$1] $2: {{$3}}: $4 ([[:Category:$5|$6]])$7',-- { prevents template name from being treated as a template call in certain situations[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-88){[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-89)text or cfg.make_error_msg_t.undefined,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-90)cfg.misc_text_t.error,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-91)template,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-92)msg,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-93)category,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-94)cfg.misc_text_t.help,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-95)category_link[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-96)})[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-97)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-98)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-99)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-100)--[[--------------------------< P A R A M E T E R _ V A L I D A T E >------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-101)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-102)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-103)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-104)local function parameter_validate (args_t, template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-105)local err_msg = cfg.parameter_validate_t.invalid_param;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-106)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-107)if cfg.templates_t.lang == template then-- for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-108)for param, _ in pairs (args_t) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-109)if not cfg.known_params_t.params_lang_t[param] and-- unique {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} parameters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-110) not cfg.known_params_t.common_params_all_t[param] then-- common to all[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-111)return substitute (err_msg, {param});-- not found so abandon[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-112)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-113)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-114)elseif cfg.templates_t.langx == template then-- for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-115)for param, _ in pairs (args_t) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-116)if not cfg.known_params_t.params_langx_t[param] and-- unique {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} parameters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-117)not cfg.known_params_t.params_x_t[param] and-- common to {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} and {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-118)not cfg.known_params_t.common_params_all_t[param] then-- common to all[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-119)return substitute (err_msg, {param});-- not found so abandon[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-120)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-121)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-122)elseif cfg.templates_t.langxx == template then-- for {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-123)for param, _ in pairs (args_t) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-124)if not cfg.known_params_t.params_lang_xx_t[param] and-- unique {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}} parameters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-125)not cfg.known_params_t.params_x_t[param] and-- common to {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} and {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-126)not cfg.known_params_t.common_params_all_t[param] then-- common to all[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-127)return substitute (err_msg, {param});-- not found so abandon[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-128)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-129)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-130)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-131)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-132)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-133)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-134)--[[--------------------------< I S _ S E T >------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-135)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-136)Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-137)an empty string.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-138)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-139)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-140)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-141)local function is_set (var)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-142)return not (var == nil or var == '');[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-143)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-144)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-145)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-146)--[[--------------------------< I N V E R T _ I T A L I C S >-------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-147)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-148)This function attempts to invert the italic markup a args.text by adding/removing leading/trailing italic markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-149)in args.text. Like |italic=unset, |italic=invert disables automatic italic markup. Individual leading/trailing[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-150)apostrophes are converted to their HTML numeric entity equivalent so that the new italic markup doesn't become[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-151)bold markup inadvertently.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-152)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-153)Leading and trailing wiki markup is extracted from args.text into separate table elements. Addition, removal,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-154)replacement of wiki markup is handled by a string.gsub() replacement table operating only on these separate elements.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-155)In the string.gsub() matching pattern, '.*' matches empty string as well as the three expected wiki markup patterns.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-156)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-157)This function expects that markup in args.text is complete and correct; if it is not, oddness may result.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-158)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-159)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-160)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-161)local function invert_italics (source)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-162)local invert_pattern_table = {-- leading/trailing markup add/remove/replace patterns[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-163)[""]="\'\'",-- empty string becomes italic markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-164)["\'\'"]="",-- italic markup becomes empty string[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-165)["\'\'\'"]="\'\'\'\'\'",-- bold becomes bold italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-166)["\'\'\'\'\'"]="\'\'\'",-- bold italic become bold[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-167)};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-168)local seg = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-169)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-170)source = source:gsub ("%f[\']\'%f[^\']", ''');-- protect single quote marks from being interpreted as bold markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-171)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-172)seg[1] = source:match ('^(\'\'+%f[^\']).+') or '';-- get leading markup, if any; ignore single quote[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-173)seg[3] = source:match ('.+(%f[\']\'\'+)$') or '';-- get trailing markup, if any; ignore single quote[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-174)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-175)if '' ~= seg[1] and '' ~= seg[3] then-- extract the 'text' [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-176)seg[2] = source:match ('^\'\'+%f[^\'](.+)%f[\']\'\'+$')-- from between leading and trailing markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-177)elseif '' ~= seg[1] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-178)seg[2] = source:match ('^\'\'+%f[^\'](.+)')-- following leading markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-179)elseif '' ~= seg[3] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-180)seg[2] = source:match ('(.+)%f[\']\'\'+$')-- preceding trailing markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-181)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-182)seg[2] = source-- when there is no markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-183)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-184)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-185)seg[1] = invert_pattern_table[seg[1]] or seg[1];-- replace leading markup according to pattern table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-186)seg[3] = invert_pattern_table[seg[3]] or seg[3];-- replace leading markup according to pattern table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-187)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-188)return table.concat (seg);-- put it all back together and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-189)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-190)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-191)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-192)--[[--------------------------< V A L I D A T E _ I T A L I C >------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-193)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-194)Validates |italic= or |italics= assigned values.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-195)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-196)When |italic= is set and has an acceptable assigned value, return the matching CSS font-style property value or,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-197)for the special case 'default', return nil.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-198)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-199)When |italic= is not set, or has an unacceptable assigned value, return nil and a nil error message.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-200)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-201)When both |italic= and |italics= are set, returns nil and a 'conflicting' error message.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-202)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-203)The return value nil causes the calling lang, lang_xx, or xlit function to set args.italic according to the template's[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-204)defined default ('inherit' for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}, 'inherit' or 'italic' for {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} depending on[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-205)the individual template's requirements, 'italic' for {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}}) or to the value appropriate to |script=, if set ({{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-206)and {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} only).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-207)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-208)Accepted values and the values that this function returns are are:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-209) nil - when |italic= absent or not set; returns nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-210) default - for completeness, should rarely if ever be used; returns nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-211) yes - force args.text to be rendered in italic font; returns 'italic'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-212) no - force args.text to be rendered in normal font; returns 'normal'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-213) unset - disables font control so that font-style applied to text is dictated by markup inside or outside the template; returns 'inherit'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-214) invert - disables font control so that font-style applied to text is dictated by markup outside or inverted inside the template; returns 'invert'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-215)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-216)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-217)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-218)local function validate_italic (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-219)local properties = {[cfg.keywords_t.affirmative] = 'italic', [cfg.keywords_t.negative] = 'normal', [cfg.keywords_t.unset] = 'inherit', [cfg.keywords_t.invert] = 'invert', [cfg.keywords_t.default] = nil};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-220)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-221)local count = 0[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-222)for _, arg in pairs {'italic', 'italics', 'i'} do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-223)if args[arg] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-224)count = count + 1[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-225)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-226)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-227)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-228)if count > 1 then-- return nil and an error message if more than one is set [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-229)return nil, cfg.validate_italic_t.multi_italic;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-230)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-231)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-232)return properties[args.italic or args.italics or args.i], nil;-- return an appropriate value and a nil error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-233)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-234)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-235)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-236)--[=[--------------------------< V A L I D A T E _ C A T _ A R G S >----------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-237)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-238)Default behavior of the {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} and {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates is to add categorization when the templates are used in main space.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-239)This default functionality may be suppressed by setting |nocat=yes or |cat=no. This function selects one of these two parameters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-240)to control categorization.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-241)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-242)Because having two parameters with 'opposite' names and 'opposite' values is confusing, this function accepts only affirmative[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-243)values for |nocat= and only negative values for |cat=; in both cases the 'other' sense (and non-sense) is not accepted and the[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-244)parameter is treated as if it were not set in the template.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-245)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-246)Sets args.nocat to true if categorization is to be turned off; to nil if the default behavior should apply.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-247)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-248)Accepted values for |nocat= are the text strings:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-249) 'yes', 'y', 'true', 't', on, '1' -- [[[Module:Yesno]]](https://freemwiki.com/wiki/Module:Yesno "Module:Yesno") returns logical true for all of these; false or nil else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-250)for |cat=[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-251) 'no', 'n', 'false', 'f', 'off', '0' -- [[[Module:Yesno]]](https://freemwiki.com/wiki/Module:Yesno "Module:Yesno") returns logical false for all of these; true or nil else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-252)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-253)]=][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-254)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-255)local function validate_cat_args (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-256)if not (args.nocat or args.cat) then-- both are nil, so categorize[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-257)return;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-258)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-259)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-260)if false == yesno (args.cat) or true == yesno (args.nocat) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-261)args.nocat = true;-- set to true when args.nocat is affirmative; nil else (as if the parameter were not set in the template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-262)else-- args.nocat is the parameter actually used.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-263)args.nocat = nil;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-264)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-265)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-266)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-267)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-268)--[[--------------------------< I N _ A R R A Y >--------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-269)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-270)Whether needle is in haystack.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-271)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-272)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-273)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-274)local function in_array (needle, haystack)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-275)if needle == nil then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-276)return false;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-277)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-278)for n,v in ipairs (haystack) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-279)if v == needle then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-280)return n;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-281)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-282)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-283)return false;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-284)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-285)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-286)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-287)--[[--------------------------< F O R M A T _ I E T F _ T A G >------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-288)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-289)Prettify IETF tags to use recommended subtag formats:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-290) code: lower case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-291) script: sentence case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-292) region: upper case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-293) variant: lower case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-294) private: lower case prefixed with -x-[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-295)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-296)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-297)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-298)local function format_ietf_tag (code, script, region, variant, private)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-299)local out = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-300)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-301)if is_set (private) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-302)return table.concat ({code:lower(), 'x', private:lower()}, '-');-- if private, all other tags ignored[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-303)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-304)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-305)table.insert (out, code:lower());[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-306)if is_set (script) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-307)script = script:lower():gsub ('^%a', string.upper);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-308)table.insert (out, script);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-309)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-310)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-311)if is_set (region) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-312)table.insert (out, region:upper());[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-313)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-314)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-315)if is_set (variant) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-316)table.insert (out, variant:lower());[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-317)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-318)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-319)return table.concat (out, '-');[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-320)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-321)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-322)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-323)--[[--------------------------< G E T _ I E T F _ P A R T S >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-324)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-325)Extracts and returns IETF language tag parts:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-326) primary language subtag (required) - 2 or 3 character IANA language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-327) script subtag - four character IANA script code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-328) region subtag - two-letter or three digit IANA region code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-329) variant subtag - four digit or 5-8 alnum variant code; only one variant subtag supported[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-330) private subtag - x- followed by 1-8 alnum private code; only supported with the primary language tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-331)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-332)in any one of these forms[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-333) lang lang-variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-334) lang-script lang-script-variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-335) lang-region lang-region-variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-336) lang-script-region lang-script-region-variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-337) lang-x-private [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-338)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-339)each of lang, script, region, variant, and private, when used, must be valid.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-340)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-341)Languages with both two- and three-character code synonyms are promoted to the two-character synonym because[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-342)the IANA registry file omits the synonymous three-character code; we cannot depend on browsers understanding[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-343)the synonymous three-character codes in the lang= attribute.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-344)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-345)For {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates, the parameters |script=, |region=, and |variant= are supported (not supported in {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-346)because those parameters are superfluous to the IETF subtags in |code=).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-347)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-348)Returns six values; all lower case. Valid parts are returned as themselves; omitted parts are returned as empty strings, invalid[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-349)parts are returned as nil; the sixth returned item is an error message (if an error detected) or nil.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-350)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-351)See [http://www.rfc-editor.org/rfc/bcp/bcp47.txt](http://www.rfc-editor.org/rfc/bcp/bcp47.txt) section 2.1.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-352)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-353)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-354)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-355)local function get_ietf_parts (source, args_script, args_region, args_variant)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-356)local code, script, region, variant, private;-- IETF tag parts[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-357)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-358)if not is_set (source) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-359)return nil, nil, nil, nil, nil, cfg.get_ietf_parts_t.missing_lang_tag;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-360)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-361)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-362)local pattern = {-- table of tables holding acceptable IETF tag patterns and short names of the IETF part captured by the pattern[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-363){'^(%a%a%a?)%-(%a%a%a%a)%-(%a%a)%-(%d%d%d%d)$', 's', 'r', 'v'}, -- 1 - ll-Ssss-RR-variant (where variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-364){'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d)%-(%d%d%d%d)$', 's', 'r', 'v'},-- 2 - ll-Ssss-DDD-variant (where region is 3 digits; variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-365){'^(%a%a%a?)%-(%a%a%a%a)%-(%a%a)%-(%w%w%w%w%w%w?%w?%w?)$', 's', 'r', 'v'},-- 3 - ll-Ssss-RR-variant (where variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-366){'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d)%-(%w%w%w%w%w%w?%w?%w?)$', 's', 'r', 'v'},-- 4 - ll-Ssss-DDD-variant (where region is 3 digits; variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-367)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-368){'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d%d)$', 's', 'v'},-- 5 - ll-Ssss-variant (where variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-369){'^(%a%a%a?)%-(%a%a%a%a)%-(%w%w%w%w%w%w?%w?%w?)$', 's', 'v'},-- 6 - ll-Ssss-variant (where variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-370)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-371){'^(%a%a%a?)%-(%a%a)%-(%d%d%d%d)$', 'r', 'v'},-- 7 - ll-RR-variant (where variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-372){'^(%a%a%a?)%-(%d%d%d)%-(%d%d%d%d)$', 'r', 'v'},-- 8 - ll-DDD-variant (where region is 3 digits; variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-373){'^(%a%a%a?)%-(%a%a)%-(%w%w%w%w%w%w?%w?%w?)$', 'r', 'v'},-- 9 - ll-RR-variant (where variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-374){'^(%a%a%a?)%-(%d%d%d)%-(%w%w%w%w%w%w?%w?%w?)$', 'r', 'v'},-- 10 - ll-DDD-variant (where region is 3 digits; variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-375)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-376){'^(%a%a%a?)%-(%d%d%d%d)$', 'v'},-- 11 - ll-variant (where variant is 4 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-377){'^(%a%a%a?)%-(%w%w%w%w%w%w?%w?%w?)$', 'v'},-- 12 - ll-variant (where variant is 5-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-378)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-379){'^(%a%a%a?)%-(%a%a%a%a)%-(%a%a)$', 's', 'r'},-- 13 - ll-Ssss-RR[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-380){'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d)$', 's', 'r'},-- 14 - ll-Ssss-DDD (region is 3 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-381)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-382){'^(%a%a%a?)%-(%a%a%a%a)$', 's'},-- 15 - ll-Ssss[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-383)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-384){'^(%a%a%a?)%-(%a%a)$', 'r'},-- 16 - ll-RR[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-385){'^(%a%a%a?)%-(%d%d%d)$', 'r'},-- 17 - ll-DDD (region is 3 digits)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-386)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-387){'^(%a%a%a?)$'},-- 18 - ll[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-388)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-389){'^(%a%a%a?)%-x%-(%w%w?%w?%w?%w?%w?%w?%w?)$', 'p'},-- 19 - ll-x-pppppppp (private is 1-8 alnum characters)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-390)}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-391)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-392)local t = {};-- table of captures; serves as a translator between captured IETF tag parts and named variables[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-393)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-394)for i, v in ipairs (pattern) do-- spin through the pattern table looking for a match[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-395)local c1, c2, c3, c4;-- captures in the 'pattern' from the pattern table go here[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-396)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-397)c1, c2, c3, c4 = source:match (pattern[i][1]);-- one or more captures set if source matches pattern[i])[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-398)if c1 then-- c1 always set on match[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-399)code = c1;-- first capture is always code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-400)t = {[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-401)[pattern[i][2] or 'x'] = c2,-- fill the table of captures with the rest of the captures[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-402)[pattern[i][3] or 'x'] = c3,-- take index names from pattern table and assign sequential captures[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-403)[pattern[i][4] or 'x'] = c4,-- index name may be nil in pattern[i] table so "or 'x'" spoofs a name for this index in this table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-404)};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-405)script = t.s or '';-- translate table contents to named variables;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-406)region = t.r or '';-- absent table entries are nil so set named IETF parts to empty string for concatenation[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-407)variant= t.v or '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-408)private = t.p or '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-409)break;-- and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-410)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-411)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-412)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-413)if not code then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-414)return nil, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_tag, {source});-- don't know what we got but it is malformed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-415)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-416)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-417)code = code:lower();-- ensure that we use and return lower case version of this[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-418)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-419)if not (override_table[code] or lang_table[code] or synonym_table[code] or lang_dep_table[code]) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-420)return nil, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_code, {code});-- invalid language code, don't know about the others (don't care?)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-421)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-422)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-423)if synonym_table[code] then-- if 639-2/639-2T code has a 639-1 synonym[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-424)table.insert (maint_cats, substitute (cfg.get_ietf_parts_t.maint_promo_cat, {code}));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-425)table.insert (maint_msgs, substitute (cfg.get_ietf_parts_t.maint_promo_msg, {code, synonym_table[code]}));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-426)code = synonym_table[code];-- use the synonym[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-427)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-428)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-429)if is_set (script) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-430)if is_set (args_script) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-431)return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_scr;-- both code with script and |script= not allowed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-432)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-433)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-434)script = args_script or '';-- use args.script if provided[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-435)end [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-436)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-437)if is_set (script) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-438)script = script:lower();-- ensure that we use and return lower case version of this[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-439)if not script_table[script] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-440)return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_scr_code, {script, code});-- language code OK, invalid script, don't know about the others (don't care?)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-441)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-442)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-443)if suppressed_table[script] then-- ensure that code-script does not use a suppressed script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-444)if in_array (code, suppressed_table[script]) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-445)return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.script_code, {script, code});-- language code OK, script is suppressed for this code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-446)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-447)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-448)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-449)if is_set (region) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-450)if is_set (args_region) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-451)return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_reg;-- both code with region and |region= not allowed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-452)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-453)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-454)region = args_region or '';-- use args.region if provided[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-455)end [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-456)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-457)if is_set (region) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-458)region = region:lower();-- ensure that we use and return lower case version of this[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-459)if not region_table[region] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-460)return code, script, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_reg_code, {region, code});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-461)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-462)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-463)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-464)if is_set (variant) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-465)if is_set (args_variant) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-466)return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_var;-- both code with variant and |variant= not allowed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-467)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-468)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-469)variant = args_variant or '';-- use args.variant if provided[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-470)end [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-471)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-472)if is_set (variant) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-473)variant = variant:lower();-- ensure that we use and return lower case version of this[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-474)if not variant_table[variant] then-- make sure variant is valid[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-475)return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var, {variant});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-476)end-- does this duplicate/replace tests in lang() and lang_xx()?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-477)if is_set (script) then-- if script set it must be part of the 'prefix'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-478)if not in_array (table.concat ({code, '-', script}), variant_table[variant]['prefixes']) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-479)return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code_scr, {variant, code, script});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-480)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-481)elseif is_set (region) then-- if region set, there are some prefixes that require lang code and region (en-CA-newfound)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-482)if not in_array (code, variant_table[variant]['prefixes']) then-- first see if lang code is all that's required (en-oxendict though en-GB-oxendict is preferred)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-483)if not in_array (table.concat ({code, '-', region}), variant_table[variant]['prefixes']) then-- now try for lang code and region (en-CA-newfound)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-484)return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code_reg, {variant, code, region});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-485)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-486)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-487)else-- cheap way to determine if there are prefixes; fonipa and others don't have prefixes; # operator always returns 0[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-488)if variant_table[variant]['prefixes'][1] and not in_array (code, variant_table[variant]['prefixes']) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-489)return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code, {variant, code});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-490)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-491)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-492)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-493)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-494)if is_set (private) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-495)private = private:lower();-- ensure that we use and return lower case version of this[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-496)if not override_table[table.concat ({code, '-x-', private})] then-- make sure private tag is valid; note that index [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-497)return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_pri, {private});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-498)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-499)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-500)return code, script, region, variant, private, nil;-- return the good bits; make sure that msg is nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-501)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-502)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-503)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-504)--[=[-------------------------< M A K E _ W I K I L I N K >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-505)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-506)Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[[L|D]]](https://freemwiki.com/wiki/L "L"); if only[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-507)link is provided, returns a wikilink in the form [[[L]]](https://freemwiki.com/wiki/L "L"); if neither are provided or link is omitted, returns an[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-508)empty string.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-509)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-510)]=][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-511)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-512)local function make_wikilink (link, display)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-513)if is_set (link) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-514)if is_set (display) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-515)return table.concat ({'[[', link, '|', display, ']]'});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-516)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-517)return table.concat ({'[[', link, ']]'});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-518)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-519)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-520)return '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-521)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-522)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-523)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-524)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-525)--[[--------------------------< D I V _ M A R K U P _ A D D >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-526)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-527)Adds and tags to list-item text or to implied

..

text. Mixed not supported.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-528)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-529)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-530)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-531)local function div_markup_add (text, style)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-532)if text:find ('^\n[%*:;#]') then-- look for list markup; list markup must begin at start of text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-533)if 'italic' == style then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-534)return text:gsub ('(\n[%*:;#]+)([^\n]+)', '%1%2');-- insert italic markup at each list item[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-535)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-536)return text;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-537)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-538)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-539)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-540)if text:find ('\n+') then-- look for any number of \n characters in text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-541)text = text:gsub ('([^\n])\n([^\n])', '%1 %2');-- replace single newline characters with a space character which mimics MediaWiki[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-542)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-543)if 'italic' == style then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-544)text = text:gsub('[^\n]+', '

%1

');-- insert p and italic markup tags at each implied p (two or more consecutive '\n\n' sequences)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-545)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-546)text = text:gsub ('[^\n]+', '

%1

');-- insert p markup at each implied p[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-547)text = text:gsub ('\n', '');-- strip newline characters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-548)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-549)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-550)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-551)return text;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-552)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-553)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-554)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-555)--[[--------------------------< T I T L E _ W R A P P E R _ M A K E >------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-556)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-557)Makes a or
where[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-558) is in the tool-tip in the wiki's local language and <content_text> is non-local-language text in[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-559)HTML markup. This because the lang= attribute applies to the content of its enclosing tag.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-560)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-561)<tag> holds a string 'div' or 'span' used to choose the correct wrapping tag.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-562)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-563)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-564)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-565)local function title_wrapper_make (title_text, content_text, tag)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-566)local wrapper_t = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-567)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-568)table.insert (wrapper_t, table.concat ({'<', tag}));-- open opening wrapper tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-569)table.insert (wrapper_t, ' title=\"');-- begin title attribute[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-570)table.insert (wrapper_t, title_text);-- add <title_text>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-571)table.insert (wrapper_t, '\">');-- end title attribute and close opening wrapper tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-572)table.insert (wrapper_t, content_text);-- add <content_text>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-573)table.insert (wrapper_t, table.concat ({'</', tag, '>'}));-- add closing wrapper tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-574)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-575)return table.concat (wrapper_t);-- make a big string and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-576)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-577)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-578)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-579)--[[--------------------------< M A K E _ T E X T _ H T M L >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-580)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-581)Add the HTML markup to text according to the type of content that it is: <span> or <i> tags for inline content or[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-582)<div> tags for block content[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-583)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-584)The lang= attribute also applies to the content of the tag where it is placed so this is wrong because 'Spanish[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-585)language text' is English:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-586)<i lang="es" title="Spanish language text">casa</i>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-587)should be:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-588)<span title="Spanish language text"><i lang="es">casa</i></span>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-589)or for <div>...</div>:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-590)<div title="Spanish language text"><div lang="es"><spanish-language-text></div></div>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-591)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-592)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-593)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-594)local function make_text_html (code, text, tag, rtl, style, size, language)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-595)local html_t = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-596)local style_added = '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-597)local wrapper_tag = tag;-- <tag> gets modified so save a copy for use when/if we create a wrapper span or div[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-598)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-599)if text:match ('^%*') then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-600)table.insert (html_t, '*');-- move proto language text prefix outside of italic markup if any; use numeric entity because plain splat confuses MediaWiki[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-601)text = text:gsub ('^%*', '');-- remove the splat from the text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-602)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-603)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-604)if 'span' == tag then-- default HTML tag for inline content[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-605)if 'italic' == style then-- but if italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-606)tag = 'i';-- change to <i> tags[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-607)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-608)else-- must be div so go[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-609)text = div_markup_add (text, style);-- handle implied <p>, implied <p> with <i>, and list markup (*;:#) with <i>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-610)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-611)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-612)table.insert (html_t, table.concat ({'<', tag}));-- open the <i>, <span>, or <div> HTML tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-613)code = code:gsub ('%-x%-.*', '');-- strip private use subtag from code tag because meaningless outside of Wikipedia[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-614)table.insert (html_t, table.concat ({' lang="', code, '\"'}));-- add language attribute[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-615)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-616)if (rtl or unicode.is_rtl(text)) and ('ltr' == this_wiki_lang_dir) then-- text is right-to-left on a left-to-right wiki[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-617)table.insert (html_t, ' dir="rtl"');-- add direction attribute for right-to-left languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-618)elseif not (rtl or unicode.is_rtl(text)) and ('rtl' == this_wiki_lang_dir) then-- text is left-to-right on a right-to-left wiki[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-619)table.insert (html_t, ' dir="ltr"');-- add direction attribute for left-to-right languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-620)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-621)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-622)if 'normal' == style then-- when |italic=no[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-623)table.insert (html_t, ' style=\"font-style: normal;');-- override external markup, if any[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-624)style_added = '\"';-- remember that style attribute added and is not yet closed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-625)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-626)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-627)if is_set (size) then-- when |size=<something>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-628)if is_set (style_added) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-629)table.insert (html_t, table.concat ({' font-size: ', size, ';'}));-- add when style attribute already inserted[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-630)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-631)table.insert (html_t, table.concat ({' style=\"font-size: ', size, ';'}));-- create style attribute[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-632)style_added = '\"';-- remember that style attribute added and is not yet closed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-633)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-634)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-635)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-636)table.insert (html_t, table.concat ({style_added, '>'}));-- close the opening HTML tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-637)table.insert (html_t, text);-- insert the text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-638)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-639)table.insert (html_t, table.concat ({'</', tag, '>'}));-- close the 'text' <i>, <span>, or <div> HTML tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-640)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-641)if is_set (language) then-- create a <title_text> string for the title= attribute in a wrapper span or div[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-642)local title_text;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-643)if 'zxx' == code then-- special case for this tag 'no linguistic content'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-644)title_text = substitute ('$1 $2', {language, cfg.make_text_html_t.zxx});-- not a language so don't use 'language' in title text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-645)elseif mw.ustring.find (language, 'languages', 1, true) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-646)title_text = substitute ('$1 $2', {language, cfg.make_text_html_t.collective});-- for collective languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-647)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-648)title_text = substitute ('$1-$2', {language, cfg.make_text_html_t.individual});-- for individual languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-649)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-650)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-651)return title_wrapper_make (title_text, table.concat (html_t), wrapper_tag);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-652)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-653)return table.concat (html_t);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-654)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-655)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-656)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-657)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-658)--[=[-------------------------< M A K E _ C A T E G O R Y >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-659)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-660)For individual language, <language>, returns:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-661) [[Category:Articles containing <language>-language text]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-662)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-663)For English:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-664)[[[Category:Articles containing explicitly cited English-language text]]](https://freemwiki.com/wiki/Category:Articles_containing_explicitly_cited_English-language_text "Category:Articles containing explicitly cited English-language text")[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-665)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-666)For ISO 639-2 collective languages (and for 639-1 bh):[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-667) [[Category:Articles with text in <language> languages]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-668)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-669)]=][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-670)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-671)local function make_category (code, language_name, nocat, name_get)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-672)if ((0 ~= namespace) or nocat) and not name_get then-- only categorize in article space[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-673)return '';-- return empty string for concatenation[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-674)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-675)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-676)if mw.ustring.find (language_name, 'languages', 1, true) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-677)return substitute ('[[$1 $2]]', {cfg.make_category_t.collective_cat, language_name});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-678)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-679)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-680)if this_wiki_lang_tag == code then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-681)return substitute ('[[$1 $2 $3-$4]]', {-- unique category name for the local language[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-682)cfg.make_category_t.cat_prefix,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-683)cfg.make_category_t.explicit_cat,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-684)language_name,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-685)cfg.make_category_t.cat_postfix,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-686)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-687)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-688)return substitute ('[[$1 $2-$3]]', {-- category for individual languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-689)cfg.make_category_t.cat_prefix,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-690)language_name,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-691)cfg.make_category_t.cat_postfix,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-692)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-693)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-694)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-695)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-696)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-697)--[[--------------------------< M A K E _ T R A N S L I T >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-698)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-699)Return translit <i lang=xx-Latn>...</i> where xx is the language code; else return empty string.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-700)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-701)The value |script= is not used in {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}} for this purpose; instead it uses |code. Because language scripts[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-702)are listed in the {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}} switches they are included in the data tables. The script parameter is introduced[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-703)at {{[Language with name and transliteration](https://freemwiki.com/wiki/Template:Language_with_name_and_transliteration "Template:Language with name and transliteration")}}. If |script= is set, this function uses it in preference to code.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-704)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-705)To avoid confusion, in this module and the templates that use it, the transliteration script parameter is renamed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-706)to be |translit-script= (in this function, tscript).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-707)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-708)This function is used by both lang_xx() and xlit()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-709) lang_xx() always provides code, language_name, and translit; may provide tscript; never provides style[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-710) xlit() always provides language_name, translit, and one of code or tscript, never both; always provides style[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-711)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-712)For {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}}, style only applies when a language code is provided.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-713)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-714)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-715)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-716)local function make_translit (code, language_name, translit, std, tscript, style, engvar)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-717)local title_t = lang_data.translit_title_table;-- table of transliteration standards and the language codes and scripts that apply to those standards[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-718)local title_text = '';-- tool tip text for title= attribute[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-719)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-720)std = std and std:lower();-- lower case for table indexing[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-721)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-722)if not is_set (std) and not is_set (tscript) then-- when neither standard nor script specified[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-723)title_text = language_name;-- write a generic tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-724)if not mw.ustring.find (language_name, 'languages', 1, true) then-- collective language names (plural 'languages' is part of the name)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-725)title_text = substitute ('$1-$2', {title_text, cfg.misc_text_t.language});-- skip this text (individual and macro languages only)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-726)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-727)title_text = substitute ('$1 $2', {title_text, mw.ustring.lower (cfg.engvar_t[engvar]['romanisz_lc'])});-- finish the tool tip; use romanization when neither script nor standard supplied[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-728)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-729)elseif is_set (std) and is_set (tscript) then-- when both are specified[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-730)if title_t[std] then-- and if standard is legitimate[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-731)if title_t[std][tscript] then-- and if script for that standard is legitimate[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-732)if script_table[tscript] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-733)title_text = substitute ('$1$2 ($3 $4) $5', {-- add the appropriate text to the tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-734)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-735)title_t[std][tscript:lower()],[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-736)script_table[tscript],[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-737)cfg.make_translit_t.script,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-738)cfg.make_translit_t.transliteration,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-739)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-740)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-741)title_text = title_text .. title_t[std]['default'];-- use the default if script not in std table; TODO: maint cat? error message because script not found for this standard?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-742)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-743)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-744)title_text = title_text .. title_t[std]['default'];-- use the default if script not in std table; TODO: maint cat? error message because script not found for this standard?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-745)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-746)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-747)return '';-- invalid standard, setup for error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-748)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-749)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-750)elseif is_set (std) then-- translit-script not set, use language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-751)if not title_t[std] then return ''; end-- invalid standard, setup for error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-752)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-753)if title_t[std][code] then-- if language code is in the table (xlit may not provide a language code)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-754)title_text = substitute ('$1$2 ($3 $4) $5', {-- add the appropriate text to the tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-755)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-756)title_t[std][code:lower()],[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-757)language_name,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-758)cfg.misc_text_t.language,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-759)cfg.make_translit_t.transliteration,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-760)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-761)else-- code doesn't match[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-762)title_text = title_text .. title_t[std]['default'];-- so use the standard's default[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-763)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-764)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-765)else-- here if translit-script set but translit-std not set[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-766)if title_t['no_std'][tscript] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-767)title_text = title_text .. title_t['no_std'][tscript];-- use translit-script if set[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-768)elseif title_t['no_std'][code] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-769)title_text = title_text .. title_t['no_std'][code];-- use language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-770)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-771)if is_set (tscript) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-772)title_text = substitute ('$1$2-$3 $4', {-- write a script tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-773)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-774)language_name,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-775)cfg.make_translit_t.script,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-776)cfg.make_translit_t.transliteration,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-777)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-778)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-779)elseif is_set (code) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-780)if not mw.ustring.find (language_name, 'languages', 1, true) then-- collective language names (plural 'languages' is part of the name)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-781)title_text = substitute ('$1-$2', {-- skip this text (individual and macro languages only)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-782)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-783)cfg.misc_text_t.language,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-784)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-785)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-786)title_text = substitute ('$1 $2', {-- finish the tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-787)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-788)cfg.make_translit_t.transliteration,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-789)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-790)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-791)title_text = substitute ('$1 $2', {-- generic tool tip (can we ever get here?)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-792)title_text,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-793)cfg.make_translit_t.transliteration,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-794)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-795)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-796)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-797)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-798)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-799)local tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-800)if is_set (code) then-- when a language code is provided (always with {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates, not always with {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}})[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-801)code = code:match ('^(%a%a%a?)');-- strip all subtags leaving only the language subtag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-802)if not style then-- nil for the default italic style[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-803)tag = '<i lang="%s-Latn">%s</i>'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-804)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-805)tag = '<span style="font-style: %s" lang="%s-Latn">%s</span>'-- non-standard style, construct a span tag for it[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-806)tag = string.format(tag, style, "%s", "%s")[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-807)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-808)tag = string.format(tag, code, "%s")[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-809)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-810)tag = '<span>%s</span>'-- when no language code: no lang= attribute, not italic ({{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}} only)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-811)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-812)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-813)tag = string.format(tag, translit)-- add the translit text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-814)if '' == title_text then-- when there is no need for a tool-tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-815)return tag;-- done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-816)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-817)title_text = cfg.engvar_sel_t.gb == engvar and title_text:gsub ('([Rr]omani)z', '%1s') or title_text;-- gb eng when engvar specifies gb eng; us eng else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-818)return title_wrapper_make (title_text, tag, 'span');-- wrap with a tool-tip span and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-819)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-820)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-821)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-822)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-823)--[[--------------------------< V A L I D A T E _ T E X T >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-824)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-825)This function checks the content of args.text and returns empty string if nothing is amiss else it returns an[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-826)error message. The tests are for empty or missing text and for improper or disallowed use of apostrophe markup.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-827)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-828)Italic rendering is controlled by the |italic= template parameter so italic markup should never appear in args.text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-829)either as ''itself'' or as '''''bold italic''''' unless |italic=unset or |italic=invert.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-830)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-831)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-832)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-833)local function validate_text (template, args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-834)if not is_set (args.text) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-835)return make_error_msg (cfg.validate_text_t.no_text, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-836)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-837)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-838)if args.text:find ("%f[\']\'\'\'\'%f[^\']") or args.text:find ("\'\'\'\'\'[\']+") then-- because we're looking, look for 4 appostrophes or 6+ appostrophes[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-839)return make_error_msg (cfg.validate_text_t.malformed_markup, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-840)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-841)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-842)local style = args.italic;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-843)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-844)if (cfg.keywords_t.unset ~= style) and (cfg.keywords_t.invert ~=style) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-845)if args.text:find ("%f[\']\'\'%f[^\']") or args.text:find ("%f[\']\'\'\'\'\'%f[^\']") then-- italic but not bold, or bold italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-846)return make_error_msg (cfg.validate_text_t.italic_markup, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-847)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-848)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-849)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-850)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-851)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-852)--[[--------------------------< R E N D E R _ M A I N T >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-853)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-854)Render mainenance messages and categories.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-855)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-856)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-857)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-858)local function render_maint (nocat)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-859)local maint = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-860)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-861)if 0 < #maint_msgs then-- when there are maintenance messages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-862)table.insert (maint, table.concat ({'<span class="lang-comment" style="font-style: normal; display: none; color: #33aa33; margin-left: 0.3em;">'}));-- opening <span> tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-863)for _, msg in ipairs (maint_msgs) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-864)table.insert (maint, table.concat ({msg, ' '}));-- add message strings[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-865)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-866)table.insert (maint, '</span>');-- close the span[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-867)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-868)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-869)if (0 < #maint_cats) and (0 == namespace) and not nocat then-- when there are maintenance categories; article namespace only[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-870)for _, cat in ipairs (maint_cats) do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-871)table.insert (maint, table.concat ({'[[Category:', cat, ']]'}));-- format and add the categories[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-872)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-873)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-874)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-875)return table.concat (maint);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-876)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-877)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-878)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-879)--[[--------------------------< P R O T O _ P R E F I X >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-880)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-881)For proto languages, text is prefixed with a splat. We do that here as a flag for make_text_html() so that a splat[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-882)will be rendered outside of italic markup (if used). If the first character in text here is already a splat, we[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-883)do nothing.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-884)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-885)proto_param is boolean or nil; true adds splat prefix regardless of language name; false removes and inhibits[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-886)regardless of language name; nil does nothing; presumes that the value in text is correct but removes extra splac.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-887)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-888)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-889)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-890)local function proto_prefix (text, language_name, proto_param)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-891)if false == proto_param then-- when forced by |proto=no[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-892)return text:gsub ('^%**', '');-- return text without splat prefix regardless of language name or existing splat prefix in text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-893)elseif (language_name:find ('^Proto%-') or (true == proto_param)) then-- language is a proto or forced by |proto=yes[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-894)return text:gsub ('^%**', '*');-- prefix proto-language text with a splat; also removes duplicate prefixing splats[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-895)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-896)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-897)return text:gsub ('^%*+', '*');-- return text unmolested except multiple splats reduced to one splat[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-898)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-899)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-900)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-901)--[[--------------------------< H A S _ P O E M _ T A G >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-902)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-903)Looks for a poem strip marker in text; returns true when found; false else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-904)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-905)Auto-italic detection disabled when text has poem stripmarker because it is not possible for this code to know[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-906)the content that will replace the stripmarker.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-907)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-908)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-909)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-910)local function has_poem_tag (text)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-911)return text:find ('\127[^\127]*UNIQ%-%-poem%-[%a%d]+%-QINU[^\127]*\127') and true or false;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-912)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-913)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-914)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-915)--[[--------------------------< H T M L _ T A G _ S E L E C T >------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-916)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-917)Inspects content of and selectively trims text. Returns text and the name of an appropriate HTML tag for text.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-918)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-919)If text contains:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-920) \n\n text has implied <p>..</p> tags - trim leading and trailing whitespace and return [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-921)If text begins with list markup:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-922) \n* unordered[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-923) \n; definition[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-924) \n: definition[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-925) \n# ordered[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-926)trim all leading whitespace except \n and trim all trailing whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-927)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-928)If text contains <poem>...</poem> stripmarker, return text unmodified and choose <div>..</div> tags because [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-929)the stripmarker is replaced with text wrapped in <div>..</div> tags.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-930)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-931)If the text contains any actual <div>...</div> tags, then it's again returned unmodified and <div>...</div>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-932)tags are used to wrap it, to prevent div/span inversion.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-933)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-934)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-935)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-936)local function html_tag_select (text)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-937)local tag;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-938)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-939)if has_poem_tag (text) then-- contains poem stripmarker (we can't know the content of that)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-940)tag = 'div';-- poem replacement is in div tags so lang must use div tags[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-941)elseif text:find ('<div') then-- reductive; if the text contains a div tag, we must use div tags[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-942)tag = 'div';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-943)elseif mw.text.trim (text):find ('\n\n+') then-- contains implied p tags[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-944)text = mw.text.trim (text);-- trim leading and trailing whitespace characters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-945)tag = 'div';-- must be div because span may not contain p tags (added later by MediaWiki); poem replacement is in div tags[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-946)elseif text:find ('\n[%*:;%#]') then-- if text has list markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-947)text = text:gsub ('^[\t\r\f ]*', ''):gsub ('%s*$', '');-- trim all whitespace except leading newline character '\n'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-948)tag = 'div';-- must be div because span may not contain ul, dd, dl, ol tags (added later by MediaWiki)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-949)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-950)text = mw.text.trim (text);-- plain text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-951)tag = 'span';-- so span is fine[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-952)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-953)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-954)return text, tag;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-955)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-956)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-957)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-958)--[[--------------------------< V A L I D A T E _ P R O T O >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-959)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-960)Validates value assigned to |proto=; permitted values are yes and no; yes returns as true, no returns as false,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-961)empty string (or parameter omitted) returns as nil; any other value returns nil with <proto_param> as second[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-962)return value for use in error message.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-963)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-964)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-965)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-966)local function validate_proto (proto_param)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-967)if cfg.keywords_t.affirmative == proto_param then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-968)return true;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-969)elseif cfg.keywords_t.negative == proto_param then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-970)return false;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-971)elseif is_set (proto_param) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-972)return nil, proto_param;-- |proto= something other than 'yes' or 'no'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-973)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-974)return nil;-- missing or empty[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-975)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-976)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-977)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-978)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-979)--[[--------------------------< L A N G U A G E _ N A M E _ G E T >--------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-980)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-981)Common function to return language name from the data set according to IETF tag.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-982)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-983)Returns language name if found in data tables; nil else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-984)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-985)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-986)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-987)local function language_name_get (ietf, code, cat)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-988)ietf = ietf:lower();-- ietf:lower() because format_ietf_tag() returns mixed case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-989)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-990)local name;-- remains nil if not found[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-991)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-992)if override_table[ietf] then-- look for whole IETF tag in override table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-993)name = override_table[ietf];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-994)elseif override_table[code] then-- not there so try basic language tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-995)name = override_table[code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-996)elseif lang_table[code] then-- shift to IANA active tag/name table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-997)name = lang_table[code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-998)elseif lang_dep_table[code] then-- try the IANA deprecated tag/name table[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-999)name = lang_dep_table[code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1000)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1001)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1002)if lang_dep_table[code] and cat then-- because deprecated code may have been overridden to en.wiki preferred name[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1003)table.insert (maint_cats, substitute (cfg.language_name_get_t.deprecated_cat, {code}));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1004)table.insert (maint_msgs, substitute (cfg.language_name_get_t.deprecated_msg, {code}));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1005)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1006)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1007)return name;-- name from data tables or nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1008)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1009)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1010)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1011)--[[--------------------------< T E X T _ S C R I P T _ M A T C H _ T E S T >----------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1012)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1013)IETF script subtag should match the script of the <text>. This module does not attempt to know all scripts and[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1014)what they look like. It does know what Latn script looks like so when <text> is written using other than the Latn[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1015)script, the IETF script subtag, if present, should not be Latn.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1016)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1017)Conversely, when <text> is written using the Latn script, the IETF script subtag, if present, should be Latn.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1018)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1019)For the purposes of this test, Latf (Fraktur) and Latg (Gaelic) are considered to be equivalent to Latn because[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1020)unicode treats these two scripts as font-specific variants of Latn.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1021)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1022)Returns an error message when mismatch detected; nil else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1023)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1024)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1025)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1026)local function text_script_match_test (script, is_latn_text, pos, char)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1027)local scripts_t = {['latf'] = true, ['latg'] = true, ['latn'] = true};-- unicode 'latn' scripts; 'latf' and 'latg' are font variants so there are no Fraktur or Gaelic codepoints[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1028)if is_set (script) then-- don't bother with the rest of this if <script> is nil or empty string[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1029)script = script:lower();-- lower case to index into <scripts_t>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1030)if is_latn_text then-- when text is wholly Latn script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1031)if not scripts_t[script] then-- but a non-Latn script is specified[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1032)return cfg.text_script_match_test_t.latn_txt_mismatch;-- emit an error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1033)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1034)else-- when text is not wholly Latn script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1035)if scripts_t[script] then-- but a Latn script is specified[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1036)return substitute (cfg.text_script_match_test_t.latn_scr_mismatch, {pos, char});-- emit an error message with position of first offending character[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1037)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1038)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1039)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1040)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1041)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1042)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1043)--[[--------------------------< B I N A R Y _ S E A R C H >---------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1044)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1045)conducts a binary search of <ranges_t> for a sub-range that holds <target>.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1046)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1047)returns boolean true if a sub-range holding <target> is found; boolean false else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1048)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1049)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1050)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1051)local function binary_search (target, ranges_t)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1052)local idx_bot = 1;-- initialize to index of first key[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1053)local idx_top = sizeof_ranges_t;-- initialize to index of last key (number of keys)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1054)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1055)if (target < ranges_t[idx_bot][1]) or (target > ranges_t[idx_top][2]) then-- invalid; target out of range[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1056)return;-- abandon[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1057)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1058)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1059)local idx_mid;-- calculated index of range midway between top index and bottom index[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1060)local flag = false;-- flag to tell us when we've evaluated last (highest) range in <ranges_t>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1061)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1062)while 1 do[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1063)idx_mid = math.ceil ((idx_bot + idx_top) / 2);-- get the mid-point in the <ranges_t> sequence[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1064)if (target >= ranges_t[idx_mid][1]) and (target <= ranges_t[idx_mid][2]) then-- indexed range low value <= target <= indexed range high value[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1065)return true;-- we found the range that holds the <target> character; return true[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1066)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1067)elseif (target > ranges_t[idx_mid][2]) then-- is <target> > indexed range high value?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1068)idx_bot = idx_mid;-- adjust <idx_bot> up[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1069)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1070)else-- here when <target> less than indexed range low value[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1071)idx_top = idx_mid - 1;-- adjust <idx_top> down[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1072)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1073)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1074)if flag then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1075)break;-- here when we just evaluated the last range and <target> not found[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1076)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1077)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1078)if not flag and (idx_bot == idx_top) then-- set true just before we evaluate the last (highest) range in <ranges_t>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1079)flag = true;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1080)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1081)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1082)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1083)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1084)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1085)--[[--------------------------< I S _ L A T I N >--------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1086)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1087)compare <text> as codepoints to lists of known codepoints accepted as Latn script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1088)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1089)returns boolean true and modified <text> when <text> is wrapped in accept-as-written markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1090)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1091)returns boolean true and <text> when codepoint is known[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1092)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1093)returns boolean false, <text>, non-Latn codepoint position in <text> (left to right), and the codepoint character[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1094) when codepoint is not known[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1095)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1096)TODO: when text has accept-as-written markup, return a non-boolean value to indicate that <text> is not wholly[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1097) latn script? Use that return value to create non-Latn HTML lang= attribute because <text> isn't really[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1098) latn so lang=und (undetermined)? or instead, omit the -Latn subtag? (without -Latn need to force |italic=yes)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1099)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1100)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1101)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1102)local function is_latin (text, tag)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1103)local count;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1104)text, count = text:gsub ('^%(%((.+)%)%)$', '%1');-- remove accept-as-written markup if present[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1105)if 0 ~= count then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1106)return true, text;-- markup present so assume that <text> is Latn-script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1107)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1108)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1109)local pos = 0;-- position counter for error messaging[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1110)for codepoint in mw.ustring.gcodepoint (text) do-- fetch each code point[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1111)pos = pos + 1;-- bump the position counter[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1112)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1113)if not is_latn_data.singles_t[codepoint] and-- codepoint not found in the singles list?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1114)not binary_search (codepoint, is_latn_data.ranges_t) and-- codepoint not a member of a listed range?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1115)not (tag and is_latn_data.specials_t[codepoint] and is_latn_data.specials_t[codepoint][tag]) then-- not a language-specific codepoint?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1116)return false, text, pos, mw.ustring.char (codepoint);-- codepoint not known; return false with codepoint position and character representation[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1117)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1118)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1119)return true, text;-- is known; return <text>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1120)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1121)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1122)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1123)--[[--------------------------< _ L A N G >--------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1124)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1125)Entry point for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1126)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1127)There should be no reason to set parameters in the {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} {{#invoke:}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1128)<includeonly>{{#invoke:lang|lang}}</includeonly>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1129)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1130)Parameters are received from the template's frame (parent frame).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1131)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1132)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1133)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1134)local function _lang (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1135)local out = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1136)local language_name;-- used to make category names[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1137)local category_name;-- same as language_name except that it retains any parenthetical disambiguators (if any) from the data set[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1138)local subtags = {};-- IETF subtags script, region, variant, and private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1139)local code;-- the language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1140)local msg;-- for error messages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1141)local tag = 'span';-- initial value for make_text_html()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1142)local template = args.template or cfg.templates_t.lang;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1143)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1144)maint_cats = {};-- initialize because when this module required into another module, these only declared once so only initialzed once[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1145)maint_msgs = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1146)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1147)validate_cat_args (args);-- determine if categorization should be suppressed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1148)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1149)if args[1] and args.code then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1150)return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {'1', cfg.lang_t.conflict_n_param_types.code}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1151)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1152)args.code = args[1] or args.code;-- prefer args.code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1153)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1154)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1155)if args[2] and args.text then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1156)return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {'2', cfg.lang_t.conflict_n_param_types.text}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1157)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1158)args.text = args[2] or args.text;-- prefer args.text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1159)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1160)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1161)msg = validate_text (template, args);-- ensure that |text= is set[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1162)if is_set (msg) then-- msg is an already-formatted error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1163)return msg;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1164)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1165)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1166)args.text, tag = html_tag_select (args.text);-- inspects text; returns appropriate HTML tag with text trimmed accordingly[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1167)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1168)args.rtl = args.rtl == cfg.keywords_t.affirmative;-- convert to boolean: 'yes' -> true, other values -> false[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1169)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1170)args.proto, msg = validate_proto (args.proto);-- return boolean, or nil, or nil and error message flag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1171)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1172)return make_error_msg (substitute (cfg.lang_t.invalid_proto, {msg}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1173)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1174)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1175)code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (args.code);-- |script=, |region=, |variant= not supported because they should be part of args.code ({{{[1](https://freemwiki.com/wiki/Template:1 "Template:1")}}} in {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}})[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1176)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1177)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1178)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1179)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1180)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1181)local is_latn_text, pos, char;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1182)is_latn_text, args.text, pos, char= is_latin (args.text, code);-- make a boolean[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1183)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1184)msg = text_script_match_test (subtags.script, is_latn_text, pos, char)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1185)if msg then-- if an error detected then there is an error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1186)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1187)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1188)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1189)args.italic, msg = validate_italic (args);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1190)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1191)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1192)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1193)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1194)if nil == args.italic then-- nil when |italic= absent or not set or |italic=default; args.italic controls[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1195)if ('latn' == subtags.script) or -- script is latn[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1196)(this_wiki_lang_tag ~= code and not is_set (subtags.script) and not has_poem_tag (args.text) and is_latn_text) then -- text not this wiki's language, no script specified and not in poem markup but is wholly latn script (auto-italics)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1197)args.italic = 'italic';-- DEFAULT for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} templates is upright; but if latn script set for font-style:italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1198)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1199)args.italic = 'inherit';-- italic not set; script not latn; inherit current style[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1200)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1201)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1202)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1203)if is_set (subtags.script) then-- if script set, override rtl setting[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1204)if in_array (subtags.script, lang_data.rtl_scripts) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1205)args.rtl = true;-- script is an rtl script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1206)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1207)args.rtl = false;-- script is not an rtl script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1208)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1209)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1210)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1211)args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private);-- format to recommended subtag styles[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1212)language_name = language_name_get (args.code, code, true);-- get language name; try IETF tag first, then code w/o variant then code w/ variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1213)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1214)if cfg.keywords_t.invert == args.italic and 'span' == tag then-- invert only supported for in-line content[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1215)args.text = invert_italics (args.text)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1216)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1217)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1218)args.text = proto_prefix (args.text, language_name, args.proto);-- prefix proto-language text with a splat[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1219)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1220)table.insert (out, make_text_html (args.code, args.text, tag, args.rtl, args.italic, args.size, language_name));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1221)table.insert (out, make_category (code, language_name, args.nocat));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1222)table.insert (out, render_maint (args.nocat));-- maintenance messages and categories[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1223)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1224)return table.concat (out);-- put it all together and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1225)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1226)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1227)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1228)--[[--------------------------< L A N G >----------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1229)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1230)Entry point for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1231)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1232)There should be no reason to set parameters in the {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} {{#invoke:}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1233)<includeonly>{{#invoke:lang|lang}}</includeonly>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1234)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1235)Parameters are received from the template's frame (parent frame).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1236)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1237)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1238)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1239)local function lang (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1240)local args_t = getArgs (frame, {-- this code so that we can detect and handle wiki list markup in text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1241)valueFunc = function (key, value)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1242)if 2 == key or 'text' == key then-- the 'text' parameter; do not trim wite space[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1243)return value;-- return untrimmed 'text'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1244)elseif value then-- all other values: if the value is not nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1245)value = mw.text.trim (value);-- trim whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1246)if '' ~= value then-- empty string when value was only whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1247)return value;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1248)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1249)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1250)return nil;-- value was empty or contained only whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1251)end-- end of valueFunc[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1252)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1253)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1254)args_t.fn = nil;-- unset because not supported but this function might have been called by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")|fn=lang|...}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1255)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1256)local msg = parameter_validate (args_t, cfg.templates_t.lang);-- verify that all supplied parameters are supported by {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1257)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1258)return make_error_msg (msg, args_t, cfg.templates_t.lang);-- when template has unsupported params, abandon with error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1259)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1260)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1261)return _lang (args_t);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1262)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1263)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1264)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1265)--[[--------------------------< T R A N S L A T I O N _ M A K E >----------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1266)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1267)Stand-alone function to create literal translation of main text.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1268)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1269)Also used by {{[lang-x2](https://freemwiki.com/wiki/Template:Lang-x2 "Template:Lang-x2")}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1270)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1271)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1272)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1273)local function translation_make (args_t)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1274)local translation_t = {', '};-- initialize output[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1275)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1276)if 'none' ~= args_t.label then-- if we want a label[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1277)table.insert (translation_t, '<small>');-- open the <small> HTML tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1278)if cfg.keywords_t.negative == args_t.link then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1279)table.insert (translation_t, substitute ('<abbr title="$1">$2</abbr>', {cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr}));-- unlinked form[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1280)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1281)table.insert (translation_t, make_wikilink (cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr));-- linked form[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1282)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1283)table.insert (translation_t, " </small>");-- close the <small> HTML tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1284)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1285)table.insert (translation_t, table.concat ({''', args_t.translation, '''}));-- use HTML entities to avoid wiki markup confusion[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1286)return table.concat (translation_t);-- make a big string and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1287)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1288)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1289)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1290)--[[--------------------------< _ L A N G _ X X >--------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1291)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1292)For the {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates, the only parameter required to be set in the template is the language code. All[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1293)other parameters can, usually should, be written in the template call. For {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates for languages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1294)that can have multiple writing systems, it may be appropriate to set |script= as well.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1295)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1296)For each {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} template choose the appropriate entry-point function so that this function knows the default[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1297)styling that should be applied to text.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1298)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1299)For normal, upright style:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1300)<includeonly>{{#invoke:lang|lang_xx_inherit|code=xx}}</includeonly>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1301)For italic style:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1302)<includeonly>{{#invoke:lang|lang_xx_italic|code=xx}}</includeonly>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1303)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1304)All other parameters should be received from the template's frame (parent frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1305)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1306)Supported parameters are:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1307) |code = (required) the IANA language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1308) |script = IANA script code; especially for use with languages that use multiple writing systems[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1309) |region = IANA region code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1310) |variant = IANA variant code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1311) |text = (required) the displayed text in language specified by code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1312) |link = boolean false ('no') does not link code-spcified language name to associated language article[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1313) |rtl = boolean true ('yes') identifies the language specified by code as a right-to-left language[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1314) |nocat = boolean true ('yes') inhibits normal categorization; error categories are not affected[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1315) |cat = boolian false ('no') opposite form of |nocat=[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1316) |italic = boolean true ('yes') renders displayed text in italic font; boolean false ('no') renders displayed text in normal font; not set renders according to initial_style_state[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1317) |lit = text that is a literal translation of text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1318) |label = 'none' to suppress all labeling (language name, 'translit.', 'lit.')[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1319) any other text replaces language-name label - automatic wikilinking disabled[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1320)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1321) for those {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that support transliteration (those templates where |text= is not entirely latn script):[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1322) |translit = text that is a transliteration of text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1323) |translit-std = the standard that applies to the transliteration[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1324) |translit-script = ISO 15924 script name; falls back to code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1325)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1326)For {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}, the positional parameters are:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1327) {{{[1](https://freemwiki.com/wiki/Template:1 "Template:1")}}} text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1328) {{{[2](https://freemwiki.com/wiki/Template:2 "Template:2")}}} transliterated text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1329) {{{[3](https://freemwiki.com/wiki/Template:3 "Template:3")}}} literal translation text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1330)no other positional parameters are allowed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1331)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1332)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1333)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1334)local function _lang_xx (args, base_template)-- base_template will be either of 'langx' or 'lang-xx'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1335)local out = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1336)local language_name;-- used to make display text, article links[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1337)local category_name;-- same as language_name except that it retains any parenthetical disambiguators (if any) from the data set[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1338)local subtags = {};-- IETF subtags script, region, and variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1339)local code;-- the language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1340)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1341)local translit_script_name;-- name associated with IANA (ISO 15924) script code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1342)local translit;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1343)local msg;-- for error messages[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1344)local tag = 'span';-- initial value for make_text_html()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1345)local template = args.template or base_template;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1346)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1347)maint_cats = {};-- initialize because when this module required into another module, these only declared once so only initialzed once[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1348)maint_msgs = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1349)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1350)local text_idx = (cfg.templates_t.langx == base_template) and 2 or 1;-- for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} 'text' positional parameter is '2'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1351)local translit_idx = (cfg.templates_t.langx == base_template) and 3 or 2;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1352)local xlate_idx = (cfg.templates_t.langx == base_template) and 4 or 3;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1353)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1354)if args[text_idx] and args.text then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1355)return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx, cfg.lang_t.conflict_n_param_types.text}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1356)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1357)args.text = args[text_idx] or args.text;-- prefer positional 'text' parameter[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1358)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1359)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1360)msg = validate_text (template, args);-- ensure that |text= is set, does not contain italic markup and is protected from improper bolding[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1361)if is_set (msg) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1362)return msg;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1363)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1364)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1365)args.text, tag = html_tag_select (args.text);-- inspects text; returns appropriate HTML tag with text trimmed accordingly[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1366)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1367)if args[translit_idx] and args.translit then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1368)return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx, cfg.lang_t.conflict_n_param_types.translit}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1369)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1370)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1371)args.translit = args[translit_idx] or args.translit-- prefer positional 'translit' parameter[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1372)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1373)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1374)args.engvar = cfg.engvar_sel_t[args.engvar] or cfg.default_engvar;-- |engvar= when valid; cfg.default_engvar else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1375)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1376)if args[xlate_idx] and (args.translation or args.lit) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1377)return make_error_msg (substitute (cfg.lang_xx_t.conflict_n_lit, {translit_idx}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1378)elseif args.translation and args.lit then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1379)return make_error_msg (cfg.lang_xx_t.conflict_lit, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1380)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1381)args.translation = args[xlate_idx] or args.translation or args.lit;-- prefer positional 'translation' parameter[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1382)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1383)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1384)if args.links and args.link then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1385)return make_error_msg (cfg.lang_xx_t.conflict_link, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1386)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1387)args.link = args.link or args.links;-- prefer args.link[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1388)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1389)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1390)validate_cat_args (args);-- determine if categorization should be suppressed[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1391)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1392)args.rtl = args.rtl == cfg.keywords_t.affirmative;-- convert to boolean: 'yes' -> true, other values -> false[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1393)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1394)code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (args.code, args.script, args.region, args.variant);-- private omitted because private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1395)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1396)if msg then-- if an error detected then there is an error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1397)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1398)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1399)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1400)if args.translit then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1401)local latn, pos, char;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1402)latn, args.translit, pos, char = is_latin (args.translit, (('' ~= subtags.private) and (code .. '-x-' .. subtags.private)) or code);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1403)if not latn then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1404)return make_error_msg (substitute (cfg.lang_xx_t.translit_nonlatn, {pos, char}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1405)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1406)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1407)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1408)local is_latn_text, text, pos, char = is_latin (args.text, code);-- make a boolean[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1409)args.text = text;-- may have been modified (accept-as-written markup removed)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1410)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1411)msg = text_script_match_test (subtags.script, is_latn_text, pos, char)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1412)if msg then-- if an error detected then there is an error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1413)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1414)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1415)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1416)args.italic, msg = validate_italic (args);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1417)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1418)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1419)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1420)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1421)if cfg.templates_t.langx == base_template then-- auto-italics for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} templates; adapted from {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} (no support for poem tag) [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1422)if nil == args.italic then-- nil when |italic= absent or not set or |italic=default; args.italic controls[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1423)if ('latn' == subtags.script) or -- script is latn[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1424)(this_wiki_lang_tag ~= code and not is_set (subtags.script) and is_latn_text) then -- text is not this wiki's language, no script specified and is wholly latn script (auto-italics)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1425)args.italic = 'italic';-- set font-style:italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1426)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1427)args.italic = 'inherit';-- italic not set; script not latn; inherit current style[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1428)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1429)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1430)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1431)else-- {{[lang-xx](https://freemwiki.com/wiki/Template:Lang-xx "Template:Lang-xx")}} does not do auto italics; retained for those wikis that don't support {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1432)if nil == args.italic then-- args.italic controls[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1433)if is_set (subtags.script) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1434)if 'latn' == subtags.script then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1435)args.italic = 'italic';-- |script=Latn; set for font-style:italic[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1436)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1437)args.italic = initial_style_state;-- italic not set; script is not latn; set for font-style:<initial_style_state>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1438)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1439)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1440)args.italic = initial_style_state;-- here when |italic= and |script= not set; set for font-style:<initial_style_state>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1441)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1442)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1443)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1444)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1445)if is_set (subtags.script) then-- if script set override rtl setting[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1446)if in_array (subtags.script, lang_data.rtl_scripts) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1447)args.rtl = true;-- script is an rtl script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1448)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1449)args.rtl = false;-- script is not an rtl script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1450)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1451)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1452)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1453)args.proto, msg = validate_proto (args.proto);-- return boolean, or nil, or nil and error message flag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1454)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1455)return make_error_msg (substitute (cfg.lang_t.invalid_proto, {args.proto}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1456)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1457)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1458)args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private);-- format to recommended subtag styles[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1459)language_name = language_name_get (args.code, code, true);-- get language name; try IETF tag first, then code w/o variant then code w/ variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1460)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1461)category_name = language_name;-- category names retain IANA parenthetical diambiguators (if any)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1462)language_name = language_name:gsub ('%s+%b()', '');-- remove IANA parenthetical disambiguators or qualifiers from names that have them[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1463)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1464)if args.label then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1465)if 'none' ~= args.label then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1466)table.insert (out, table.concat ({args.label, ': '}));-- custom label[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1467)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1468)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1469)if cfg.keywords_t.negative == args.link then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1470)table.insert (out, language_name);-- language name without wikilink[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1471)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1472)if mw.ustring.find (language_name, 'languages', 1, true) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1473)table.insert (out, make_wikilink (language_name));-- collective language name uses simple wikilink[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1474)elseif lang_data.article_name[args.code:lower()] then-- is IETF tag in article name over ride?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1475)table.insert (out, make_wikilink (lang_data.article_name[args.code:lower()], language_name));-- language name with wikilink from override data[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1476)elseif lang_data.article_name[code] then-- is language tag in article override[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1477)table.insert (out, make_wikilink (lang_data.article_name[code], language_name));-- language name with wikilink from override data[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1478)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1479)table.insert (out, make_wikilink (substitute ('$1 $2', {language_name, cfg.misc_text_t.language}), language_name));-- language name with wikilink[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1480)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1481)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1482)table.insert (out, ': ');-- separator[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1483)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1484)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1485)if cfg.keywords_t.invert == args.italic then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1486)args.text = invert_italics (args.text)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1487)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1488)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1489)args.text = proto_prefix (args.text, language_name, args.proto);-- prefix proto-language text with a splat[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1490)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1491)table.insert (out, make_text_html (args.code, args.text, tag, args.rtl, args.italic, args.size, ('none' == args.label) and language_name or nil))[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1492)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1493)if is_set (args.translit) and not is_latn_text then-- transliteration; not supported when args.text is wholly latn text (this is an imperfect test)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1494)table.insert (out, ', ');-- comma to separate text from translit[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1495)if 'none' ~= args.label then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1496)table.insert (out, '<small>');[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1497)if script_table[args['translit-script']] then-- when |translit-script= is set, try to use the script's name[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1498)translit_script_name = script_table[args['translit-script']];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1499)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1500)translit_script_name = language_name;-- fall back on language name[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1501)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1502)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1503)local translit_title_obj = mw.title.makeTitle (0, substitute ('$1 $2',{cfg.lang_xx_t.romanization, translit_script_name}));-- make a title object; no engvar, article titles use US spelling[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1504)if translit_title_obj.exists and (cfg.keywords_t.negative ~= args.link) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1505)table.insert (out, make_wikilink (substitute ('$1 $2', {cfg.lang_xx_t.romanization, translit_script_name or language_name}),[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1506)substitute ('$1', {cfg.engvar_t[args.engvar]['romanisz_pt']})) .. ':');-- make a wikilink if there is an article to link to; engvar the display text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1507)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1508)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1509)table.insert (out, substitute ('$1:', {cfg.engvar_t[args.engvar]['romanisz_pt']}));-- else plain text per engvar[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1510)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1511)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1512)table.insert (out, ' </small>');-- close the small tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1513)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1514)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1515)translit = make_translit (args.code, language_name, args.translit, args['translit-std'], args['translit-script'], nil, args.engvar)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1516)if is_set (translit) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1517)table.insert (out, translit);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1518)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1519)return make_error_msg (substitute ('$1: $2', {cfg.lang_xx_t.invalid_xlit_std, args['translit-std'] or '[missing]'}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1520)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1521)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1522)elseif is_set (args.translit) and is_latn_text then-- when creating a transliteration of Latn script <text>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1523)return make_error_msg (cfg.lang_xx_t.xlit_of_latn, args, template);-- emit error message and abandon[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1524)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1525)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1526)if is_set (args.translation) then-- translation (not supported in {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}})[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1527)table.insert (out, translation_make (args));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1528)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1529)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1530)table.insert (out, make_category (code, category_name, args.nocat));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1531)table.insert (out, render_maint(args.nocat));-- maintenance messages and categories[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1532)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1533)return table.concat (out);-- put it all together and done[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1534)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1535)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1536)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1537)--[[--------------------------< L A N G _ X X _ A R G S _ G E T >----------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1538)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1539)Common function to get args table from {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1540)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1541)Returns table of args.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1542)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1543)Text positional parameters are not trimmed here but are selectively trimmed at html_tag_select().[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1544)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1545)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1546)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1547)local function lang_xx_args_get (frame, base_template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1548)local args_t = getArgs(frame,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1549){[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1550)parentFirst= true,-- parameters in the template override parameters set in the {{#invoke:}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1551)valueFunc = function (key, value)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1552)if ((cfg.templates_t.langx == base_template) and 2 or 1) == key then-- the 'text' positional parameter; 1 for {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}, 2 for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}; do not trim wite space[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1553)return value;-- return untrimmed 'text' positional parameter[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1554)elseif value then-- all other values: if the value is not nil[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1555)value = mw.text.trim (value);-- trim whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1556)if '' ~= value then-- empty string when value was only whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1557)return value;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1558)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1559)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1560)return nil;-- value was empty or contained only whitespace[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1561)end-- end of valueFunc[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1562)});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1563)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1564)return args_t;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1565)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1566)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1567)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1568)--[[--------------------------< L A N G _ X X _ I T A L I C >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1569)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1570)Entry point for those {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that call lang_xx_italic(). Sets the initial style state to italic.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1571)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1572)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1573)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1574)local function lang_xx_italic (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1575)local args = lang_xx_args_get (frame, cfg.templates_t.langxx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1576)args.fn = nil;-- unset because not supported but this function might have been called by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")|fn=lang_xx_italic|...}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1577)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1578)local msg = parameter_validate (args, cfg.templates_t.langxx);-- verify that all supplied parameters are supported by {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1579)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1580)return make_error_msg (msg, args, cfg.templates_t.langxx);-- when template has unsupported params, abandon with error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1581)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1582)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1583)initial_style_state = 'italic';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1584)return _lang_xx (args, cfg.templates_t.langxx) .. '[[Category:Pages using Lang-xx templates]]';-- temporary category[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1585)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1586)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1587)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1588)--[[--------------------------< _ L A N G _ X X _ I T A L I C >------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1589)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1590)Entry point from another module. Sets the initial style state to italic.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1591)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1592)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1593)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1594)local function _lang_xx_italic (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1595)initial_style_state = 'italic';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1596)return _lang_xx (args, cfg.templates_t.langxx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1597)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1598)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1599)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1600)--[[--------------------------< L A N G _ X X _ I N H E R I T >------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1601)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1602)Entry point for those {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that call lang_xx_inherit(). Sets the initial style state to inherit.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1603)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1604)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1605)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1606)local function lang_xx_inherit (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1607)local args = lang_xx_args_get (frame, cfg.templates_t.langxx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1608)args.fn = nil;-- unset because not supported but this function might have been called by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")|fn=lang_xx_inherit|...}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1609)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1610)local msg = parameter_validate (args, cfg.templates_t.langxx);-- verify that all supplied parameters are supported by {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1611)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1612)return make_error_msg (msg, args, cfg.templates_t.langxx);-- when template has unsupported params, abandon with error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1613)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1614)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1615)initial_style_state = 'inherit';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1616)return _lang_xx (args, cfg.templates_t.langxx) .. '[[Category:Pages using Lang-xx templates]]';-- temporary category[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1617)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1618)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1619)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1620)--[[--------------------------< _ L A N G _ X X _ I N H E R I T >----------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1621)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1622)Entry point from another module. Sets the initial style state to inherit.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1623)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1624)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1625)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1626)local function _lang_xx_inherit (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1627)initial_style_state = 'inherit';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1628)return _lang_xx (args, cfg.templates_t.langxx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1629)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1630)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1631)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1632)--[[--------------------------< _ L A N G X >------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1633)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1634)Entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1635)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1636)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1637)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1638)local function _langx (args_t)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1639)local langx_data = mw.loadData (['Module:Lang/langx'](https://freemwiki.com/wiki/Module:Lang/langx));-- get necessary data [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1640)local rtl_t = langx_data.rtl_t;-- get list of language tags for languages that are rendered right-to-left[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1641)local link_t = langx_data.link_t;-- get list of language tags for {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that set |link=<something>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1642)local size_t = langx_data.size_t;-- get list of language tags for {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that set |size=<something>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1643)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1644)local msg = parameter_validate (args_t, cfg.templates_t.langx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1645)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1646)return make_error_msg (msg, args_t, cfg.templates_t.langx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1647)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1648)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1649)args_t.code = args_t[1] or args_t.code;-- get the language tag; must be {{{[1](https://freemwiki.com/wiki/Template:1 "Template:1")}}} or |code=[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1650)if not args_t.code then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1651)return make_error_msg (cfg.get_ietf_parts_t.missing_lang_tag, args_t, cfg.templates_t.langx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1652)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1653)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1654)args_t.rtl = args_t.rtl or (rtl_t[args_t.code] and cfg.keywords_t.affirmative);-- prefer |rtl= in template call, use rtl_t else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1655)args_t.link = args_t.link or link_t[args_t.code];-- prefer |link= in template call, use link_t felse[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1656)args_t.size = args_t.size or size_t[args_t.code];-- prefer |size= in template call, use size_t else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1657)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1658)args_t[1] = nil;-- unset to mimic {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates which set |code=xx[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1659)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1660)local lang_subtag = args_t.code;-- use only the base language subtag for unsupported tag test; some args_t.code are modified by |script= etc[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1661)return _lang_xx (args_t, cfg.templates_t.langx);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1662)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1663)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1664)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1665)--[[--------------------------< L A N G X >--------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1666)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1667)Entry point for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1668)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1669)this function calls _lang_xx() to render non-English text. The {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates have three positional paramters[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1670)but {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} has four:[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1671)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1672) | 1 | 2 | 3 | 4 [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1673) {{lang-xx |<text> |<xlit> |<xlat> }}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1674) {{langx |<tag> |<text> |<xlit> |<xlat> }}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1675)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1676)The calls to lang_xx_args_get() and _lang_xx() use 'langx' as a flag for those functions to select the proper[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1677)positional parameters.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1678)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1679){{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} depends on the calling template to select 'inherit' or 'italic' to establish the default rendering.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1680)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1681){{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} can't do that. The initial version of {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}} relied on a list of language tags (inherit_t in ~/langx)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1682)scraped from those {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates that call lang_xx_inherit() to render text in upright font. langx() now[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1683)uses auto-italics code adapted from {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} (doesn't support poem tags).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1684)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1685)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1686)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1687)local function langx (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1688)local args_t = lang_xx_args_get (frame, cfg.templates_t.langx);-- get the arguments; 'langx' is the <base_template> used to decide which positional param is 'text', 'translit', 'lit'[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1689)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1690)return _langx (args_t);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1691)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1692)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1693)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1694)--[[--------------------------< _ I S _ I E T F _ T A G >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1695)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1696)Returns true when a language name associated with IETF language tag exists; nil else. IETF language tag must be valid.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1697)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1698)All code combinations supported by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} and the {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates are supported by this function.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1699)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1700)Module entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1701)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1702)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1703)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1704)local function _is_ietf_tag (tag)-- entry point when this module is require()d into another[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1705)local c, s, r, v, p, err;-- code, script, region, variant, private, error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1706)c, s, r, v, p, err = get_ietf_parts (tag);-- disassemble tag into constituent part and validate[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1707)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1708)return ((c and not err) and true) or nil;-- return true when code portion has a value without error message; nil else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1709)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1710)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1711)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1712)--[[--------------------------< I S _ I E T F _ T A G >--------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1713)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1714)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1715)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1716)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1717)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1718)local function is_ietf_tag (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1719)return _is_ietf_tag (getArgs (frame)[1]);-- args[1] is the IETF language tag to be tested; also get parent frame[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1720)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1721)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1722)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1723)--[[--------------------------< I S _ I E T F _ T A G _ F R A M E >--------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1724)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1725)Module entry point from an {{#invoke:}}; same as is_ietf_tag() except does not get parameters from the parent[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1726)(template) frame. This function not useful when called by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")|fn=is_ietf_tag_frame|<tag>}} because <tag>[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1727)is in the parent frame.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1728)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1729)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1730)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1731)local function is_ietf_tag_frame (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1732)return _is_ietf_tag (getArgs (frame, {frameOnly = true,})[1]);-- args[1] is the IETF language tag to be tested; do not get parent frame[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1733)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1734)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1735)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1736)--[[--------------------------< _ N A M E _ F R O M _ T A G >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1737)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1738)Returns language name associated with IETF language tag if valid; error message else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1739)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1740)All code combinations supported by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} and the {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates are supported by this function.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1741)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1742)Set invoke's |link= parameter to yes to get wikilinked version of the language name.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1743)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1744)Module entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1745)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1746)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1747)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1748)local function _name_from_tag (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1749)local subtags = {};-- IETF subtags script, region, variant, and private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1750)local raw_code = args[1];-- save a copy of the input IETF subtag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1751)local link = cfg.keywords_t.affirmative == args['link'];-- make a boolean[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1752)local label = args.label;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1753)local code;-- the language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1754)local msg;-- gets an error message if IETF language tag is malformed or invalid[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1755)local language_name = '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1756)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1757)code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (raw_code);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1758)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1759)local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or '';-- make template name (if provided by the template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1760)return make_error_span (template, msg);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1761)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1762)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1763)raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private);-- format to recommended subtag styles; private omitted because private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1764)language_name = language_name_get (raw_code, code);-- get language name; try IETF tag first, then code w/o variant then code w/ variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1765)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1766)if 'yes' ~= args.raw then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1767)language_name = language_name:gsub ('%s+%b()', '');-- remove IANA parenthetical disambiguators or qualifiers from names that have them[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1768)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1769)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1770)if link then-- when |link=yes, wikilink the language name[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1771)if mw.ustring.find (language_name, 'languages', 1, true) then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1772)language_name = make_wikilink (language_name, label);-- collective language name uses simple wikilink[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1773)elseif lang_data.article_name[raw_code:lower()] then-- is IETF tag in article name override?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1774)language_name = make_wikilink (lang_data.article_name[raw_code:lower()], label or language_name);-- language name with wikilink from override data[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1775)elseif lang_data.article_name[code] then-- is language tag in article name override?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1776)language_name = make_wikilink (lang_data.article_name[code], label or language_name);-- language name with wikilink from override data[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1777)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1778)language_name = make_wikilink (substitute ('$1 $2', {language_name, cfg.misc_text_t.language}), label or language_name);-- language name with wikilink[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1779)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1780)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1781)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1782)return language_name;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1783)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1784)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1785)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1786)--[[--------------------------< N A M E _ F R O M _ T A G >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1787)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1788)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1789)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1790)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1791)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1792)local function name_from_tag (frame)-- entry point from an {{#invoke:lang|name_from_tag|<IETF tag>|link=<yes>|template=<template name>}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1793)return _name_from_tag (getArgs(frame))-- pass-on the args table, nothing else; getArgs() so we also get parent frame[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1794)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1795)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1796)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1797)--[[--------------------------< _ T A G _ F R O M _ N A M E >--------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1798)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1799)Returns the IETF language tag associated with the language name. Spelling of language name must be correct[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1800)according to the spelling in the source tables. When a standard language name has a parenthetical disambiguator,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1801)that disambiguator must be omitted (they are not present in the data name-to-tag tables).[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1802)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1803)Module entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1804)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1805)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1806)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1807)local function _tag_from_name (args)-- entry point from another module[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1808)local msg;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1809)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1810)if args[1] and '' ~= args[1] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1811)local data = mw.loadData (['Module:Lang/tag from name'](https://freemwiki.com/wiki/Module:Lang/tag_from_name));-- get the reversed data tables TODO: change when going live[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1812)local lang = args[1]:lower();-- allow any-case for the language name (speeling must till be correct)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1813)local tag = data.rev_override_table[lang] or data.rev_lang_table[lang] or data.rev_lang_dep_table[lang];-- get the code; look first in the override then in the standard[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1814)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1815)if tag then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1816)return tag, true;-- language name found so return tag and done; second return used by is_lang_name()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1817)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1818)msg = substitute (cfg.tag_from_name_t.lang_not_found, {args[1]});-- language name not found, error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1819)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1820)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1821)msg = cfg.tag_from_name_t.missing_lang_name;-- language name not found, error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1822)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1823)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1824)local template = '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1825)if args.template and '' ~= args.template then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1826)template = table.concat ({'{{', args['template'], '}}: '});-- make template name (if provided by the template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1827)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1828)return make_error_span (template, msg);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1829)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1830)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1831)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1832)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1833)--[[--------------------------< T A G _ F R O M _ N A M E >----------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1834)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1835)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1836)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1837)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1838)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1839)local function tag_from_name (frame)-- entry point from an {{#invoke:lang|tag_from_name|<language name>|link=<yes>|template=<template name>}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1840)local result, _ = _tag_from_name (getArgs(frame))-- pass-on the args table, nothing else; getArgs() so we also get parent frame; supress second return used by is_lang_name()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1841)return result;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1842)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1843)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1844)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1845)--[[--------------------------< I S _ L A N G _ N A M E >------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1846)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1847)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1848)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1849)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1850)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1851)local function is_lang_name (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1852)local _, result = _tag_from_name (getArgs(frame))-- pass-on the args table, nothing else; getArgs() so we also get parent frame; supress second return used by tag_from_name()[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1853)return result and true or nil;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1854)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1855)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1856)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1857)--[[--------------------------< _ X L I T >--------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1858)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1859)Module entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1860)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1861)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1862)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1863)local function _xlit (args)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1864)local title_table = lang_data.translit_title_table;-- table of transliteration standards and the language codes and scripts that apply to those standards[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1865)local language_name;-- language name that matches language code; used for tool tip[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1866)local translit;-- transliterated text to display[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1867)local script;-- IANA script[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1868)local msg;-- for when called functions return an error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1869)local template = args.template or cfg.templates_t.transliteration;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1870)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1871)maint_cats = {};-- initialize because when this module required into another module, these only declared once so only initialzed once[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1872)maint_msgs = {};[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1873)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1874)if is_set (args[3]) then-- [3] set when {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")|code|standard|text}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1875)args.text = args[3];-- get the transliterated text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1876)args.translit_std = args[2] and args[2]:lower();-- get the standard; lower case for table indexing[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1877)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1878)if not title_table[args.translit_std] then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1879)return make_error_msg (substitute (cfg.transl_t.unrecog_xlit_std, {args.translit_std}), args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1880)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1881)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1882)if is_set (args[2]) then-- [2] set when {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")|code|text}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1883)args.text = args[2];-- get the transliterated text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1884)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1885)if args[1] and (args[1]:match ('^%a%a%a?%a?$') or-- args[2] missing; is args[1] a language or script tag or is it the transliterated text?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1886)args[1]:match ('^%a%a%a?%-x%-')) then-- or is args[1] a private-use tag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1887)return make_error_msg (cfg.transl_t.no_text, args, template);-- args[1] is a code so we're missing text[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1888)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1889)args.text = args[1];-- args[1] is not a code so we're missing that; assign args.text for error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1890)return make_error_msg (cfg.transl_t.missing_lang_scr, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1891)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1892)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1893)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1894)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1895)if is_set (args[1]) then-- IANA language code used for HTML lang= attribute; or ISO 15924 script code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1896)if args[1]:match ('^%a%a%a?%a?$') or args[1]:match ('^%a%a%a?%-x%-') then-- args[1] has correct form?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1897)args.code = args[1]:lower();-- use the language/script code; only (2, 3, or 4 alpha characters) or private-use; lower case because table indexes are lower case[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1898)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1899)return make_error_msg (substitute (cfg.transl_t.unrecog_lang_scr, {args[1]}), args, template);-- invalid language / script code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1900)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1901)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1902)return make_error_msg (cfg.transl_t.missing_lang_scr, args, template);-- missing language / script code so quit[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1903)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1904)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1905)local is_latn_text, pos, char;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1906)is_latn_text, args.text, pos, char= is_latin (args.text, args.code);-- is latn text? strip accept-as-written markup[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1907)if not is_latn_text then-- when text is not latn[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1908)return make_error_msg (substitute (cfg.lang_xx_t.translit_nonlatn, {pos, char}), args, template);-- abandon with error message[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1909)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1910)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1911)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1912)args.italic, msg = validate_italic (args);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1913)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1914)return make_error_msg (msg, args, template);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1915)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1916)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1917)if 'italic' == args.italic then-- 'italic' when |italic=yes; because that is same as absent or not set and |italic=default[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1918)args.italic = nil;-- set to nil; [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1919)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1920)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1921)args.engvar = cfg.engvar_sel_t[args.engvar] or cfg.default_engvar;-- |engvar= when valid; cfg.default_engvar else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1922)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1923)if override_table[args.code] then-- is code a language code defined in the override table?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1924)language_name = override_table[args.code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1925)args.code = args.code:match ('^%a%a%a?');-- if private use, strip all but language subtag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1926)elseif lang_table[args.code] then-- is code a language code defined in the standard language code tables?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1927)language_name = lang_table[args.code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1928)elseif lang_dep_table[args.code] then-- is code a language code defined in the deprecated language code tables?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1929)language_name = lang_dep_table[args.code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1930)elseif script_table[args.code] then-- if here, code is not a language code; is it a script code?[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1931)language_name = script_table[args.code];[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1932)script = args.code;-- code was an ISO 15924 script so use that instead[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1933)args.code = '';-- unset because not a language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1934)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1935)return make_error_msg (substitute (cfg.transl_t.unrecog_lang_scr, {args.code}), args, template);-- invalid language / script code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1936)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1937)-- here only when all parameters passed to make_translit() are valid[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1938)return make_translit (args.code, language_name, args.text, args.translit_std, script, args.italic, args.engvar);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1939)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1940)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1941)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1942)--[[--------------------------< X L I T >----------------------------------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1943)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1944)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1945)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1946)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1947)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1948)local function xlit (frame)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1949)return _xlit (getArgs(frame));[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1950)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1951)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1952)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1953)--[[--------------------------< C A T E G O R Y _ F R O M _ T A G >--------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1954)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1955)Returns category name associated with IETF language tag if valid; error message else.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1956)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1957)All code combinations supported by {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}} and the {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}} templates are supported by this function.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1958)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1959)Module entry point from another module.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1960)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1961)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1962)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1963)local function _category_from_tag (args_t)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1964)local subtags = {};-- IETF subtags script, region, variant, and private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1965)local raw_code = args_t[1];-- save a copy of the input IETF subtag[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1966)local link = cfg.keywords_t.affirmative == args_t.link;-- make a boolean[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1967)local label = args_t.label;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1968)local code;-- the language code[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1969)local msg;-- gets an error message if IETF language tag is malformed or invalid[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1970)local category_name = '';[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1971)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1972)code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (raw_code);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1973)if msg then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1974)local template = (args_t.template and table.concat ({'{{', args_t.template, '}}: '})) or '';-- make template name (if provided by the template)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1975)return make_error_span (template, msg);[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1976)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1977)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1978)raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private);-- format to recommended subtag styles; private omitted because private[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1979)category_name = language_name_get (raw_code, code);-- get language name; try IETF tag first, then code w/o variant then code w/ variant[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1980)category_name = make_category (code, category_name, nil, true):gsub ('[%[%]]', '');[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1981)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1982)if link then[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1983)return table.concat ({'[[:', category_name, ']]'});[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1984)else[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1985)return category_name;[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1986)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1987)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1988)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1989)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1990)--[[--------------------------< C A T E G O R Y _ F R O M _ T A G >--------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1991)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1992)Module entry point from an {{#invoke:}}.[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1993)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1994)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1995)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1996)local function category_from_tag (frame)-- entry point from an {{#invoke:lang|category_from_tag|<IETF tag>|template=<template name>}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1997)return _category_from_tag (getArgs (frame));-- pass-on the args table, nothing else; getArgs() so we also get parent frame[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1998)end[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-1999)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2000)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2001)--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2002)]][](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2003)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2004)return {[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2005)category_from_tag = category_from_tag,-- frame entry points when this module is #invoke:ed into templates/wikitext[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2006)lang = lang,-- entry point for {{[lang](https://freemwiki.com/wiki/Template:Lang "Template:Lang")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2007)langx = langx,-- entry point for {{[langx](https://freemwiki.com/wiki/Template:Langx "Template:Langx")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2008)lang_xx_inherit = lang_xx_inherit,-- entry points for {{[lang-??](https://freemwiki.com/wiki/Template:Lang-%3F%3F "Template:Lang-??")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2009)lang_xx_italic = lang_xx_italic,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2010)is_ietf_tag = is_ietf_tag,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2011)is_ietf_tag_frame = is_ietf_tag_frame,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2012)is_lang_name = is_lang_name,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2013)tag_from_name = tag_from_name,-- returns IETF tag associated with language name[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2014)name_from_tag = name_from_tag,-- used for template documentation; possible use in ISO 639 name from code templates[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2015)xlit = xlit,-- entry point for {{[transliteration](https://freemwiki.com/wiki/Template:Transliteration "Template:Transliteration")}}[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2016)[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2017)_category_from_tag = _category_from_tag,-- API entry points when this module is require()d into other modules[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2018)_lang = _lang,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2019)_langx = _langx,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2020)_lang_xx_inherit = _lang_xx_inherit,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2021)_lang_xx_italic = _lang_xx_italic,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2022)_is_ietf_tag = _is_ietf_tag,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2023)get_ietf_parts = get_ietf_parts,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2024)_tag_from_name = _tag_from_name, [](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2025)_name_from_tag = _name_from_tag,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2026)_xlit = _xlit,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2027)_translation_make = translation_make,[](https://freemwiki.com/index.php?oldid=579704&title=Module%3ALang#L-2028)}; Retrieved from "[https://freemwiki.com/index.php?title=Module:Lang&oldid=579704](https://freemwiki.com/index.php?title=Module:Lang&oldid=579704)" * This page was last edited on 21 October 2025, at 06:18. * Content is available under [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/) unless otherwise noted. FreemWiki is operated by **FINGERPOWER DIGITAL TECHNOLOGY LLC** (Colorado, Entity ID 20221978727). * [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy) * [About](https://freemwiki.com/wiki/About) * [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service) * [Mobile view](https://freemwiki.com/index.php?title=Module:Lang&oldid=579704&mobileaction=toggle_view_mobile)