Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Ivan Štambuk/lang-ex-helper
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!
local p = {} -- Processes "ipa=" parameter when specified inside the {{lang-ex}} template. Adds slashes for phonemic transcription, -- unless the argument is already encapsulated within slashes (for phonemic transcription) or square brackets (for -- phonetic transcription). function p.process_ipa(frame) local ipa = frame:getParent().args["ipa"] if ipa == "" or ipa == nil then return "" end if mw.ustring.match(ipa, "^%/.*%/$") == nil and mw.ustring.match(ipa, "^%[.*%]$") == nil then return ("/" .. ipa .. "/") else return ipa end end -- Generate a wikilink to language name, followed by a whitespace, when the language code ends with "+". -- Depends on language code being expanded to full language name via the {{ISO 639 name}} template, and -- passed through "langname=" parameter, which is faster than expanding that template in Scribunto. function p.process_langcode(frame) local langcode = frame:getParent().args["1"] if langcode == "" or langcode == nil then return "" end if mw.ustring.match(langcode, "%+$") then local langname = frame.args["langname"] return "[[" .. langname .. " language|" .. langname .. "]]: " else return "" end end -- If language code provided as the first argument ends with "+", it returns the code without the "+" suffix. -- Otherwise, it returns the first argument. function p.get_bare_langcode(frame) local langcode = frame:getParent().args["1"] if langcode == "" or langcode == nil then return "" end if mw.ustring.match(langcode, "%+$") then -- strip the "+" suffix local bare_langcode = mw.ustring.sub(langcode, 1, mw.ustring.len(langcode)-1); return (bare_langcode) else return "" end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Ivan Štambuk/lang-ex-helper/doc
(
edit
)