Modul:egy-utilities
Penampilan
- Laman modul ini kekurangan sublaman pendokumenan. Sila cipta laman pendokumenan tersebut.
- Pautan berguna: senarai sublaman • pautan • transklusi • kes ujian • kotak pasir
local export = {}
local sortkey_replacements = mw.loadData "Module:egy-utilities/data"
-- Replace Egyptian letters with a series of arbitrary codepoints that happen to
-- be in the right sequence.
function export.makeSortKey(text, lang, sc)
text= mw.ustring.lower(text)
text = mw.ustring.gsub(text, "[%-%s]", "")
return mw.ustring.upper(mw.ustring.gsub(text, ".", sortkey_replacements))
end
function export.show_sort_order(frame)
local output = {}
for i, word in ipairs(frame.args) do
output[i] = word
end
local function link(word)
return '<span class="Latn" lang="egy">[[' .. word .. '#Bahasa Mesir|' .. word .. ']]</span>'
end
local make_sortkey = require("Module:memoize")(export.makeSortKey)
table.sort(
output,
function(word1, word2)
return make_sortkey(word1) < make_sortkey(word2)
end)
return table.concat(
require("Module:fun").map(
function(word)
return "* " .. link(word) .. " (<code>" .. make_sortkey(word) .. "</code>)"
end,
output),
"\n")
end
function export.hieroforms(frame)
local parent_args = frame:getParent().args
local default_title = parent_args['head'] or mw.title.getCurrentTitle().text
default_title = 'Tulisan hieroglif alternatif '
.. require 'Module:script utilities'.tag_text(
default_title, require 'Module:languages'.getByCode 'egy', nil, 'term', nil)
local tabletitle = parent_args['title'] or default_title
local text = '<div class="NavFrame" style="clear:both;display:inline-block;">\n<div class="NavHead" style="">' .. tabletitle .. ' </div>\n<div class="NavContent">\n{| style="text-align:center;"'
local i = 1
while parent_args[i] do
local new_frame = frame:newChild{title = frame:getTitle(), args = {[1] = parent_args[i]}}
local hiero = require 'Module:egy-hieroglyphs'.parameter_to_hiero(new_frame)
text = text .. '\n| style="background-color:var(--wikt-palette-lightergrey,#eeeeee)"|<span style="margin:0px 6px;">' .. hiero .. '</span>'
i = i + 1
end
local j = 1
local no_read = true
local since_last = 1
local read = 'read1'
while j < i do
if parent_args[read] then
if no_read then
text = text .. '\n|-'
no_read = false
end
while since_last > 0 do
text = text .. '\n|'
since_last = since_last - 1
end
local link = require 'Module:links'.full_link( {
lang = require 'Module:languages'.getByCode 'egy', term = parent_args[read]
}, 'term' )
text = text .. 'style="background-color:var(--wikt-palette-lightergrey,#eeeeee)"|' .. link
end
since_last = since_last + 1
j = j + 1
read = 'read' .. j
end
j = 1
local no_date = true
since_last = 1
local date = 'date1'
while j < i do
if parent_args[date] then
if no_date then
text = text .. '\n|-'
no_date = false
end
while since_last > 0 do
text = text .. '\n|'
since_last = since_last - 1
end
text = text .. 'style="background-color:var(--wikt-palette-lightergrey,#eeeeee)"|' .. frame:expandTemplate{title = 'defdate', args = {parent_args[date]}}
end
since_last = since_last + 1
j = j + 1
date = 'date' .. j
end
j = 1
local no_note = true
since_last = 1
local note = 'note1'
while j < i do
if parent_args[note] then
if no_note then
text = text .. '\n|- style="font-size:70%"'
no_note = false
end
while since_last > 0 do
text = text .. '\n|'
since_last = since_last - 1
end
text = text .. 'style="background-color:#efefef"|' .. parent_args[note]
end
since_last = since_last + 1
j = j + 1
note = 'note' .. j
end
text = text .. '\n|}</div></div>'
return text
end
return export