Module:User:kc kennylau/japanese

local export = {}

local ja = require("Module:ja")

function export.convert(frame) local text = mw.text.unstripNoWiki(frame.args[1]) text = mw.ustring.gsub(text, "%* {{ja%-l|([^|=}]+)|([^|=}]*)|([^|=}]+)}}", function(a,b,c)		if ja.script(a):match("Hani") then			c = mw.ustring.gsub(c, "[A-ZĀĒĪŌŪ]", function(d) return "^" .. mw.ustring.lower(d) end)			b = ja.kata_to_hira(ja.romaji_to_kata(c))		end		return "* "	end) text = mw.ustring.gsub(text, "%* {{ja%-l|([^|=}]+)|([^|=}]*)}}", "* ") text = mw.ustring.gsub(text, "%* {{l|ja|([^|=}]+)|tr=%[%[([^|=}]+)%]%], ([^|=}]+)}}", function(a,b,c)		if ja.script(a):match("Hani") then			c = mw.ustring.gsub(c, "[A-ZĀĒĪŌŪ]", function(d) return "^" .. mw.ustring.lower(d) end)			b = ja.kata_to_hira(ja.romaji_to_kata(c))			return "* "		else			return "* "		end	end) text = mw.ustring.gsub(text, "%* {{l|ja|([^|=}]+)|tr=([^|=}]+), ([^|=}]+)}}", function(a,b,c)		if ja.script(a):match("Hani") then			c = mw.ustring.gsub(c, "[A-ZĀĒĪŌŪ]", function(d) return "^" .. mw.ustring.lower(d) end)			b = ja.kata_to_hira(ja.romaji_to_kata(c))		end		return "* "	end) text = mw.ustring.gsub(text, "%* {{l|ja|([^|=}]+)|tr=[^|=}]+}}", "* ") text = mw.ustring.gsub(text, "%* %[%[([^|=}]+)%]%] %(%[%[([^|=}]+)%]%]%)", function(a,b)		if ja.script(a):match("Hani") then			b = mw.ustring.gsub(b, "[A-ZĀĒĪŌŪ]", function(c) return "^" .. mw.ustring.lower(c) end)			b = ja.kata_to_hira(ja.romaji_to_kata(b))		end		return "* "	end) return text end

return export