Module:Armn-translit: Difference between revisions
Jump to navigation
Jump to search
Created page with "local export = {} local gsub = require("Module:string utilities").gsub local mapping = { ["ա"]="a", ["բ"]="b", ["գ"]="g", ["դ"]="d", ["ե"]="e", ["զ"]="z",["է"]="ē", ["ը"]="ə", ["թ"]="tʻ", ["ժ"]="ž", ["ի"]="i", ["լ"]="l", ["խ"]="x", ["ծ"]="c", ["կ"]="k", ["հ"]="h", ["ձ"]="j", ["ղ"]="ġ", ["ճ"]="č", ["մ"]="m", ["յ"]="y", ["ն"]="n", ["շ"]="š", ["ո"]="o", ["չ"]="čʻ", ["պ"]="p", ["ջ"]="ǰ", ["ռ"]="ṙ", ["ս"]="s", ["վ"]="v", ["տ"]="..." |
fix mn ligature translit |
||
| Line 12: | Line 12: | ||
["Ձ"]="J", ["Ղ"]="Ġ", ["Ճ"]="Č", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Š", ["Ո"]="O", | ["Ձ"]="J", ["Ղ"]="Ġ", ["Ճ"]="Č", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Š", ["Ո"]="O", | ||
["Չ"]="Čʻ", ["Պ"]="P", ["Ջ"]="J̌", ["Ռ"]="Ṙ", ["Ս"]="S", ["Վ"]="V", ["Տ"]="T", ["Ր"]="R", | ["Չ"]="Čʻ", ["Պ"]="P", ["Ջ"]="J̌", ["Ռ"]="Ṙ", ["Ս"]="S", ["Վ"]="V", ["Տ"]="T", ["Ր"]="R", | ||
["Ց"]="Cʻ", ["Ւ"]="W", ["Փ"]="Pʻ", ["Ք"]="Kʻ", ["Օ"]="Ō", ["Ֆ"]="F", [" | ["Ց"]="Cʻ", ["Ւ"]="W", ["Փ"]="Pʻ", ["Ք"]="Kʻ", ["Օ"]="Ō", ["Ֆ"]="F", ["ﬓ"]="mn", ["ﬔ"]="me", | ||
["ﬕ"]="mi", ["ﬖ"]="vn", ["ﬗ"]="mx", ["ՠ"]="ä", ["ֈ"]="hª", | ["ﬕ"]="mi", ["ﬖ"]="vn", ["ﬗ"]="mx", ["ՠ"]="ä", ["ֈ"]="hª", | ||
-- punctuation | |||
["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>", | ["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>", | ||
["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʻ' | ["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʻ' | ||
| Line 20: | Line 20: | ||
local replacements = { | local replacements = { | ||
-- desirable, but doesn't work: ['<sup>յ</sup>'] = 'ʸ', | |||
['յ̵'] = ' | ['յ̵'] = mapping['ֈ'], | ||
['ղʻ'] = 'q', | ['ղʻ'] = 'q', | ||
['Ո[ւՒ]'] = 'U', | ['Ո[ւՒ]'] = 'U', | ||
| Line 38: | Line 38: | ||
function export.tr(text, lang, sc) | function export.tr(text, lang, sc) | ||
if | if type(lang) == "table" then | ||
lang = lang:getFullCode() | |||
end | end | ||
Revision as of 23:12, 30 March 2026
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Armenian script. It is used to transliterate Udi.
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:Armn-translit/testcases.
Functions
tr(text, lang, sc)- Transliterates a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the transliteration fails, returns
nil.
local export = {}
local gsub = require("Module:string utilities").gsub
local mapping = {
["ա"]="a", ["բ"]="b", ["գ"]="g", ["դ"]="d", ["ե"]="e", ["զ"]="z",["է"]="ē", ["ը"]="ə",
["թ"]="tʻ", ["ժ"]="ž", ["ի"]="i", ["լ"]="l", ["խ"]="x", ["ծ"]="c", ["կ"]="k", ["հ"]="h",
["ձ"]="j", ["ղ"]="ġ", ["ճ"]="č", ["մ"]="m", ["յ"]="y", ["ն"]="n", ["շ"]="š", ["ո"]="o",
["չ"]="čʻ", ["պ"]="p", ["ջ"]="ǰ", ["ռ"]="ṙ", ["ս"]="s", ["վ"]="v", ["տ"]="t", ["ր"]="r",
["ց"]="cʻ", ["ւ"]="w", ["փ"]="pʻ", ["ք"]="kʻ", ["և"]="ew", ["օ"]="ō", ["ֆ"]="f",
["Ա"]="A", ["Բ"]="B", ["Գ"]="G", ["Դ"]="D", ["Ե"]="E", ["Զ"]="Z", ["Է"]="Ē", ["Ը"]="Ə",
["Թ"]="Tʻ", ["Ժ"]="Ž", ["Ի"]="I", ["Լ"]="L", ["Խ"]="X", ["Ծ"]="C", ["Կ"]="K", ["Հ"]="H",
["Ձ"]="J", ["Ղ"]="Ġ", ["Ճ"]="Č", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Š", ["Ո"]="O",
["Չ"]="Čʻ", ["Պ"]="P", ["Ջ"]="J̌", ["Ռ"]="Ṙ", ["Ս"]="S", ["Վ"]="V", ["Տ"]="T", ["Ր"]="R",
["Ց"]="Cʻ", ["Ւ"]="W", ["Փ"]="Pʻ", ["Ք"]="Kʻ", ["Օ"]="Ō", ["Ֆ"]="F", ["ﬓ"]="mn", ["ﬔ"]="me",
["ﬕ"]="mi", ["ﬖ"]="vn", ["ﬗ"]="mx", ["ՠ"]="ä", ["ֈ"]="hª",
-- punctuation
["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>",
["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʻ'
}
local replacements = {
-- desirable, but doesn't work: ['<sup>յ</sup>'] = 'ʸ',
['յ̵'] = mapping['ֈ'],
['ղʻ'] = 'q',
['Ո[ւՒ]'] = 'U',
['ու'] = 'u',
['Ո՛[ւՒ]'] = 'Ú',
['ո՛ւ'] = 'ú',
['Ո՜[ւՒ]'] = 'U<sup>!</sup>',
['ո՜ւ'] = 'u<sup>!</sup>',
['Ո՞[ւՒ]'] = 'U<sup>?</sup>',
['ո՞ւ'] = 'u<sup>?</sup>',
['ո̈ւ'] = 'ü',
['Ո̈[ւՒ]'] = 'Ü',
['օ̈'] = 'ö',
['Օ̈'] = 'Ö',
}
function export.tr(text, lang, sc)
if type(lang) == "table" then
lang = lang:getFullCode()
end
if lang == "xcl" then
mapping["ղ"]="ł"
mapping["Ղ"]="Ł"
end
for regex, replacement in pairs(replacements) do
text = gsub(text, regex, replacement)
end
text = gsub(text, '.', mapping)
return text
end
return export