Module:User:Hermes Thrice Great/bo-common

local export = {} local match = mw.ustring.match local gsub = mw.ustring.gsub

function split(str, pat) local t = {} -- NOTE: use {n = 0} in Lua-5.0 local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find(fpat, 1) while s do     if s ~= 1 or cap ~= "" then table.insert(t, cap) end last_end = e+1 s, e, cap = str:find(fpat, last_end) end if last_end <= #str then cap = str:sub(last_end) table.insert(t, cap) end return t end

function export.verb(frame) local title = mw.title.getCurrentTitle.text local tr_title = require("Module:Tibt-translit").tr(title, "bo", "Tibt") local tr_split_title = split(tr_title,'[\\/]+')[2] local s = { match(tr_split_title, (gsub(tr_split_title, ".", "(.)"))) } local i = table.getn(s) - 1 local j = i - 1 if match(s[i], "[aeiourl']") or (s[j] == "n" and s[i] == "g") then return "བ" end return "པ" end

return export