<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://bsd.neuroinf.jp/w/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3AOrdinal</id>
	<title>モジュール:Ordinal - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://bsd.neuroinf.jp/w/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3AOrdinal"/>
	<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Ordinal&amp;action=history"/>
	<updated>2026-04-15T12:02:10Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Ordinal&amp;diff=35033&amp;oldid=prev</id>
		<title>WikiSysop: 1版</title>
		<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Ordinal&amp;diff=35033&amp;oldid=prev"/>
		<updated>2016-03-05T00:55:49Z</updated>

		<summary type="html">&lt;p&gt;1版&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
 &lt;br /&gt;
This template will add the appropriate ordinal suffix to a given integer.&lt;br /&gt;
 &lt;br /&gt;
Please do not modify this code without applying the changes first at Module:Ordinal/sandbox and testing &lt;br /&gt;
at Module:Ordinal/sandbox/testcases and Module talk:Ordinal/sandbox/testcases.&lt;br /&gt;
 &lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:RP88&lt;br /&gt;
 &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
 &lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Dependencies ======================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
local i18n      = require(&amp;#039;Module:I18n/ordinal&amp;#039;)        -- get localized translations of ordinals&lt;br /&gt;
local fallback  = require(&amp;#039;Module:Fallback&amp;#039;)            -- get fallback functions&lt;br /&gt;
local yesno     = require(&amp;#039;Module:Yesno&amp;#039;)               -- boolean value interpretation&lt;br /&gt;
local formatnum = require(&amp;#039;Module:Formatnum&amp;#039;)           -- number formatting&lt;br /&gt;
local roman     = require(&amp;#039;Module:Roman&amp;#039;)               -- roman numeral conversion (primarily for French)&lt;br /&gt;
&lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Public Functions ==================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Ordinal&lt;br /&gt;
 &lt;br /&gt;
This function converts an integer value into a numeral followed by ordinal indicator.  The output string might &lt;br /&gt;
contain HTML tags unless you set nosup=y.&lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:Ordinal|Ordinal|1=|lang=|style=|gender=|nosup=|debug=}}&lt;br /&gt;
{{#invoke:Ordinal|Ordinal}} - uses the caller&amp;#039;s parameters&lt;br /&gt;
 &lt;br /&gt;
Parameters&lt;br /&gt;
    1: Positive integer number. &lt;br /&gt;
    lang: language&lt;br /&gt;
    style: Presentation style. Different options for different languages. In English there is &amp;quot;style=d&amp;quot; adding -d suffixes to all numbers.&lt;br /&gt;
    gender: Gender is used in French and Polish language versions. Genders: m for male, f for female and n for neuter.	&lt;br /&gt;
    nosup: Set nosup=y to display the ordinals without superscript.&lt;br /&gt;
    debug: Set debug=y to output error messages.&lt;br /&gt;
    &lt;br /&gt;
Error Handling:&lt;br /&gt;
   Unless debug=y, any error results in parameter 1 being echoed to the output.  This reproduces the behavior of the original Ordinal template.&lt;br /&gt;
]]&lt;br /&gt;
function p.Ordinal( frame )&lt;br /&gt;
	-- if no argument provided than check parent template/module args&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	if args[1]==nil then&lt;br /&gt;
		args = frame:getParent().args &lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	--  if we don&amp;#039;t have a specified language, attempt to use the user&amp;#039;s language&lt;br /&gt;
	local lang = args.lang&lt;br /&gt;
	if not lang or lang == &amp;#039;&amp;#039; or not mw.language.isValidCode( lang ) then&lt;br /&gt;
		lang = frame:preprocess(&amp;#039;{{int:lang}}&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local nosup = yesno(args[&amp;quot;nosup&amp;quot;] or &amp;#039;&amp;#039;, false) -- nosup can be true or false&lt;br /&gt;
	local debugging = yesno(args[&amp;quot;debug&amp;quot;], false) -- debugging can be nil, true, or false&lt;br /&gt;
&lt;br /&gt;
	-- also enable debugging if debug is unspecified, and &amp;quot;nosup&amp;quot; is false&lt;br /&gt;
	debugging = debugging or ((debugging == nil) and not nosup)&lt;br /&gt;
		&lt;br /&gt;
	local output = p._Ordinal( &lt;br /&gt;
		args[1],  					-- positive integer number&lt;br /&gt;
		lang,						-- language&lt;br /&gt;
		args[&amp;quot;style&amp;quot;],				-- allows to set presentation style&lt;br /&gt;
		args[&amp;quot;gender&amp;quot;], 			-- allows to specify gender (m, f, or n)&lt;br /&gt;
		nosup,						-- set nosup to &amp;quot;y&amp;quot; to suppress superscripts&lt;br /&gt;
		debugging					-- Set debug=y to output error messages&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	-- Add maintenance category&lt;br /&gt;
	if (i18n.SchemeFromLang[lang] == nil) and debugging then &lt;br /&gt;
		output = output_cat(output, &amp;#039;Pages with calls to Module Ordinal using an unsupported language&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function will add the appropriate ordinal suffix to a given integer. &lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	input: Numeral as a positive integer or string.&lt;br /&gt;
	lang: Language code as a string (e.g. &amp;#039;en&amp;#039;, &amp;#039;de&amp;#039;, etc.).&lt;br /&gt;
	style: Presentation style as a string (e.g. &amp;#039;d&amp;#039;, &amp;#039;roman&amp;#039;, etc.).&lt;br /&gt;
	gender: Gender as a string (&amp;#039;m&amp;#039;, &amp;#039;f&amp;#039;, &amp;#039;n&amp;#039;).  Use empty string &amp;#039;&amp;#039; to leave gender unspecified.&lt;br /&gt;
	nosup: Boolean, set to true to force the ordinals to display without superscript.&lt;br /&gt;
	debug: Boolean, set to true to output error messages.&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
   Unless debug is true, any error results in value being echoed to the output.&lt;br /&gt;
]]&lt;br /&gt;
function p._Ordinal( input, lang, style, gender, nosup, debugging )	&lt;br /&gt;
	local output = input&lt;br /&gt;
	&lt;br /&gt;
	if input then&lt;br /&gt;
		local value = tonumber(input)&lt;br /&gt;
		if value and (value &amp;gt; 0) then&lt;br /&gt;
		&lt;br /&gt;
			-- Normalize style, the style &amp;#039;roman year&amp;#039; is an alias for &amp;#039;roman&amp;#039;&lt;br /&gt;
			style = string.lower(style or &amp;#039;&amp;#039;)&lt;br /&gt;
			if style == &amp;#039;roman year&amp;#039; then&lt;br /&gt;
				style = &amp;#039;roman&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- Normalize gender parameter&lt;br /&gt;
			gender = string.lower(gender or &amp;#039;&amp;#039;)&lt;br /&gt;
			if (gender ~= &amp;#039;m&amp;#039;) and (gender ~= &amp;#039;f&amp;#039;) and (gender ~= &amp;#039;n&amp;#039;) then&lt;br /&gt;
				gender = &amp;#039;&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
	&lt;br /&gt;
			-- if no language is specified, default to english (caller might want to get user&amp;#039;s language)&lt;br /&gt;
			if not lang or lang == &amp;#039;&amp;#039; then&lt;br /&gt;
				lang = &amp;#039;en&amp;#039;;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			output = OrdinalCore( value, lang, style, gender, nosup )&lt;br /&gt;
		else&lt;br /&gt;
			if debugging then&lt;br /&gt;
				output = output_error( &amp;quot;not a number&amp;quot;, input )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if debugging then&lt;br /&gt;
			output = output_error( &amp;quot;not a number&amp;quot;, &amp;#039;&amp;#039; )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Private Functions =================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function is the core functionality for adding the appropriate ordinal suffix to a given integer.&lt;br /&gt;
]]&lt;br /&gt;
function OrdinalCore( value, lang, style, gender, nosup )	&lt;br /&gt;
	-- Just in case someone breaks the internationalization code, fix the english scheme&lt;br /&gt;
	if i18n.SchemeFromLang[&amp;#039;en&amp;#039;] == nil then&lt;br /&gt;
		i18n.SchemeFromLang[&amp;#039;en&amp;#039;] = &amp;#039;en-scheme&amp;#039;&lt;br /&gt;
	end	&lt;br /&gt;
	if i18n.Scheme[&amp;#039;en-scheme&amp;#039;] == nil then&lt;br /&gt;
		i18n.Scheme[&amp;#039;en-scheme&amp;#039;] = {rules = &amp;#039;skip-tens&amp;#039;, superscript = true, suffix = &amp;#039;th&amp;#039;, suffix_1 = &amp;#039;st&amp;#039;, suffix_2 = &amp;#039;nd&amp;#039;, suffix_3 = &amp;#039;rd&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Add the default scheme (i.e. &amp;quot;&amp;lt;value&amp;gt;.&amp;quot;)&lt;br /&gt;
	if i18n.SchemeFromLang[&amp;#039;default&amp;#039;] == nil then&lt;br /&gt;
		i18n.SchemeFromLang[&amp;#039;default&amp;#039;] = &amp;#039;period-scheme&amp;#039;&lt;br /&gt;
	end	&lt;br /&gt;
	if i18n.Scheme[&amp;#039;period-scheme&amp;#039;] == nil then&lt;br /&gt;
		i18n.Scheme[&amp;#039;period-scheme&amp;#039;] = {rules = &amp;#039;suffix&amp;#039;, suffix = &amp;#039;.&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	-- which scheme should we use to format the ordinal value? &lt;br /&gt;
	-- Use Fallback module to handle languages groups that map to a supported language&lt;br /&gt;
	local schemeSpecifier = fallback._langSwitch(i18n.SchemeFromLang, lang)&lt;br /&gt;
	&lt;br /&gt;
	-- Look up scheme based on scheme specifier (and possibly style)&lt;br /&gt;
	local scheme = i18n.Scheme[schemeSpecifier .. &amp;#039;/&amp;#039; .. style] or i18n.Scheme[schemeSpecifier]&lt;br /&gt;
	&lt;br /&gt;
	-- process scheme by applying rules identified by Scheme&lt;br /&gt;
	local output = &amp;#039;&amp;#039;&lt;br /&gt;
	local period = (scheme.period and &amp;#039;.&amp;#039;) or &amp;#039;&amp;#039;&lt;br /&gt;
	local rules = scheme.rules&lt;br /&gt;
	if rules == &amp;#039;skip-tens&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		local mod100 = math.floor(math.abs(value)) % 100&lt;br /&gt;
		if (mod100 &amp;gt;= 10) and (mod100 &amp;lt;= 19) then&lt;br /&gt;
			suffix = scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			local mod10 = math.floor(math.abs(value)) % 10&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..mod10] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;suffix&amp;#039; then&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( scheme.suffix or &amp;#039;&amp;#039;, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;prefix&amp;#039; then&lt;br /&gt;
		output = (scheme.prefix or &amp;#039;&amp;#039;) .. FormatNum(value, scheme.formatlang or lang)&lt;br /&gt;
	elseif rules == &amp;#039;mod10-suffix&amp;#039; then&lt;br /&gt;
		local index = math.floor(math.abs(value)) % 10&lt;br /&gt;
		local suffix = scheme[&amp;#039;suffix_&amp;#039;..index] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;gendered-suffix&amp;#039; then&lt;br /&gt;
		local suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;gendered-suffix-one&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		if value &amp;lt; 5 then&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..value..&amp;#039;_&amp;#039;..gender] or scheme[&amp;#039;suffix_&amp;#039;..value] or scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;suffix-one&amp;#039; then&lt;br /&gt;
		local prefix, suffix&lt;br /&gt;
		if value == 1 then&lt;br /&gt;
			prefix = scheme[&amp;#039;prefix_1&amp;#039;] or scheme.prefix or &amp;#039;&amp;#039;&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_1&amp;#039;] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			prefix = scheme.prefix or &amp;#039;&amp;#039;&lt;br /&gt;
			suffix = scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = prefix .. FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;mod10-gendered-suffix-skip-tens&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		local mod100 = math.floor(math.abs(value)) % 100&lt;br /&gt;
		if (mod100 &amp;gt;= 10) and (mod100 &amp;lt;= 19) then&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			local mod10 = math.floor(math.abs(value)) % 10&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..mod10..&amp;#039;_&amp;#039;..gender] or scheme[&amp;#039;suffix_&amp;#039;..mod10] or scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	else&lt;br /&gt;
		output = FormatNum(value, lang)&lt;br /&gt;
	end &lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to generate superscripted content&lt;br /&gt;
]]&lt;br /&gt;
function Superscript( str, superscript, nosup, period )&lt;br /&gt;
	if superscript and (not nosup) then&lt;br /&gt;
		return period .. &amp;#039;&amp;lt;sup&amp;gt;&amp;#039; .. str .. &amp;#039;&amp;lt;/sup&amp;gt;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return str&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to call Formatnum.&lt;br /&gt;
]]&lt;br /&gt;
function FormatNum( value, lang )&lt;br /&gt;
	if lang == &amp;#039;roman&amp;#039; then&lt;br /&gt;
		return roman._Numeral(value)&lt;br /&gt;
	else&lt;br /&gt;
		return formatnum.formatNum(value, lang)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to handle error messages.&lt;br /&gt;
]]&lt;br /&gt;
function output_error( error_str, value )&lt;br /&gt;
	error_str = &amp;#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;&amp;lt;span title=&amp;quot;Error: &amp;#039; .. error_str .. &amp;#039;&amp;quot;&amp;gt;&amp;#039; .. value .. &amp;#039;&amp;lt;/span&amp;gt;&amp;lt;/strong&amp;gt;&amp;#039;&lt;br /&gt;
    return output_cat(error_str, &amp;#039;Errors reported by Module Ordinal&amp;#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to add append a category to a message.&lt;br /&gt;
]]&lt;br /&gt;
function output_cat( message, category )&lt;br /&gt;
    return message .. &amp;#039;[[Category:&amp;#039; .. category .. &amp;#039;]]&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Ordinal&amp;diff=30444&amp;oldid=prev</id>
		<title>WikiSysop: 1版</title>
		<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Ordinal&amp;diff=30444&amp;oldid=prev"/>
		<updated>2015-06-16T22:32:16Z</updated>

		<summary type="html">&lt;p&gt;1版&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
 &lt;br /&gt;
This template will add the appropriate ordinal suffix to a given integer.&lt;br /&gt;
 &lt;br /&gt;
Please do not modify this code without applying the changes first at Module:Ordinal/sandbox and testing &lt;br /&gt;
at Module:Ordinal/sandbox/testcases and Module talk:Ordinal/sandbox/testcases.&lt;br /&gt;
 &lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:RP88&lt;br /&gt;
 &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
 &lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Dependencies ======================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
local i18n      = require(&amp;#039;Module:I18n/ordinal&amp;#039;)        -- get localized translations of ordinals&lt;br /&gt;
local fallback  = require(&amp;#039;Module:Fallback&amp;#039;)            -- get fallback functions&lt;br /&gt;
local yesno     = require(&amp;#039;Module:Yesno&amp;#039;)               -- boolean value interpretation&lt;br /&gt;
local formatnum = require(&amp;#039;Module:Formatnum&amp;#039;)           -- number formatting&lt;br /&gt;
local roman     = require(&amp;#039;Module:Roman&amp;#039;)               -- roman numeral conversion (primarily for French)&lt;br /&gt;
&lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Public Functions ==================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Ordinal&lt;br /&gt;
 &lt;br /&gt;
This function converts an integer value into a numeral followed by ordinal indicator.  The output string might &lt;br /&gt;
contain HTML tags unless you set nosup=y.&lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:Ordinal|Ordinal|1=|lang=|style=|gender=|nosup=|debug=}}&lt;br /&gt;
{{#invoke:Ordinal|Ordinal}} - uses the caller&amp;#039;s parameters&lt;br /&gt;
 &lt;br /&gt;
Parameters&lt;br /&gt;
    1: Positive integer number. &lt;br /&gt;
    lang: language&lt;br /&gt;
    style: Presentation style. Different options for different languages. In English there is &amp;quot;style=d&amp;quot; adding -d suffixes to all numbers.&lt;br /&gt;
    gender: Gender is used in French and Polish language versions. Genders: m for male, f for female and n for neuter.	&lt;br /&gt;
    nosup: Set nosup=y to display the ordinals without superscript.&lt;br /&gt;
    debug: Set debug=y to output error messages.&lt;br /&gt;
    &lt;br /&gt;
Error Handling:&lt;br /&gt;
   Unless debug=y, any error results in parameter 1 being echoed to the output.  This reproduces the behavior of the original Ordinal template.&lt;br /&gt;
]]&lt;br /&gt;
function p.Ordinal( frame )&lt;br /&gt;
	-- if no argument provided than check parent template/module args&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	if args[1]==nil then&lt;br /&gt;
		args = frame:getParent().args &lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	--  if we don&amp;#039;t have a specified language, attempt to use the user&amp;#039;s language&lt;br /&gt;
	local lang = args.lang&lt;br /&gt;
	if not lang or lang == &amp;#039;&amp;#039; or not mw.language.isValidCode( lang ) then&lt;br /&gt;
		lang = frame:preprocess(&amp;#039;{{int:lang}}&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local nosup = yesno(args[&amp;quot;nosup&amp;quot;] or &amp;#039;&amp;#039;, false) -- nosup can be true or false&lt;br /&gt;
	local debugging = yesno(args[&amp;quot;debug&amp;quot;], false) -- debugging can be nil, true, or false&lt;br /&gt;
&lt;br /&gt;
	-- also enable debugging if debug is unspecified, and &amp;quot;nosup&amp;quot; is false&lt;br /&gt;
	debugging = debugging or ((debugging == nil) and not nosup)&lt;br /&gt;
		&lt;br /&gt;
	local output = p._Ordinal( &lt;br /&gt;
		args[1],  					-- positive integer number&lt;br /&gt;
		lang,						-- language&lt;br /&gt;
		args[&amp;quot;style&amp;quot;],				-- allows to set presentation style&lt;br /&gt;
		args[&amp;quot;gender&amp;quot;], 			-- allows to specify gender (m, f, or n)&lt;br /&gt;
		nosup,						-- set nosup to &amp;quot;y&amp;quot; to suppress superscripts&lt;br /&gt;
		debugging					-- Set debug=y to output error messages&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	-- Add maintenance category&lt;br /&gt;
	if (i18n.SchemeFromLang[lang] == nil) and debugging then &lt;br /&gt;
		output = output_cat(output, &amp;#039;Pages with calls to Module Ordinal using an unsupported language&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function will add the appropriate ordinal suffix to a given integer. &lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	input: Numeral as a positive integer or string.&lt;br /&gt;
	lang: Language code as a string (e.g. &amp;#039;en&amp;#039;, &amp;#039;de&amp;#039;, etc.).&lt;br /&gt;
	style: Presentation style as a string (e.g. &amp;#039;d&amp;#039;, &amp;#039;roman&amp;#039;, etc.).&lt;br /&gt;
	gender: Gender as a string (&amp;#039;m&amp;#039;, &amp;#039;f&amp;#039;, &amp;#039;n&amp;#039;).  Use empty string &amp;#039;&amp;#039; to leave gender unspecified.&lt;br /&gt;
	nosup: Boolean, set to true to force the ordinals to display without superscript.&lt;br /&gt;
	debug: Boolean, set to true to output error messages.&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
   Unless debug is true, any error results in value being echoed to the output.&lt;br /&gt;
]]&lt;br /&gt;
function p._Ordinal( input, lang, style, gender, nosup, debugging )	&lt;br /&gt;
	local output = input&lt;br /&gt;
	&lt;br /&gt;
	if input then&lt;br /&gt;
		local value = tonumber(input)&lt;br /&gt;
		if value and (value &amp;gt; 0) then&lt;br /&gt;
		&lt;br /&gt;
			-- Normalize style, the style &amp;#039;roman year&amp;#039; is an alias for &amp;#039;roman&amp;#039;&lt;br /&gt;
			style = string.lower(style or &amp;#039;&amp;#039;)&lt;br /&gt;
			if style == &amp;#039;roman year&amp;#039; then&lt;br /&gt;
				style = &amp;#039;roman&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- Normalize gender parameter&lt;br /&gt;
			gender = string.lower(gender or &amp;#039;&amp;#039;)&lt;br /&gt;
			if (gender ~= &amp;#039;m&amp;#039;) and (gender ~= &amp;#039;f&amp;#039;) and (gender ~= &amp;#039;n&amp;#039;) then&lt;br /&gt;
				gender = &amp;#039;&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
	&lt;br /&gt;
			-- if no language is specified, default to english (caller might want to get user&amp;#039;s language)&lt;br /&gt;
			if not lang or lang == &amp;#039;&amp;#039; then&lt;br /&gt;
				lang = &amp;#039;en&amp;#039;;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			output = OrdinalCore( value, lang, style, gender, nosup )&lt;br /&gt;
		else&lt;br /&gt;
			if debugging then&lt;br /&gt;
				output = output_error( &amp;quot;not a number&amp;quot;, input )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if debugging then&lt;br /&gt;
			output = output_error( &amp;quot;not a number&amp;quot;, &amp;#039;&amp;#039; )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Private Functions =================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function is the core functionality for adding the appropriate ordinal suffix to a given integer.&lt;br /&gt;
]]&lt;br /&gt;
function OrdinalCore( value, lang, style, gender, nosup )	&lt;br /&gt;
	-- Just in case someone breaks the internationalization code, fix the english scheme&lt;br /&gt;
	if i18n.SchemeFromLang[&amp;#039;en&amp;#039;] == nil then&lt;br /&gt;
		i18n.SchemeFromLang[&amp;#039;en&amp;#039;] = &amp;#039;en-scheme&amp;#039;&lt;br /&gt;
	end	&lt;br /&gt;
	if i18n.Scheme[&amp;#039;en-scheme&amp;#039;] == nil then&lt;br /&gt;
		i18n.Scheme[&amp;#039;en-scheme&amp;#039;] = {rules = &amp;#039;skip-tens&amp;#039;, superscript = true, suffix = &amp;#039;th&amp;#039;, suffix_1 = &amp;#039;st&amp;#039;, suffix_2 = &amp;#039;nd&amp;#039;, suffix_3 = &amp;#039;rd&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Add the default scheme (i.e. &amp;quot;&amp;lt;value&amp;gt;.&amp;quot;)&lt;br /&gt;
	if i18n.SchemeFromLang[&amp;#039;default&amp;#039;] == nil then&lt;br /&gt;
		i18n.SchemeFromLang[&amp;#039;default&amp;#039;] = &amp;#039;period-scheme&amp;#039;&lt;br /&gt;
	end	&lt;br /&gt;
	if i18n.Scheme[&amp;#039;period-scheme&amp;#039;] == nil then&lt;br /&gt;
		i18n.Scheme[&amp;#039;period-scheme&amp;#039;] = {rules = &amp;#039;suffix&amp;#039;, suffix = &amp;#039;.&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	-- which scheme should we use to format the ordinal value? &lt;br /&gt;
	-- Use Fallback module to handle languages groups that map to a supported language&lt;br /&gt;
	local schemeSpecifier = fallback._langSwitch(i18n.SchemeFromLang, lang)&lt;br /&gt;
	&lt;br /&gt;
	-- Look up scheme based on scheme specifier (and possibly style)&lt;br /&gt;
	local scheme = i18n.Scheme[schemeSpecifier .. &amp;#039;/&amp;#039; .. style] or i18n.Scheme[schemeSpecifier]&lt;br /&gt;
	&lt;br /&gt;
	-- process scheme by applying rules identified by Scheme&lt;br /&gt;
	local output = &amp;#039;&amp;#039;&lt;br /&gt;
	local period = (scheme.period and &amp;#039;.&amp;#039;) or &amp;#039;&amp;#039;&lt;br /&gt;
	local rules = scheme.rules&lt;br /&gt;
	if rules == &amp;#039;skip-tens&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		local mod100 = math.floor(math.abs(value)) % 100&lt;br /&gt;
		if (mod100 &amp;gt;= 10) and (mod100 &amp;lt;= 19) then&lt;br /&gt;
			suffix = scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			local mod10 = math.floor(math.abs(value)) % 10&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..mod10] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;suffix&amp;#039; then&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( scheme.suffix or &amp;#039;&amp;#039;, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;prefix&amp;#039; then&lt;br /&gt;
		output = (scheme.prefix or &amp;#039;&amp;#039;) .. FormatNum(value, scheme.formatlang or lang)&lt;br /&gt;
	elseif rules == &amp;#039;mod10-suffix&amp;#039; then&lt;br /&gt;
		local index = math.floor(math.abs(value)) % 10&lt;br /&gt;
		local suffix = scheme[&amp;#039;suffix_&amp;#039;..index] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;gendered-suffix&amp;#039; then&lt;br /&gt;
		local suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;gendered-suffix-one&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		if value == 1 then&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_1_&amp;#039;..gender] or scheme[&amp;#039;suffix_1&amp;#039;] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;suffix-one&amp;#039; then&lt;br /&gt;
		local prefix, suffix&lt;br /&gt;
		if value == 1 then&lt;br /&gt;
			prefix = scheme[&amp;#039;prefix_1&amp;#039;] or scheme.prefix or &amp;#039;&amp;#039;&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_1&amp;#039;] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			prefix = scheme.prefix or &amp;#039;&amp;#039;&lt;br /&gt;
			suffix = scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = prefix .. FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	elseif rules == &amp;#039;mod10-gendered-suffix-skip-tens&amp;#039; then&lt;br /&gt;
		local suffix&lt;br /&gt;
		local mod100 = math.floor(math.abs(value)) % 100&lt;br /&gt;
		if (mod100 &amp;gt;= 10) and (mod100 &amp;lt;= 19) then&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			local mod10 = math.floor(math.abs(value)) % 10&lt;br /&gt;
			suffix = scheme[&amp;#039;suffix_&amp;#039;..mod10..&amp;#039;_&amp;#039;..gender] or scheme[&amp;#039;suffix_&amp;#039;..mod10] or scheme[&amp;#039;suffix_&amp;#039;..gender] or scheme.suffix or &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		output = FormatNum(value, scheme.formatlang or lang) .. Superscript( suffix, scheme.superscript, nosup, period)&lt;br /&gt;
	else&lt;br /&gt;
		output = FormatNum(value, lang)&lt;br /&gt;
	end &lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to generate superscripted content&lt;br /&gt;
]]&lt;br /&gt;
function Superscript( str, superscript, nosup, period )&lt;br /&gt;
	if superscript and (not nosup) then&lt;br /&gt;
		return period .. &amp;#039;&amp;lt;sup&amp;gt;&amp;#039; .. str .. &amp;#039;&amp;lt;/sup&amp;gt;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return str&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to call Formatnum.&lt;br /&gt;
]]&lt;br /&gt;
function FormatNum( value, lang )&lt;br /&gt;
	if lang == &amp;#039;roman&amp;#039; then&lt;br /&gt;
		return roman._Numeral(value)&lt;br /&gt;
	else&lt;br /&gt;
		return formatnum.formatNum(value, lang)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to handle error messages.&lt;br /&gt;
]]&lt;br /&gt;
function output_error( error_str, value )&lt;br /&gt;
	error_str = &amp;#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;&amp;lt;span title=&amp;quot;Error: &amp;#039; .. error_str .. &amp;#039;&amp;quot;&amp;gt;&amp;#039; .. value .. &amp;#039;&amp;lt;/span&amp;gt;&amp;lt;/strong&amp;gt;&amp;#039;&lt;br /&gt;
    return output_cat(error_str, &amp;#039;Errors reported by Module Ordinal&amp;#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to add append a category to a message.&lt;br /&gt;
]]&lt;br /&gt;
function output_cat( message, category )&lt;br /&gt;
    return message .. &amp;#039;[[Category:&amp;#039; .. category .. &amp;#039;]]&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>