Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Neighbors
Esassani
Mobai
Glenn
Mors
Creatures
Fish
Insects
Shore-Dwellers
Search
Search
English
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Lang
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- Source: https://genshin-impact.fandom.com/wiki/Module:Lang local p = {} local param = {} local langCode = require('Module:Lang/code') local lib = require('Module:Feature') function trim(s) return s:match '^%s*(.-)%s*$' end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { parentFirst = true, wrappers = { 'Template:Lang' } }) return p._main(args) end function eachLang(altLangs, args, tBlock, key, value) local part = mw.html.create('span') local vertical = args.vertical or nil local append = {} if langCode[key] then if not(args.mini) then part:wikitext('<u>' .. langCode[key] .. '</u>' .. ': ') end if not(args.selective) then part:tag('span') :attr('lang', key) :wikitext(value) else part:node(p.SelectiveSpan(value, key)) end -- Auto romanization if none given if lib.isEmpty(tBlock[key .. '_rm']) and args.auto_rm then local rm if key == 'ru' then rm = require('Module:Ru-rm')._main{value} elseif key == 'ko' then rm = require('Module:Ko-rm')._main{value} end -- mw.logObject(rm, 'result') if lib.isNotEmpty(rm) then args[key .. '_rm'] = rm tBlock[key .. '_rm'] = true end end -- Special font for chinese rm due to Rubik's lack of support for some tones if lib.isNotEmpty(tBlock[key .. '_rm']) and lib.inArray({'zh', 'zh-Hans', 'zh-Hant'}, key) then args[key .. '_rm'] = '<span lang="zh-rm">' .. args[key .. '_rm'] .. '</span>' end -- Romanization if lib.isNotEmpty(tBlock[key .. '_rm']) then table.insert(append, '<i>' .. args[key .. '_rm'] .. '</i>') end -- Translation if lib.isNotEmpty(tBlock[key .. '_tl']) then if vertical then table.insert(append, args[key .. '_tl']) else table.insert(append, '"' .. args[key .. '_tl'] .. '"') end end -- Literal translation if lib.isNotEmpty(tBlock[key .. '_lit']) then table.insert(append, 'lit. "' .. args[key .. '_lit'] .. '"') end -- Build end string if #append>0 and vertical then part:wikitext('<br />' .. table.concat(append, '<br />')) elseif #append>0 then part:wikitext(' ' .. table.concat(append, ', '):gsub('", ','," ')) end else part:wikitext(key .. ': ' .. value) end table.insert(altLangs, tostring(part)) end function p._main(args) local out = mw.html.create('') local tBlock = {sort = true, mini = true, selective = true, vertical = true} --Obtain all _tn keys for k, v in pairs(args) do if mw.ustring.find(k, '_rm$') or mw.ustring.find(k, '_tl$') or mw.ustring.find(k, '_lit$') then tBlock[k] = true end end --Obtain all numerical keys for k,v in ipairs(args) do tBlock[k] = true end --Output default Value out:wikitext(args[1]) local altLangs = {} --Process Sort Paremeter (Split by Delimiter: comma) for sKey in string.gmatch(args.sort or '', '([^,]+)') do if not(tBlock[sKey]) and args[sKey] then eachLang(altLangs, args, tBlock, sKey, args[sKey]) tBlock[sKey]=true end end --Process Rest for key, value in pairs(args) do if not(tBlock[key]) then eachLang(altLangs, args, tBlock, key, value) end end if #altLangs>0 then if not(args.mini) then out:wikitext(' (') end out:wikitext(table.concat(altLangs,'; ')) if not(args.mini) then out:wikitext(')') end end return tostring(out) end function p.SelectiveSpan(s, lang, if1all) --initial check, return blank if nil if s then else return '' end --mw.logObject(s,'Input') --debug --initialize tables local span = {} local nospan = {} local split = {} --separate the string through unicode codepoints as default lua split cannot handle non-UTF-8 characters for c in mw.ustring.gcodepoint(s) do --mw.logObject(c,'c') --debug table.insert(split, mw.ustring.char(c)) end --mw.logObject(split,'split') --debug --separate the split string into ASCII and non-ASCII, include anything inside '<>' as ASCII to not mess with html tags rendering local loopnum = 1 local html, link = false, false while split[loopnum] do --check for start of html tag if split[loopnum] == '<' then html = true end --check for start of link if (split[loopnum] == '[' and split[loopnum+1] == '[') then link = true end if (split[loopnum]:find('[\201-\255ÊêÔôƠơƯưẮắẤấẾếỐốỚớỨứẰằẦầỀềỒồỜờỪừẢảẲẳẨẩẺẻỂểỈỉỎỏỔổỞởỦủỬửỶỷẴẵẪẫẼẽỄễỖỗỠỡỮữỸỹẠạẶặẬậẸẹỆệỊịỌọỘộỢợỤụỰựỴỵ]') and html == false and link == false) then span[loopnum] = split[loopnum] else nospan[loopnum] = split[loopnum] end --check for end of html tag if split[loopnum] == '>' then html = false end --check for end of link if (split[loopnum] == '|' or (split[loopnum] == ']' and split[loopnum+1] == ']')) then link = false end loopnum = loopnum + 1 end --mw.logObject(span,'span') --debug --mw.logObject(nospan,'nospan') --debug if (if1all and next(span, nil) ~= nil) then return mw.html.create('span'):attr('lang', lang):wikitext(s) end --build the string while applying the lang span to the non-ASCII characters only local i = 1 local s = mw.html.create() while (span[i] or nospan[i]) do if span[i] then local text = mw.html.create() local try = true text:wikitext(span[i]) while try do if span[i+1] then text:wikitext(span[i+1]) i = i + 1 else try = false end end s:tag('span'):attr('lang', lang):node(text):done() elseif nospan[i] then s:wikitext(nospan[i]) end i = i + 1 end --mw.logObject(s,'Output') --debug return s end function p.CleanTT(tx) local full = tx local result = tx for tooltip, display in string.gmatch(full, '<span[^>]+title="([^>]-)">(.-)</span>') do search_str = '<span[^>]+title="' .. tooltip .. '">(' .. display .. ')</span><span[^>]+><span[^>]+>' .. display .. '</span><span[^>]+>' .. tooltip .. '</span></span>' result = result:gsub(search_str, display) end return result end return p
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Petit Planet:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Template used on this page:
Module:Lang/doc
(
edit
)