Module:ota-Armn-translit
Appearance
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Ottoman Turkish language text per WT:OTA 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:ota-Armn-translit/testcases.
Functions
[edit]tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
-- Used to transliterate the [[w:Armeno-Turkish alphabet]]
local gsub = require("Module:string utilities").gsub
local mapping = {
["ա"]="a", ["գ"]="k", ["ե"]="y", ["զ"]="z", ["է"]="e", ["ը"]="ı",
["թ"]="t", ["ժ"]="j", ["ի"]="i", ["լ"]="l", ["խ"]="h", ["կ"]="g", ["հ"]="h",
["ղ"]="ğ", ["ճ"]="c", ["մ"]="m", ["յ"]="y", ["ն"]="n", ["շ"]="ş",
["չ"]="ç", ["պ"]="b", ["ս"]="s", ["վ"]="v", ["տ"]="d", ["ր"]="r",
["փ"]="p", ["ք"]="k", ["և"]="ew", ["օ"]="o", ["ֆ"]="f",
["Ա"]="A", ["Գ"]="K", ["Ե"]="Y", ["Զ"]="Z", ["Է"]="E", ["Ը"]="I",
["Թ"]="T", ["Ժ"]="J", ["Ի"]="İ", ["Լ"]="L", ["Խ"]="H", ["Կ"]="G", ["Հ"]="H",
["Ղ"]="Ğ", ["Ճ"]="C", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Ş",
["Չ"]="Ç", ["Պ"]="B", ["Ս"]="S", ["Վ"]="V", ["Տ"]="D", ["Ր"]="R",
["Փ"]="P", ["Ք"]="K", ["Օ"]="O", ["Ֆ"]="F",
-- turning RIGHT SINGLE QUOTATION MARK (U+2019) into MODIFIER LETTER APOSTROPHE (U+02BC)
-- the encoding ARMENIAN APOSTROPHE (U+055A) is dispreferred by the Unicode standard
["’"]="ʼ",
-- not used in Turkish words
["բ"]="p", ["դ"]="t", ["ծ"]="dz", ["ձ"]="ts", ["ջ"]="ç", ["ռ"]="r", ["ց"]="ts",
["Բ"]="P", ["Դ"]="T", ["Ծ"]="Dz", ["Ձ"]="Ts", ["Ջ"]="Ç", ["Ռ"]="R", ["Ց"]="Ts",
-- punctuation
["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>",
["՟"]=".", ["֊"]="-", ['«']='“', ['»']='”',
}
local replacements = {
['([ՔԿ])ԵԱ'] = '%1Â',
['([ՔքԿկ])եա'] = '%1â', -- լեա is lya
['Ո[ւՒ]'] = 'U',
['ու'] = 'u',
['Ի[ւՒ]'] = 'Ü',
['իւ'] = 'ü',
['Է[օՕ]'] = 'Ö',
['էօ'] = 'ö',
['Ո՛[ւՒ]'] = 'Ú',
['ո՛ւ'] = 'ú',
['Ո՜[ւՒ]'] = 'U<sup>!</sup>',
['ո՜ւ'] = 'u<sup>!</sup>',
['Ո՞[ւՒ]'] = 'U<sup>?</sup>',
['ո՞ւ'] = 'u<sup>?</sup>',
-- ['Ն[ԿՂ]'] = 'Ñ', these cannot be handled automatically
-- ['ն[կղ]'] = 'ñ', these cannot be handled automatically
}
function export.tr(text, lang, sc)
if sc and sc ~= "Armn" then
return nil
end
for regex, replacement in pairs(replacements) do
text = gsub(text, regex, replacement)
end
text = gsub(text, '.', mapping)
return text
end
return export