Module:fa-translit
Itsura
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Wikang Persa 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:fa-translit/testcases.
Functions
[baguhin]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 mapping = {
["ا"]='â', ["ب"]='b', ["پ"]='p', ["ت"]='t', ["ث"]='s', ["ج"]='j', ["چ"]='č', ["ح"]='h', ["خ"]='x',
["د"]='d', ["ذ"]='z', ["ر"]='r', ["ز"]='z', ["ژ"]='ž', ["س"]='s', ["ش"]='š', ["ص"]='s', ["ض"]='z',
["ط"]='t', ["ظ"]='z', ["ع"]='’', ["غ"]='ğ', ["ف"]='f', ["ق"]='q', ["ک"]='k', ["گ"]='g', ["ل"]='l',
["م"]='m', ["ن"]='n', ["و"]='u', ["ه"]='h', ["ی"]='i', ["آ"]='â', ["ﮥ"]='eye',
-- displaying on separate lines as the viewing becomes distorted on these combinations
["ء"]="'",
["ئ"]="'",
["ؤ"]="'",
["أ"]="'",
-- diacritics
["\217\142"]="a", -- fathe, zabar
["\217\144"]="e", -- kasre, zir
["\217\143"]="o", -- zamme, piš
["\217\146"]="", --jazm, sokun - no vowel
["اً"]="an",
["\226\128\140"]="-", -- ZWNJ (zero-width non-joiner)
-- ligatures
["ﻻ"]="lâ",
["ﷲ"]="llâh",
-- kashida
["ـ"]="", -- kashida, no sound
-- numerals
["۱"]="1", ["۲"]="2", ["۳"]="3", ["۴"]="4", ["۵"]="5",
["۶"]="6", ["٧"]="7", ["٨"]="8", ["٩"]="9", ["۰"]="0",
-- punctuation (leave on separate lines)
["؟"]="?", -- question mark
["،"]=",", -- comma
["؛"]=";" -- semicolon
};
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, '.', mapping)
text = mw.ustring.gsub(text, "(.)\217\145", "%1%1") -- tašdid
return text
end
return export