Module:mxi-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Mozarabic 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:mxi-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 = {};
function export.tr(text, lang, sc)
local replacements;
if (sc == 'Arab') then
return mw.ustring.gsub(mw.ustring.gsub(text, '.', {
-- consonants --
['ا']='ə', ['ب']='b', ['ت']='t', ['ث']='ṯ', ['ج']='j',
['ح']='ḥ', ['خ']='ḵ', ['د']='d', ['ذ']='ḏ', ['ر']='r',
['ز']='z', ['س']='s', ['ش']='š', ['ص']='ṣ', ['ض']='ḍ',
['ط']='ṭ', ['ظ']='ẓ', ['ع']='ʕ', ['غ']='ḡ', ['ڢ']='f',
['ڧ']='q', ['ك']='k', ['ل']='l', ['م']='m', ['ࢽ']='n',
['ه']='h', ['و']='w', ['ی']='y',
-- [ق], [ف] and [ي] should not occur, but [ن] sometimes does
['ن']='n',
-- [ے] should likely be used in quotes at least
['ے']='y',
-- tashkil --
['َ']='a', ['ُ']='u', ['ِ']='i',
['ّ']='ː', ['ْ']='°',
}), '([btṯjḥḵdḏrzsšṣḍṭẓʕḡfqklmnhwyuiː°])ə', '%1ā'):gsub('aə', 'ā');
elseif (sc == 'Hebr') then
return mw.ustring.gsub(text, '.', {
-- consonants --
['א'] = 'ʔ', ['ב'] = 'b', ['ג'] = 'g', ['ד'] = 'd',
['ה'] = 'h', ['ו'] = 'w', ['ז'] = 'z', ['ח'] = 'ḥ',
['ט'] = 'ṭ', ['י'] = 'y', ['כ'] = 'k', ['ל'] = 'l',
['מ'] = 'm', ['נ'] = 'n', ['ס'] = 's', ['ע'] = 'ʕ',
['פ'] = 'f', ['צ'] = 'ṣ', ['ק'] = 'q', ['ר'] = 'r',
['ש'] = 'š', ['ת'] = 't',
-- sofit --
['ך'] = 'k', ['ם'] = 'm', ['ן'] = 'n', ['ף'] = 'f',
['ץ'] = 'ṣ',
-- nikud ?
});
end
return ;
end
return export;