Contains a function that links long lists of Arabic words, such as Appendix:Arabic Frequency List from Quran/Arabic Frequency List from Quran 1-1000 and Appendix:Arabic Quranic Verbs/Arabic Quranic Verbs 1-500.
local export = {}
local U = require("Module:string/char")
-- Derived from Arabic data table in ].
local entry_name_replacements = {
= U(0x0627), = "", = "", = "",
= "", = "", = "", = "",
= "", = "", = "",
}
local function make_entry_name(text)
return (text:gsub("*", entry_name_replacements))
end
local function link(entry, text)
return '<span class="Arab" lang="ar">[['
.. make_entry_name(entry)
.. '#Arabic|' .. (text or entry) .. ']]</span>‎'
end
function export.link(frame)
local text = frame.args
if not text then
return nil
end
local transliterate = require("Module:memoize")(require "Module:ar-translit".tr)
local open_paren = ' <span class="mention-gloss-paren annotation-paren">(</span><span class="tr Latn" xml:lang="ar-Latn" lang="ar-Latn">'
local close_paren = '</span><span class="mention-gloss-paren annotation-paren">)</span>'
return (text
:gsub(
"%]+)%]%]",
function (link_text)
local entry, text = link_text:match("^(+)|(.+)$")
entry, text = entry or link_text, text or link_text
local translit = transliterate(text)
if translit then
return link(entry, text)
.. open_paren .. translit .. close_paren
else
return link(link_text)
end
end))
end
return export