Jump to content
MediaWiki

Module:LC zh

From mediawiki.org
Module documentation

Description

Implements {{LC zh }} for zh language conversion.

Module Quality

Test Status
Module:LC zh success: 36, error: 0

Test cases

All tests passed.

test_main:

Text Expected Actual
Yes {{#invoke:LC zh|main}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N}} An error Caught expected error: Lua error: Missing parameter "ns".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = }}
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = User}} User User
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = Help}} Help Help
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User}} An error Caught expected error: Lua error at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} User:Example User:Example
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} Help:示例 Help:示例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} Help:範例 Help:範例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} 示例 示例
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H}} An error Caught expected error: Lua error at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} 用户 用户
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type = C}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{#invoke:LC zh|main|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} 示例 示例

test_template:

Text Expected Actual
Yes {{LC zh}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{LC zh|lang = {{{lang|}}}}} An error Caught expected error: Lua error: Unknown content type code "nil".
Yes {{LC zh|lang = {{{lang|}}}|type = N}} An error Caught expected error: Lua error: Missing parameter "ns".
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = }}
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = User}} User User
Yes {{LC zh|lang = {{{lang|}}}|type = N|ns = Help}} Help Help
Yes {{LC zh|lang = {{{lang|}}}|type = T}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = User}} An error Caught expected error: Lua error at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} User:Example User:Example
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} Help:示例 Help:示例
Yes {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} Help:範例 Help:範例
Yes {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} 示例 示例
Yes {{LC zh|lang = {{{lang|}}}|type = H}} An error Caught expected error: Lua error at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} 用户 用户
Yes {{LC zh|lang = {{{lang|}}}|type = C}} An error Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk".
Yes {{LC zh|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} 示例 示例

test_template_localized_link:

Text Expected Actual
Yes {{Localized link}} [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span>

test_template_localized_link_sandbox:

Text Expected Actual
Yes {{Localized link/sandbox}} [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span>
The above documentation is transcluded from Module:LC zh/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (edit) pages.
Subpages of this module.

 -- @var table
 localp={}

 -- @param frame frame
 -- @return args Merged argument table
 functionp.getMergedArgs(frame)
 localargs={}

 -- @var args Argument table
 -- {{#invoke:Module name|function name|key = value}}
 localframeArgs=frame.args

 -- @var args Argument table
 -- {{Template name|key = value}}
 localframeParentArgs=frame:getParent().args

 fork,vinpairs(frameArgs)do
 v=mw.text.trim(tostring(v))
 args[k]=v
 end

 fork,vinpairs(frameParentArgs)do
 v=mw.text.trim(v)
 args[k]=v
 end

 returnargs
 end

 -- @return table Array of language variants
 -- in MediaWiki internal language codes
 functionp.getContentVariants()
 return{
 "zh-hans",
 "zh-hant",
 "zh-hk"
 }
 end

 -- @return table Array of language variants
 -- in MediaWiki internal language codes
 functionp.getTargetVariants()
 return{
 "zh",
 "zh-hans",
 "zh-hant",
 "zh-cn",
 "zh-tw",
 "zh-hk",
 "zh-mo",
 "zh-sg",
 "zh-my",
 }
 end

 -- @param string langCode MediaWiki internal language code
 -- @return bool Whether is one of zh target language variant
 functionp.hasTargetVariant(langCode)
 -- @vvar table
 localvariants=p.getTargetVariants()

 for_,variantinipairs(variants)do
 iflangCode==variantthen
 returntrue
 end
 end

 returnfalse
 end

 -- @param string convMode Conversion mode:
 -- - LANGUAGE_CONVERTER: Convertable (language converter syntax)
 -- - UNCONVERTIBLE: Unconvertable
 -- @param string langCode MediaWiki internal language code.
 -- @param string namespaceName English canonical namespace name,
 -- use whitespace instead of underscore.
 -- @return string Localized namespace name
 functionp.getNamespaceName(convMode,langCode,namespaceName)
 ifnamespaceName==""then
 return""
 end

 -- @var table
 localnamespaceNames={
 -- Prevent fallback
 -- Always use en namespace names for zh
 ["en"]={
 -- 0 (Main)
 [""]="",
 -- 1
 ["Talk"]="Talk",
 -- 2
 ["User"]="User",
 -- 3
 ["User talk"]="User talk",
 -- 4
 ["Project"]="Project",
 ["Meta"]="Meta",
 ["Wikidata"]="Wikidata",
 -- 5
 ["Project talk"]="Project talk",
 ["Meta talk"]="Meta talk",
 ["Wikidata talk"]="Wikidata talk",
 -- 6
 ["File"]="File",
 -- 7
 ["File talk"]="File talk",
 -- 8
 ["MediaWiki"]="MediaWiki",
 -- 9
 ["MediaWiki talk"]="MediaWiki talk",
 -- 10
 ["Template"]="Template",
 -- 11
 ["Template talk"]="Template talk",
 -- 12
 ["Help"]="Help",
 -- 13
 ["Help talk"]="Help talk",
 -- 14
 ["Category"]="Category",
 -- 15
 ["Category talk"]="Category talk",
 -- 90
 ["Thread"]="Thread",
 -- 91
 ["Thread talk"]="Thread talk",
 -- 92
 ["Summary"]="Summary",
 -- 93
 ["Summary talk"]="Summary talk",
 -- 100
 ["Manual"]="Manual",
 -- 101
 ["Manual talk"]="Manual talk",
 -- 102
 ["Extension"]="Extension",
 -- 103
 ["Extension talk"]="Extension talk",
 -- 104
 ["API"]="API",
 -- 105
 ["API talk"]="API talk",
 -- 106
 ["Skin"]="Skin",
 -- 107
 ["Skin talk"]="Skin talk",
 -- 200
 ["Grants"]="Grants",
 -- 201
 ["Grants talk"]="Grants talk",
 -- 202
 ["Research"]="Research",
 -- 203
 ["Research talk"]="Research talk",
 -- 206
 ["Iberocoop"]="Iberocoop",
 -- 207
 ["Iberocoop talk"]="Iberocoop talk",
 -- 470
 ["Schema"]="Schema",
 -- 471
 ["Schema talk"]="Schema talk",
 -- 482
 ["Config"]="Config",
 -- 483
 ["Config talk"]="Config talk",
 -- 486
 ["Data"]="Data",
 -- 487
 ["Data talk"]="Data talk",
 -- 710
 ["TimedText"]="TimedText",
 -- 711
 ["TimedText talk"]="TimedText talk",
 -- 828
 ["Module"]="Module",
 -- 829
 ["Module talk"]="Module talk",
 -- 1198
 ["Translations"]="Translations",
 -- 1199
 ["Translations talk"]="Translations talk",
 -- 1728
 ["Event"]="Event",
 -- 1729
 ["Event talk"]="Event talk",
 -- 2300
 ["Gadget"]="Gadget",
 -- 2301
 ["Gadget talk"]="Gadget talk",
 -- 2302
 ["Gadget definition"]="Gadget definition",
 -- 2303
 ["Gadget definition talk"]="Gadget definition talk",
 -- 2600
 ["Topic"]="Topic",
 -- 5500
 ["Newsletter"]="Newsletter",
 -- 5501
 ["Newsletter talk"]="Newsletter talk",
 },
 ["zh-hans"]={
 ["Talk"]="讨论",
 ["User"]="用户",
 ["User talk"]="用户讨论",
 ["Project"]="项目",
 ["Meta"]="元维基",
 ["Wikidata"]="维基数据",
 ["Project talk"]="项目讨论",
 ["Meta talk"]="元维基讨论",
 ["Wikidata talk"]="维基数据讨论",
 ["File"]="文件",
 ["File talk"]="文件讨论",
 ["MediaWiki talk"]="MediaWiki讨论",
 ["Template"]="模板",
 ["Template talk"]="模板讨论",
 ["Help"]="帮助",
 ["Help talk"]="帮助讨论",
 ["Category"]="分类",
 ["Category talk"]="分类讨论",
 ["Thread"]="帖子",
 ["Thread talk"]="帖子讨论",
 ["Summary"]="摘要",
 ["Summary talk"]="摘要讨论",
 ["Manual"]="手册",
 ["Manual talk"]="手册讨论",
 ["Extension"]="扩展",
 ["Extension talk"]="扩展讨论",
 ["API"]="API",
 ["API talk"]="API讨论",
 ["Skin"]="皮肤",
 ["Skin talk"]="皮肤讨论",
 ["Grants"]="补助",
 ["Grants talk"]="补助讨论",
 ["Research"]="研究",
 ["Research talk"]="研究讨论",
 ["Iberocoop"]="Iberocoop",
 ["Iberocoop talk"]="Iberocoop讨论",
 ["Schema"]="Schema",
 ["Schema talk"]="Schema talk",
 ["Config"]="配置",
 ["Config talk"]="配置讨论",
 ["Data"]="数据",
 ["Data talk"]="数据讨论",
 ["TimedText"]="TimedText",
 ["TimedText talk"]="TimedText讨论",
 ["Module"]="模块",
 ["Module talk"]="模块讨论",
 ["Translations"]="翻译",
 ["Translations talk"]="翻译讨论",
 ["Event"]="活动",
 ["Event talk"]="活动讨论",
 ["Gadget"]="小工具",
 ["Gadget talk"]="小工具讨论",
 ["Gadget definition"]="小工具定义",
 ["Gadget definition talk"]="小工具定义讨论",
 ["Topic"]="话题",
 ["Newsletter"]="电子报",
 ["Newsletter talk"]="电子报讨论",
 },
 ["zh-hant"]={
 ["Talk"]="討論",
 ["User"]="使用者",
 ["User talk"]="使用者討論",
 ["Project"]="專案",
 ["Meta"]="元維基",
 ["Wikidata"]="維基數據",
 ["Project talk"]="專案討論",
 ["Meta talk"]="元維基討論",
 ["Wikidata talk"]="維基數據討論",
 ["File"]="檔案",
 ["File talk"]="檔案討論",
 ["MediaWiki talk"]="MediaWiki討論",
 ["Template"]="模板",
 ["Template talk"]="模板討論",
 ["Help"]="說明",
 ["Help talk"]="說明討論",
 ["Category"]="分類",
 ["Category talk"]="分類討論",
 ["Thread"]="討論串",
 ["Thread talk"]="討論串討論",
 ["Summary"]="摘要",
 ["Summary talk"]="摘要討論",
 ["Manual"]="手冊",
 ["Manual talk"]="手冊討論",
 ["Extension"]="擴充功能",
 ["Extension talk"]="擴充功能討論",
 ["API"]="API",
 ["API talk"]="API討論",
 ["Skin"]="外觀",
 ["Skin talk"]="外觀討論",
 ["Grants"]="補助",
 ["Grants talk"]="補助討論",
 ["Research"]="研究",
 ["Research talk"]="研究討論",
 ["Iberocoop"]="Iberocoop",
 ["Iberocoop talk"]="Iberocoop討論",
 ["Schema"]="綱要",
 ["Schema talk"]="綱要討論",
 ["Config"]="組態",
 ["Config talk"]="組態討論",
 ["Data"]="資料",
 ["Data talk"]="資料討論",
 ["TimedText"]="TimedText",
 ["TimedText talk"]="TimedText討論",
 ["Module"]="模組",
 ["Module talk"]="模組討論",
 ["Translations"]="翻譯",
 ["Translations talk"]="翻譯討論",
 ["Event"]="活動",
 ["Event talk"]="活動討論",
 ["Gadget"]="小工具",
 ["Gadget talk"]="小工具討論",
 ["Gadget definition"]="小工具定義",
 ["Gadget definition talk"]="小工具定義討論",
 ["Topic"]="話題",
 ["Newsletter"]="電子報",
 ["Newsletter talk"]="電子報討論",
 },
 ["zh-hk"]={
 ["User"]="用戶",
 ["User talk"]="用戶討論",
 },
 }

 -- Only allow known namespace names
 if
 namespaceNames["en"]==nilor
 namespaceNames["en"][namespaceName]==nilor
 namespaceNames["zh-hans"]==nilor
 namespaceNames["zh-hans"][namespaceName]==nilor
 namespaceNames["zh-hant"]==nilor
 namespaceNames["zh-hant"][namespaceName]==nil
 then
 returnerror("Unknown namespace name \""..tostring(namespaceName).."\"",2)
 end

 ifconvMode=="LANGUAGE_CONVERTER"then
 localt={}

 t[#t+1]="-{zh:"
 t[#t+1]=namespaceNames["en"][namespaceName]
 t[#t+1]="; zh-hans:"
 t[#t+1]=namespaceNames["zh-hans"][namespaceName]
 t[#t+1]="; zh-hant:"
 t[#t+1]=namespaceNames["zh-hant"][namespaceName]

 if
 namespaceNames["zh-hk"]and
 namespaceNames["zh-hk"][namespaceName]
 then
 t[#t+1]="; zh-hk:"
 t[#t+1]=namespaceNames["zh-hk"][namespaceName]
 end

 t[#t+1]=";}-"

 returntable.concat(t)
 end

 ifconvMode=="UNCONVERTIBLE"then
 if
 langCode=="zh-hans"or
 langCode=="zh-cn"or
 langCode=="zh-my"or
 langCode=="zh-sg"
 then
 returnnamespaceNames["zh-hans"][namespaceName]
 end

 if
 langCode=="zh-hant"or
 langCode=="zh-tw"
 then
 returnnamespaceNames["zh-hant"][namespaceName]
 end

 if
 langCode=="zh-hk"or
 langCode=="zh-mo"
 then
 return(namespaceNames["zh-hk"]andnamespaceNames["zh-hk"][namespaceName])or
 namespaceNames["zh-hans"][namespaceName]
 end

 returnnamespaceNames["en"][namespaceName]
 end

 returnerror("Unknown language conversion mode \""..tostring(convMode).."\"",2)
 end

 -- @param string langCode MediaWiki internal language code.
 -- @param table content The table contain content in different languages.
 functionp.getConvertibleLangConverterContent(langCode,content)
 -- @var table
 localcontentVariants=p.getContentVariants()

 -- @var table
 localt={}

 t[#t+1]="-{"

 for_,variantinipairs(contentVariants)do
 ifcontent[variant]~=nilthen
 t[#t+1]=variant
 t[#t+1]=":"
 t[#t+1]=content[variant]
 t[#t+1]=";"
 t[#t+1]=" "
 end
 end

 ift[7]==nilthen
 returnt[4]
 end

 t[#t]="}-"

 returntable.concat(t)
 end

 -- @param string langCode MediaWiki internal language code.
 -- @param table content The table contain content in different languages.
 functionp.getUnconvertibleContent(langCode,content)
 if
 langCode=="zh-hans"or
 langCode=="zh-cn"or
 langCode=="zh-my"or
 langCode=="zh-sg"
 then
 returncontent["zh-hans"]or
 content["zh-hant"]or
 content["zh-hk"]
 end

 if
 langCode=="zh-hant"or
 langCode=="zh-tw"
 then
 returncontent["zh-hant"]or
 content["zh-hk"]or
 content["zh-hans"]
 end

 if
 langCode=="zh-hk"or
 langCode=="zh-mo"
 then
 returncontent["zh-hk"]or
 content["zh-hant"]or
 content["zh-hans"]
 end

 returncontent["zh-hans"]or
 content["zh-hant"]or
 content["zh-hk"]
 end

 -- @param string convMode Conversion mode:
 -- - LANGUAGE_CONVERTER: Convertable (language converter syntax)
 -- - UNCONVERTIBLE: Unconvertable
 -- @param string langCode MediaWiki internal language code.
 -- @param table content The table contain content in different languages.
 functionp.getMaybeConvertibleContent(convMode,langCode,content)
 -- Require at least one of parameters: "zh-hans", "zh-hant", "zh-hk",
 -- allow empty string but not null value
 if
 content["zh-hans"]==niland
 content["zh-hant"]==niland
 content["zh-hk"]==nil
 then
 returnerror(
 "Require at least one of the parameter: \"zh-hans\", \"zh-hant\", \"zh-hk\"",
 2
 )
 end

 ifconvMode=="LANGUAGE_CONVERTER"then
 returnp.getConvertibleLangConverterContent(langCode,content)
 elseifconvMode=="UNCONVERTIBLE"then
 returnp.getUnconvertibleContent(langCode,content)
 end

 returnerror("Unknown language conversion mode \""..tostring(convMode).."\"",2)
 end

 -- @param table options
 -- @return string Wikitext
 functionp.getWikitext(options)
 -- @var string convMode Conversion mode:
 -- - LANGUAGE_CONVERTER: Convertable (language converter syntax)
 -- - UNCONVERTIBLE: Unconvertable
 localconvMode=options["mode"]

 -- @var string langCode MediaWiki internal language code.
 locallangCode=options["lang"]

 -- @var bool Whether to hide namespace text (not applied to ns_2)
 localhideNs=tostring(options["hide_ns"])~="0"

 -- @var string contentTypeCode Content type code:
 -- - N: Namespaces
 -- - T: Display title text
 -- - H: Headings wikitext
 -- - C: Content wikitext
 localcontentTypeCode=options["type"]

 -- @var string ns English canonical namespace name
 localns=options["ns"]

 -- @var string ns2 English secondary pseudo-namespace canonical namespace name
 localns2=options["ns_2"]

 -- @var table content The table contain content in different languages.
 localcontent=options["content"]

 ifcontentTypeCode=="N"then
 -- Require parameter "ns", allow empty string but not null value
 ifns==nilthen
 returnerror("Missing parameter \"ns\"",2)
 end

 -- Optional parameter "ns_2", require parameter "ns" not empty string
 ifns2~=nilandns2~=""then
 ifns==""then
 returnerror(
 "Parameter \"ns\" need to be non-empty string when parameter \"ns_2\" is used",
 2
 )
 end

 if
 hideNsor
 p.getNamespaceName(convMode,langCode,ns)==""
 then
 returnp.getNamespaceName(convMode,langCode,ns2)
 end

 returnp.getNamespaceName(convMode,langCode,ns)..
 ":"..
 p.getNamespaceName(convMode,langCode,ns2)
 end

 ifhideNsthen
 return""
 end

 returnp.getNamespaceName(convMode,langCode,ns)
 end

 ifcontentTypeCode=="T"then
 ifns==nilthen
 ns=""
 end

 -- Optional parameter "ns_2", require parameter "ns" not empty string
 ifns2~=nilandns2~=""then
 ifns==""then
 returnerror(
 "Parameter \"ns\" need to be non-empty string when parameter \"ns_2\" is used",
 2
 )
 end

 if
 hideNsor
 p.getNamespaceName(convMode,langCode,ns)==""
 then
 returnp.getNamespaceName(convMode,langCode,ns2)..
 ":"..
 p.getMaybeConvertibleContent(convMode,langCode,content)
 end

 returnp.getNamespaceName(convMode,langCode,ns)..
 ":"..
 p.getNamespaceName(convMode,langCode,ns2)..
 ":"..
 p.getMaybeConvertibleContent(convMode,langCode,content)
 end

 if
 hideNsor
 p.getNamespaceName(convMode,langCode,ns)==""
 then
 returnp.getMaybeConvertibleContent(convMode,langCode,content)
 end

 returnp.getNamespaceName(convMode,langCode,ns)..
 ":"..
 p.getMaybeConvertibleContent(convMode,langCode,content)
 end

 ifcontentTypeCode=="H"then
 -- @var table
 localcontentVariants=p.getContentVariants()

 -- @var table
 locala={}

 -- @var table For deduplication
 localaIdx={}

 -- @var string|nil
 localanc

 -- URL anchors
 for_,variantinipairs(contentVariants)do
 ifcontent[variant]~=nilandaIdx[content[variant]]==nilthen
 aIdx[content[variant]]=true

 a[#a+1]="<span id=\""
 a[#a+1]=string.gsub(content[variant]," ","_")
 a[#a+1]="\"></span>"
 end
 end

 anc=table.concat(a)

 returnanc..p.getMaybeConvertibleContent(convMode,langCode,content)
 end

 ifcontentTypeCode=="C"then
 returnp.getMaybeConvertibleContent(convMode,langCode,content)
 end

 ifcontentTypeCode=="U"then
 returnp.getUnconvertibleContent(langCode,content)
 end

 returnerror("Unknown content type code \""..tostring(contentTypeCode).."\"",2)
 end

 -- @param frame frame
 -- @param table args
 -- - lang: Output language/language variant.
 -- - hide_ns: Whether to hide the namespace prefixes.
 -- (only apply to parameter "ns", does not affect parameter "ns_2")
 -- - type: Content type code.
 -- - ns: English canonical namespace name.
 -- - ns_2: English secondary pseudo-namespace canonical namespace name.
 -- - zh-hans: Mandarin - Simplified Han script content.
 -- - zh-hant: Mandarin - Traditional Han script content.
 -- - zh-hk: Mandarin - Traditional Han script, Hong Kong content.
 -- @return string
 functionp._main(frame,args)
 -- @var title
 localpageTitle=mw.title.getCurrentTitle()

 -- @var string Title.pageLang.code is an expensive function in Scribunto,
 -- thus not using pageLang.code here
 localpageLangCode=frame:preprocess("{{PAGELANGUAGE}}")

 -- @var string Used for /variant-code subpage text detection
 localpageTitleSubpageText=pageTitle.subpageText

 -- @var string
 localuiLangCode=frame:callParserFunction{
 name="int",
 args={"lang"}
 }

 -- @var string Conversion mode:
 -- - LANGUAGE_CONVERTER: Convertable (language converter syntax)
 -- - UNCONVERTIBLE: Unconvertable
 localconvMode="LANGUAGE_CONVERTER"

 -- @var string? MediaWiki internal language code.
 locallangCode=args["lang"]

 -- @var string Content type code:
 -- - "N" - Namespace names
 -- - "T" - Page display title
 -- - "H" - Section heading
 -- - "C" - Text content
 -- - pre and syntaxhighlight should use this type.
 -- Do NOT use <pre> and <syntaxhighlight>;
 -- Use {{#tag:pre and {{#tag:syntaxhighlight instead.
 -- - "U" - Unconvertable text content
 -- - global announcements
 -- - system messages
 -- - user page templates
 -- - etc.
 localcontentType=args["type"]orargs["mode"]orargs[1]

 ifpageLangCode~="zh"orcontentType=="U"then
 convMode="UNCONVERTIBLE"

 iflangCode==nilorlangCode==""then
 ifp.hasTargetVariant(pageTitleSubpageText)then
 langCode=pageTitleSubpageText
 end
 end
 end

 iflangCode==nilorlangCode==""then
 langCode=uiLangCode
 end

 -- @var string
 localhideNs="0"

 if
 args["hide_ns"]~=niland
 args["hide_ns"]~=""
 then
 hideNs="1"
 elseif
 args["nsp"]~=niland
 args["nsp"]~=""
 then
 hideNs="1"
 elseif
 args[2]~=niland
 args[2]~=""
 then
 hideNs="1"
 end

 -- @var table options
 localoptions={
 ["mode"]=convMode,
 ["lang"]=langCode,
 ["hide_ns"]=hideNs,
 ["type"]=contentType,
 ["ns"]=args["ns"]orargs["namespace"]orargs[3],
 ["ns_2"]=args["ns_2"],
 ["content"]={
 ["zh-hans"]=args["zh-hans"],
 ["zh-hant"]=args["zh-hant"],
 ["zh-hk"]=args["zh-hk"],
 },
 }

 returnp.getWikitext(options)
 end

 -- @param frame frame
 -- @return string
 functionp.main(frame)
 localargs=p.getMergedArgs(frame)

 returnp._main(frame,args)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /