ናብ ትሕዝቶ ኪድ

ሞድዩል:Wikidata/Magnitude format

ካብ ዊኪፐድያ፣ ናጻ ኢንሳይክሎፐድያ

Documentation for this module may be created at ሞድዩል:Wikidata/Magnitude format/doc

local p = {}

function p.magnitudeFormat(value, options)
	if not value or not value.amount then
		return
	end
	
	local unitId = value.unit:match('^.-/(Q%d+)$')
	local amount = tonumber(value.amount:gsub('+','') or '')
	
	if not unitId or not amount then
		return
	end
	
	return require('Module:Convert').showValue(amount, unitId, options)
end

function p.periodicityFormat(value, options, frame)
	local result
  	--if true then return require('Module:Tables').tostring(value) end
  	
  	local function noSign(value)
  		if value and value:sub(1,1) == '+' then
  			return value:sub(2,value:len())
  		else
  			return value
  		end
  	end
  
	if value.unit == 'http://www.wikidata.org/entity/Q5151' then
  		if value.amount == '+1' then 
  			result = 'ወርሓዊ'
  		elseif value.amount == '+2' then 
  			result = 'ኣብ ክልተ ወርሒ'
  		elseif value.amount == '+3' then 
  			result = 'ኣብ ሰለስተ ዓመት'
  		elseif value.amount == '+4' then 
  			result = 'ኣብ ርብዒ ዓመት'
  		elseif value.amount == '+6' then 
  			result = 'ኣብ ሽዱሽተ ወርሒ'
  		else
  			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' ኣዋርሕ'
  		end
  	elseif value.unit == 'http://www.wikidata.org/entity/Q23387' then
  		if value.amount == '+1' then 
  			result = 'ሰሙናዊ'
  		elseif value.amount == '+2' then 
  			result = 'ኣብ ክልተ ሰሙን'
  		else
  			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' ሰሙናት'
  		end
	elseif value.unit == 'http://www.wikidata.org/entity/Q577' then
		if value.amount == '+1' then 
  			result = 'ዓመታዊ'		
  		else
  			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' ዓመታት'
  		end  			
	elseif value.unit == 'http://www.wikidata.org/entity/Q573' then
		if value.amount == '+1' then 
  			result = 'መዓልታዊ'		
  		else
  			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' መዓልታት'
  		end  					
	elseif value.unit == 'http://www.wikidata.org/entity/Q3955006' then
		if value.amount == '+1' then 
  			result = 'ኣብ ሽዱሽተ ወርሒ'		
  		else
  			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' መንፈቕ'
  		end  				  		
	else 
		if value.amount == '+1' then 
			result = 'ኣብ ነፍሲ ወከፍ ' .. value.unit
		else
			result = 'ኣብ ነፍሲ ወከፍ ' .. noSign(value.amount) .. ' ' .. value.unit
		end
	end

	if result and options and options['uppercase'] == 'yes' then
		return mw.language.new('ti'):ucfirst(result)
	else
		return result
	end
end

-- Alias to simplify use from the template property, for example:
--  {{Property|P2048)|data type=height}}
--
p['height'] 		= p.magnitudeFormat
p['área']			= p.magnitudeFormat
p['magnitude']		= p.magnitudeFormat
p['periodicity']	= p.periodicityFormat

return p