Module:shi-Latn-Arab-translit: Difference between revisions
Jump to navigation
Jump to search
m Protected "Module:shi-Latn-Arab-translit": Highly visible template/module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) |
m 1 revision imported |
||
(No difference)
| |||
Latest revision as of 12:46, 21 April 2026
Documentation for this module may be created at Module:shi-Latn-Arab-translit/doc
local export = {}
local tt = {
["b"] = "ب",
["g"] = "ڭ",
["d"] = "د",
["ḍ"] = "ض",
["f"] = "ف",
["k"] = "ك",
["h"] = "ه",
["ḥ"] = "ح",
["ɛ"] = "ع",
["x"] = "خ",
["q"] = "ق",
["j"] = "ج",
["l"] = "ل",
["m"] = "م",
["n"] = "ن",
["p"] = "پ",
["r"] = "ر",
["ṛ"] = "ر",
["ɣ"] = "غ",
["s"] = "س",
["ṣ"] = "ص",
["t"] = "ت",
["c"] = "ش",
["ṭ"] = "ط",
["v"] = "ڤ",
["w"] = "و",
["y"] = "ي",
["z"] = "ز",
["ẓ"] = "ژ",
["ʷ"] = "ُ",
["e"] = "",
}
function export.tr(text, lang, sc)
if not sc then
sc = require("Module:languages"):getByCode("shi"):findBestScript(text):getCode()
end
if sc == "Latn" then
text = mw.ustring.lower(text)
local words = mw.text.split(text, '%s+')
local result_words = {}
for _, word in ipairs(words) do
local word = mw.ustring.gsub(word, "([^aiu])%1", "%1ّ")
word = mw.ustring.gsub(word, '.', tt)
word = mw.ustring.gsub(word, "^a", "آ")
word = mw.ustring.gsub(word, "^u", "او")
word = mw.ustring.gsub(word, "^i", "اي")
word = mw.ustring.gsub(word, "a", "ا")
word = mw.ustring.gsub(word, "u", "و")
word = mw.ustring.gsub(word, "i", "ي")
table.insert(result_words, word)
end
text = table.concat(result_words, ' ')
else
text = nil
end
return text
end
return export