Jump to content

Module:R:Strong's

From Wiktionary, the free dictionary

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}


local function code_is_polytonic(sc)
	return sc == "Polyt" or sc == "polytonic"
end

local function text_is_polytonic(txt)
	return code_is_polytonic(require("Module:languages").getByCode("grc"):findBestScript(txt):getCode())
end

function export.strongs(frame)
	local he = require("Module:languages").getByCode("he")
	local grc = require("Module:languages").getByCode("grc")
	
	local args = frame:getParent().args
	local title = args['w'] or mw.title.getCurrentTitle().text
	local title_span = text_is_polytonic(title) and '<span class="Polyt" lang="grc">'..title..'</span>' or title

	if  mw.title.getCurrentTitle().nsText == "Template" then
		-- pass
	elseif he:findBestScript(title):getCode() == "Hebr" then
		error('Arguments for language and Strong’s Number are required for Hebrew word disambiguation.')
	elseif code_is_polytonic(grc:findBestScript(title):getCode()) then
		local strongs_concordance_numbers_G = require("Module:R:Strong's/grc-data-text-format")
		local number = tonumber(strongs_concordance_numbers_G:match(
			"%f[^%z\n]" .. require("Module:string utilities").pattern_escape(title) .. "\t(%d+)%f[%z\n]"))
		if number then
			return "G" .. number
		else
			error('The term “' .. title .. '” does not have a Strong’s number.')
		end
	else
		error('The term “' .. title .. '” is not in polytonic or Hebrew script.')
	end
end

return export