This submodule is used by Module:Wd for internationalization (i18n) purposes and has been separated to allow for locale-independent updating of the module's logic.



-- The values and functions in this submodule should be localized per wiki.

-- load submodule "aliasesP" that lives next to this submodule
local aliasesP = mw.loadData((...):sub(1, (...):match('^.*()/') - 1).."/aliasesP")

local p = {
	["errors"] = {
		["unknown-data-type"]          = 'Неизвестен или неподдържан тип данни „$1“',
		["missing-required-parameter"] = 'Не са дефинирани задължителни параметри, изисква се поне един',
		["extra-required-parameter"]   = 'Параметър „$1“ трябва да бъде дефиниран като незадължителен',
		["no-function-specified"]      = 'Трябва да бъде посочена функция за извикване', -- equal to the standard module error message
		["main-called-twice"]          = 'Функцията main не може да бъде извикана два пъти',
		["no-such-function"]           = 'Функцията „$1“ не съществува' -- equal to the standard module error message
	},
	["info"] = {
		["edit-on-wikidata"] = 'Редактиране в Уикиданни'
	},
	["numeric"] = {
		["10^6"]   = ' млн.',
		["10^9"]   = ' млрд.',
		["10^12"]  = ' трлн.',
		["decimal-mark"] = ',',
		["delimiter"]    = ' '
	},
	["datetime"] = {
		["prefixes"] = {
			["decade-period"] = ''
		},
		["suffixes"] = {
			["decade-period"] = '-те',
			["millennium"]    = ' хилядолетие',
			["century"]       = ' век',
			["million-years"] = ' млн. години',
			["billion-years"] = ' млрд. години',
			["year"]          = ' г.',
			["years"]         = ' години'
		},
		["julian-calendar"] = 'Приемане на григорианския календар', -- linked page title
		["julian"]          = 'стар стил',
		["BCE"]             = 'пр.н.е.',
		["CE"]              = 'сл.н.е.',
		["common-era"]      = 'Нова Ера' -- linked page title
	},
	["coord"] = {
		["latitude-north"] = "N",
		["latitude-south"] = "S",
		["longitude-east"] = "E",
		["longitude-west"] = "W",
		["degrees"]        = "°",
		["minutes"]        = "'",
		["seconds"]        = '"',
		["separator"]      = ", "
	},
	["values"] = {
		["unknown"] = "неизв.",
		["none"]    = "няма"
	},
	["cite"] = {
		["citeVersion"]                 = 3, -- increment this each time the below parameters are changed to avoid conflict errors
		["coauthors"]                   = "съавтори-част",
		[aliasesP.author]               = "автор-част",
		[aliasesP.title]                = "заглавие-част",
		[aliasesP.referenceURL]         = "url-част",
		[aliasesP.statedIn]             = "заглавие",
		[aliasesP.chapter]              = "издание",
		[aliasesP.volume]               = "том",
		[aliasesP.publicationDate]      = "дата",
		[aliasesP.retrieved]            = "достъп-дата",
		[aliasesP.archiveURL]           = "архив-url",
		[aliasesP.archiveDate]          = "архив-дата",
		[aliasesP.language]             = "език",
		[aliasesP.publisher]            = "издател",
		[aliasesP.publishedIn]          = "място",
		[aliasesP.quote]                = "цитат",
		[aliasesP.pages]                = "страница",
	}
}

function p.getOrdinalSuffix(num, gen)
	local gLetter = 'и'
	
	if gen == p['datetime']['suffixes']['millennium'] then
		gLetter = 'о'
	end
	
	if tostring(num):sub(-2,-2) == '1' then
		return '-' .. gLetter -- 10th, 11th, 12th, 13th, ... 19th
	end
	
	num = tostring(num):sub(-1)
	
	if num == '1' then
		return '-в' .. gLetter
	elseif num == '2' then
		return '-р' .. gLetter
	elseif num == '3' or num == '4' then
		return '-т' .. gLetter
	else
		return '-' .. gLetter
	end
end

function p.formatQuantity(value, short)
	local num = tonumber(value)
	
	if not num then
		-- not a proper number
		return value
	end
	
	local suffix = ''
	if short then
		if math.abs(num/10^12) >= 1 then
			num = num/10^12
			suffix = p['numeric']['10^12']
		elseif math.abs(num/10^9) >= 1 then
			num = num/10^9
			suffix = p['numeric']['10^9']
		elseif math.abs(num/10^6) >= 1 then
			num = num/10^6
			suffix = p['numeric']['10^6']
		end
	end
		
	if math.abs(num) >= 1 then
		num = tonumber(mw.ustring.format('%.3f', num)) -- round to 3 digits after decimal (1/1000)
	end
	
	return mw.ustring.gsub(mw.getContentLanguage():formatNum(num) .. suffix, '%s+', p['numeric']['delimiter'])
end

function p.formatMultilanguageText(text, lang, code)
	if text and lang and lang ~= code then
		local dir = mw.language.new(lang):isRTL() and 'rtl' or 'ltr'
		return mw.text.tag('span', {['dir'] = dir, ['lang'] = lang}, text)
	end
	
	return nil
end

return p