<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASortName</id>
	<title>Module:SortName - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASortName"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:SortName&amp;action=history"/>
	<updated>2026-04-18T05:55:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:SortName&amp;diff=479501&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:SortName&amp;diff=479501&amp;oldid=prev"/>
		<updated>2021-07-16T06:05:00Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.sortname(frame)&lt;br /&gt;
    local currentpage = mw.title.getCurrentTitle()&lt;br /&gt;
    local pagetitle = frame.args[1] or currentpage.text&lt;br /&gt;
    local langvar = mw.language.getContentLanguage()&lt;br /&gt;
    local text1 = ''&lt;br /&gt;
    local text2 = ''&lt;br /&gt;
    local parts = { 'de','De','von','Von','du','Du','del','Del','zu','Zu','di','Di','van','Van','na','Na','le','Le','de\'','De\'' }&lt;br /&gt;
    local partmatch = false&lt;br /&gt;
    if string.find( pagetitle, ' ' ) ~= nil then&lt;br /&gt;
        pagetitle = string.gsub( string.gsub( string.gsub( pagetitle, '%b()', '' ), ' +', ' '), ' $', '' )&lt;br /&gt;
        if string.find( pagetitle, '^List of ' ) ~= nil then&lt;br /&gt;
            pagetitle = langvar:ucfirst( string.gsub( pagetitle, '^List of ', '', 1 ) )&lt;br /&gt;
        elseif string.find( pagetitle, '^The ' ) ~= nil then&lt;br /&gt;
            pagetitle = string.gsub( pagetitle, '^The ', '' ) .. ', The'&lt;br /&gt;
        else&lt;br /&gt;
            pagetitle = string.gsub( pagetitle, ',.*$', '' )&lt;br /&gt;
            pagetitle = string.gsub( pagetitle, ' of .*$', '' )&lt;br /&gt;
            for i in ipairs( parts ) do&lt;br /&gt;
                if string.find( pagetitle, ' ' .. parts[i] .. ' ' ) ~= nil then&lt;br /&gt;
                    text1 = string.sub( pagetitle, string.find( pagetitle, ' ' .. parts[i] .. ' ' ) + 1, #pagetitle )&lt;br /&gt;
                    text2 = string.sub( pagetitle, 0, string.find( pagetitle, ' ' .. parts[i] .. ' ' ) - 1 )&lt;br /&gt;
                    pagetitle = text1 .. ', ' .. text2&lt;br /&gt;
                    partmatch = true&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
            if not partmatch and string.find( pagetitle, ' ' ) ~= nil then&lt;br /&gt;
                text1 = string.sub( pagetitle, string.find( pagetitle, ' [^ ]*$' ) + 1, #pagetitle )&lt;br /&gt;
                text2 = string.sub( pagetitle, 0, string.find( pagetitle, ' [^ ]*$' ) - 1 )&lt;br /&gt;
                local romannumeral = roman_to_numeral(text1)&lt;br /&gt;
                if romannumeral == -1 then&lt;br /&gt;
                    pagetitle = text1 .. ', ' .. text2&lt;br /&gt;
                else&lt;br /&gt;
                    if string.find( text2, ' ' ) == nil then&lt;br /&gt;
                        pagetitle = text2 .. ' ' .. romannumeral&lt;br /&gt;
                    else&lt;br /&gt;
                        text1 = string.sub( text2, string.find( text2, ' [^ ]*$' ) + 1, #text2 )&lt;br /&gt;
                        text2 = string.sub( text2, 0, string.find( text2, ' [^ ]*$' ) - 1 )&lt;br /&gt;
                        pagetitle = text1 .. ' ' .. romannumeral .. ', ' .. text2&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return pagetitle&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- the following table and roman_to_numeral function came from Module:ConvertNumeric, created by User:Dcoetzee&lt;br /&gt;
roman_numerals = {&lt;br /&gt;
    I = 1,&lt;br /&gt;
    V = 5,&lt;br /&gt;
    X = 10,&lt;br /&gt;
    L = 50,&lt;br /&gt;
    C = 100,&lt;br /&gt;
    D = 500,&lt;br /&gt;
    M = 1000&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
-- Converts a given valid roman numeral (and some invalid roman numerals) to a number. Returns -1, errorstring on error&lt;br /&gt;
function roman_to_numeral(roman)&lt;br /&gt;
    if type(roman) ~= &amp;quot;string&amp;quot; then return -1, &amp;quot;roman numeral not a string&amp;quot; end&lt;br /&gt;
    local rev = roman:reverse()&lt;br /&gt;
    local raising = true&lt;br /&gt;
    local last = 0&lt;br /&gt;
    local result = 0&lt;br /&gt;
    for i = 1, #rev do&lt;br /&gt;
        local c = rev:sub(i, i)&lt;br /&gt;
        local next = roman_numerals[c]&lt;br /&gt;
        if next == nil then return -1, &amp;quot;roman numeral contains illegal character &amp;quot; .. c end&lt;br /&gt;
        if next &amp;gt; last then&lt;br /&gt;
            result = result + next&lt;br /&gt;
            raising = true&lt;br /&gt;
        elseif next &amp;lt; last then&lt;br /&gt;
            result = result - next&lt;br /&gt;
            raising = false&lt;br /&gt;
        elseif raising then&lt;br /&gt;
            result = result + next&lt;br /&gt;
        else&lt;br /&gt;
            result = result - next&lt;br /&gt;
        end&lt;br /&gt;
        last = next&lt;br /&gt;
    end&lt;br /&gt;
    return result&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>