This module will transliterate text in the Hebrew script.
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:Hebr-Arab-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 gsub = mw.ustring.gsub
local match = mw.ustring.match
local letters = "קראטוןםפףךלחיעכגדשזסבהנמצתץ"
local dagesh = "ּ"
local diacritics = "ְֱֲֲֳִֵֶַָָֻּ"
local tt = {
='ب', ='ج',='د',='ذ',='ه',='و',='ز', ='ح',='ط',='ي',
='ك', -- intital form
='ك', -- intial form
='ك', -- final form, with dagesh = strong k sound
='ك', -- final form
='ل',='م',='م',='ن',='ن',
='س', -- no direct equivalent
='ع',='ف',='ف',='ص',='ص',='ق',='ر',='ش',='س',='ش',
='ث',
='أ',
='َ',-- Patach/fatah
='ِ', -- Hiriq/Damma
='ٰ', -- Qamatz/Khanjariyah
='ْ',-- Shva/Sukun
='و'-- Holam
}
function export.tr(text, lang, sc)
-- fixes the double diacritic issues
text = gsub(text, "פ" .. '()' .. dagesh, "ف%1")
text = mw.ustring.gsub(text, '()()', "%2%1")
text = mw.ustring.gsub(text, '.', tt)
--
text = gsub(text, "תּ","ت")
text = gsub(text, "וֹ","و")
text = gsub(text, "וּ","ُو")
text = mw.ustring.gsub(text, '.', tt)
return text
end
return export