This module will transliterate Northern Kurdish language text.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}
.
Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:kmr-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local tt = {
="a", ="b", ="c", ="ç", ="d", ="e",
="ê", ="ê", ="f", ="g", ="h", ="i",
="î", ="j", ="k", ="l", ="m", ="n",
="o", ="p", ="q", ="r", ="s", ="ş",
="t", ="u", ="û", ="v", ="w", ="x",
="y", ="z",
="A", ="B", ="C", ="Ç", ="D", ="E",
="Ê", ="Ê", ="F", ="G", ="H", ="I",
="Î", ="J", ="K", ="L", ="M", ="N",
="O", ="P", ="Q", ="R", ="S", ="Ş",
="T", ="U", ="Û", ="V", ="W", ="X",
="Y", ="Z",
= "ẍ", = "Ẍ", = "ḧ", = "Ḧ",
};
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, '’', tt)
text = mw.ustring.gsub(text, '.', tt)
text = mw.ustring.gsub(text, '^()’', "%1") -- р’ож: roj
text = mw.ustring.gsub(text, '()’', "%1%1") -- пьр’: pirr
local consonants = "bcçdfghḧjklmnpqrsştvwxẍzBCÇDFGHḦJKLMNPQRSŞTVWXẌZ"
local vowels = "aeêiîouûAEÊIÎOUÛ"
-- handle ә’
text = mw.ustring.gsub(text, '()()’',
function (pos, e)
if pos == 1 then -- ә’ at beginning of string
local after1, after2 = mw.ustring.match(text, "^(.?)(.?)", pos + 2)
if consonants:find(after1)
and (after2 == '' -- followed by single consonant: ә’к → 'ek
or consonants:find(after2)) then -- followed by two consonants: ә’скәр → 'esker
return "'" .. e
end
else
local before = mw.ustring.sub(text, pos - 1, pos - 1)
if vowels:find(before) then -- preceded by vowel: щьмаә’т → cima'et
return "'" .. e
end
end
return e .. "'"
end)
return text
end
return export