This module will transliterate Yiddish language text per WT:YI TR.
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:yi-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 = {
= "q",
= "o",
= "a",
= "b",
= "b",
= "v",
= "g",
= "g",
= "g",
= "d",
= "d",
= "d",
= "H",
= "w",
= "u",
= "v",
= "v",
= "oy",
= "oy",
= "z",
= "kh",
= "t",
= "y",
= "i",
= "i",
= "ey",
= "ey",
= "ay",
= "ay",
= "ay",
= "k",
= "kh",
= "kh",
= "k",
= "kh",
= "kh",
= "l",
= "m",
= "m",
= "n",
= "n",
= "s",
= "e",
= "p",
= "F",
= "f",
= "p",
= "f",
= "f",
= "ts",
= "ts",
= "k",
= "r",
= "sh",
= "sh",
= "s",
= "t",
= "s",
= "s",
= "-",
= "'",
= "\"",
}
-- in precedence order
local tokens = {
"ייַ",
"אָ",
"אַ",
"בּ",
"בֿ",
"גּ",
"גֿ",
"דּ",
"דֿ",
"וּ",
"וו",
"יִ",
"יִ",
"יי",
"ײַ",
"וי",
"כּ",
"כֿ",
"ךּ",
"ךֿ",
"פּ",
"פֿ",
"ףּ",
"ףֿ",
"שׁ",
"שׂ",
"תּ",
"תֿ",
"א",
"ב",
"ג",
"ד",
"ה",
"ו",
"ױ",
"װ",
"ז",
"ח",
"ט",
"י",
"ײ",
"ײַ",
"כ",
"ך",
"ל",
"מ",
"ם",
"נ",
"ן",
"ס",
"ע",
"פ",
"ף",
"צ",
"ץ",
"ק",
"ר",
"ש",
"ת",
"־",
"׳",
"״",
}
local hebrew_only_tokens = {
"בֿ",
"ח",
"כּ",
"שׂ",
"ת",
}
function export.tr(text, lang, sc)
local hebrew_only = false
for _, token in ipairs(hebrew_only_tokens) do
if string.find(text, token) ~= nil then
hebrew_only = true
break
end
end
for _, token in ipairs(tokens) do
text = string.gsub(text, token, tt)
end
local suffix = text ~= '-' and string.sub(text, 1, 1) == '-'
local prefix = text ~= '-' and string.sub(text, -1, -1) == '-'
if suffix then
text = string.gsub(text, "^-", "-q")
end
if prefix then
text = string.gsub(text, "-$", "q-")
end
text = string.gsub(text, "()y$", "%1i")
text = string.gsub(text, "()y()", "%1i%2")
text = string.gsub(text, "()y()", "%1i%2") -- repeated to handle overlapping cases
text = string.gsub(text, "()w", "%1u")
hebrew_only = hebrew_only or (string.find(text, "w") ~= nil)
text = string.gsub(text, "w", "v")
hebrew_only = hebrew_only or (string.find(text, "F") ~= nil)
text = string.gsub(text, "F$", "p")
text = string.gsub(text, "F()", "p%1")
text = string.gsub(text, "F", "f")
text = string.gsub(text, "zsh", "zh")
if suffix then
text = string.gsub(text, "^%-q", "-")
end
if prefix then
text = string.gsub(text, "q%-$", "-")
end
text = string.gsub(text, "q(y)", "%1")
text = string.gsub(text, "q()", "%1")
hebrew_only = hebrew_only or (string.find(text, "q") ~= nil)
text = string.gsub(text, "q", "a")
-- hebrew_only = hebrew_only or (string.find(text, "H") ~= nil) or (string.find(text, "H$") ~= nil)
text = string.gsub(text, "H", "h")
local categories = nil
if hebrew_only then
categories = {"Requests for transliteration of Yiddish terms with Hebrew-only letters"}
end
return text, nil, categories
end
return export