Module:sish-translit: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
local tt = {} | local tt = {} | ||
tt["Armn"] = { | tt["Armn"] = { | ||
[" | ["Ա"]='A', ["ա"]='a', | ||
[" | ["Բ"]='B', ["բ"]='b', | ||
[" | ["Վ"]='V', ["վ"]='v', | ||
[" | ["Գ"]='G', ["գ"]='g', | ||
[ | ["Դ"]='D', ["ֆ"]='d', | ||
[" | ["Ե"]='E', ["ե"]='e', | ||
[" | ["Է"]='Ē', ["է"]='ē', | ||
["Ժ"]='Ž', ["ժ"]='ž', | |||
[" | ["Զ"]='Z', ["զ"]='z', | ||
[" | ["Ի"]='I', ["ի"]='i', | ||
[" | ["Ձ"]='J', ["ձ"]='j', | ||
["Կ"]='K', ["կ"]='k', | |||
[" | ["Լ"]='L', ["լ"]='l', | ||
[" | ["Մ"]='M', ["մ"]='m', | ||
["Ն"]='N', ["ն"]='n', | |||
['Ո']='O', ['ո']='o', | |||
['Օ']='Ō', ['օ']='ō', | |||
["Պ"]='P', ["պ"]='p', | |||
["Ր"]='R', ["ր"]='r', | |||
["Ս"]='S', ["ս"]='s', | |||
["Տ"]='T', ["տ"]='t', | |||
["Ու"]='U', ["ու"]='u', | |||
["Ֆ"]='F', ["ֆ"]='f', | |||
["Հ"]='H', ["հ"]='h', | |||
["Ծ"]='C', ["ծ"]='c', | |||
["Ճ"]='Č', ["ճ"]='č', | |||
["Ջ"]='J̌', ["ջ"]='ǰ', | |||
["Շ"]='Š', ["շ"]='š', | |||
["Յ"]="Y", ["յ"]="y", | |||
["Խ"]="X", ["խ"]="x", | |||
["Ղ"]="Ġ", ["ղ"]="ġ", | |||
["Ը"]="Ə", ["ը"]="ə", | |||
["Ռ"]="Ṙ", ["ռ"]="ṙ", | |||
["Փ"]="Pʻ", ["փ"]="pʻ", | |||
["Թ"]="Tʻ", ["թ"]="tʻ", | |||
["Ք"]="Kʻ", ["ք"]="kʻ", | |||
["Ց"]="Cʻ", ["ց"]="cʻ", | |||
["Չ"]="Čʻ", ["չ"]="čʻ", | |||
}; | }; | ||
tt[" | tt["Latn"] = { | ||
[" | --Digraphs | ||
[" | ["U"]='Ու', ["u"]='ու', | ||
[" | |||
[" | ["A"]='Ա', ["a"]='ա', | ||
[" | ["B"]='Բ', ["b"]='բ', | ||
["V"]='Վ', ["v"]='վ', | |||
["G"]='Գ', ["g"]='գ', | |||
["D"]='Դ', ["d"]='դ', | |||
["E"]='Ե', ["e"]='ե', | |||
["Ē"]='Է', ["ē"]='է', | |||
["Ž"]='Ժ', ["ž"]='ժ', | |||
["Z"]='Զ', ["z"]='զ', | |||
["I"]='Ի', ["i"]='ի', | |||
["J"]='Ձ', ["j"]='ձ', | |||
["K"]='Կ', ["k"]='կ', | |||
["L"]='Լ', ["l"]='լ', | |||
["M"]='Մ', ["m"]='մ', | |||
["N"]='Ն', ["n"]='ն', | |||
['O']='Ո', ['o']='ո', | |||
['Ō']='Օ', ['ō']='օ', | |||
["P"]='Պ', ["p"]='պ', | |||
["R"]='Ր', ["r"]='ր', | |||
["S"]='Ս', ["s"]='ս', | |||
["T"]='Տ', ["t"]='տ', | |||
["F"]='Ֆ', ["f"]='ֆ', | |||
["H"]='Հ', ["h"]='հ', | |||
["C"]='Ծ', ["c"]='ծ', | |||
["Č"]='Ճ', ["č"]='ճ', | |||
["J̌"]='Ջ', ["ǰ"]='ջ', | |||
["Š"]='Շ', ["š"]='շ', | |||
["Y"]="Յ", ["y"]="յ", | |||
["X"]="Խ", ["x"]="խ", | |||
["Ġ"]="Ղ", ["ġ"]="ղ", | |||
["Ə"]="Ը", ["ə"]="ը", | |||
["Ṙ"]="Ռ", ["ṙ"]="ռ", | |||
["Pʻ"]="Փ", ["pʻ"]="փ", | |||
["Tʻ"]="Թ", ["tʻ"]="թ", | |||
["Kʻ"]="Ք", ["kʻ"]="ք", | |||
["Cʻ"]="Ց", ["cʻ"]="ց", | |||
["Čʻ"]="Չ", ["čʻ"]="չ", | |||
}; | }; | ||
function export.tr(text, lang, sc) | function export.tr(text, lang, sc) | ||
if (sc == "Latn") then | |||
text = mw.ustring.gsub(text, '[dDnNlL][jž]', tt[sc]) | |||
end | |||
return mw.ustring.toNFC(mw.ustring.gsub(text, '.', tt[sc])) | return mw.ustring.toNFC(mw.ustring.gsub(text, '.', tt[sc])) | ||
end | end | ||
return export | return export | ||
Revision as of 05:36, 12 June 2026
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Ossamic 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:sish-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 tt = {}
tt["Armn"] = {
["Ա"]='A', ["ա"]='a',
["Բ"]='B', ["բ"]='b',
["Վ"]='V', ["վ"]='v',
["Գ"]='G', ["գ"]='g',
["Դ"]='D', ["ֆ"]='d',
["Ե"]='E', ["ե"]='e',
["Է"]='Ē', ["է"]='ē',
["Ժ"]='Ž', ["ժ"]='ž',
["Զ"]='Z', ["զ"]='z',
["Ի"]='I', ["ի"]='i',
["Ձ"]='J', ["ձ"]='j',
["Կ"]='K', ["կ"]='k',
["Լ"]='L', ["լ"]='l',
["Մ"]='M', ["մ"]='m',
["Ն"]='N', ["ն"]='n',
['Ո']='O', ['ո']='o',
['Օ']='Ō', ['օ']='ō',
["Պ"]='P', ["պ"]='p',
["Ր"]='R', ["ր"]='r',
["Ս"]='S', ["ս"]='s',
["Տ"]='T', ["տ"]='t',
["Ու"]='U', ["ու"]='u',
["Ֆ"]='F', ["ֆ"]='f',
["Հ"]='H', ["հ"]='h',
["Ծ"]='C', ["ծ"]='c',
["Ճ"]='Č', ["ճ"]='č',
["Ջ"]='J̌', ["ջ"]='ǰ',
["Շ"]='Š', ["շ"]='š',
["Յ"]="Y", ["յ"]="y",
["Խ"]="X", ["խ"]="x",
["Ղ"]="Ġ", ["ղ"]="ġ",
["Ը"]="Ə", ["ը"]="ə",
["Ռ"]="Ṙ", ["ռ"]="ṙ",
["Փ"]="Pʻ", ["փ"]="pʻ",
["Թ"]="Tʻ", ["թ"]="tʻ",
["Ք"]="Kʻ", ["ք"]="kʻ",
["Ց"]="Cʻ", ["ց"]="cʻ",
["Չ"]="Čʻ", ["չ"]="čʻ",
};
tt["Latn"] = {
--Digraphs
["U"]='Ու', ["u"]='ու',
["A"]='Ա', ["a"]='ա',
["B"]='Բ', ["b"]='բ',
["V"]='Վ', ["v"]='վ',
["G"]='Գ', ["g"]='գ',
["D"]='Դ', ["d"]='դ',
["E"]='Ե', ["e"]='ե',
["Ē"]='Է', ["ē"]='է',
["Ž"]='Ժ', ["ž"]='ժ',
["Z"]='Զ', ["z"]='զ',
["I"]='Ի', ["i"]='ի',
["J"]='Ձ', ["j"]='ձ',
["K"]='Կ', ["k"]='կ',
["L"]='Լ', ["l"]='լ',
["M"]='Մ', ["m"]='մ',
["N"]='Ն', ["n"]='ն',
['O']='Ո', ['o']='ո',
['Ō']='Օ', ['ō']='օ',
["P"]='Պ', ["p"]='պ',
["R"]='Ր', ["r"]='ր',
["S"]='Ս', ["s"]='ս',
["T"]='Տ', ["t"]='տ',
["F"]='Ֆ', ["f"]='ֆ',
["H"]='Հ', ["h"]='հ',
["C"]='Ծ', ["c"]='ծ',
["Č"]='Ճ', ["č"]='ճ',
["J̌"]='Ջ', ["ǰ"]='ջ',
["Š"]='Շ', ["š"]='շ',
["Y"]="Յ", ["y"]="յ",
["X"]="Խ", ["x"]="խ",
["Ġ"]="Ղ", ["ġ"]="ղ",
["Ə"]="Ը", ["ə"]="ը",
["Ṙ"]="Ռ", ["ṙ"]="ռ",
["Pʻ"]="Փ", ["pʻ"]="փ",
["Tʻ"]="Թ", ["tʻ"]="թ",
["Kʻ"]="Ք", ["kʻ"]="ք",
["Cʻ"]="Ց", ["cʻ"]="ց",
["Čʻ"]="Չ", ["čʻ"]="չ",
};
function export.tr(text, lang, sc)
if (sc == "Latn") then
text = mw.ustring.gsub(text, '[dDnNlL][jž]', tt[sc])
end
return mw.ustring.toNFC(mw.ustring.gsub(text, '.', tt[sc]))
end
return export