Module:Rohg-translit: Difference between revisions
Jump to navigation
Jump to search
Use faster implementation of mw.ustring.char. |
m 1 revision imported |
(No difference)
| |
Latest revision as of 12:45, 21 April 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 Hanifi Rohingya script. It is used to transliterate Rohingya.
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:Rohg-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 u = require("Module:string/char")
local tt = {
-- consonants
["𐴀"]="", ["𐴁"]="b", ["𐴃"]="t", ["𐴄"]="th",
["𐴅"]="j", ["𐴆"]="ch", ["𐴇"]="h", ["𐴈"]="kh",
["𐴉"]="f", ["𐴂"]="p", ["𐴊"]="d", ["𐴋"]="dh",
["𐴌"]="r", ["𐴍"]="ç", ["𐴎"]="z", ["𐴏"]="s",
["𐴐"]="c", ["𐴑"]="k", ["𐴒"]="g", ["𐴓"]="l",
["𐴔"]="m", ["𐴕"]="n", ["𐴖"]="w", ["𐴗"]="u",
["𐴘"]="y", ["𐴙"]="i", ["𐴚"]="ng", ["𐴛"]="ny", ["𐴜"]="v",
-- vowels
["𐴝"]="a", ["𐴞"]="i", ["𐴟"]="u", ["𐴠"]="e", ["𐴡"]="o",
-- others
["𐴢"]="", --only used after some ending consonants
["𐴣"]="ñ", --nasalization
[u(0x200D)]="", --ZWJ, might appear to adjust consonants
-- numerals
["𐴰"]="0", ["𐴱"]="1", ["𐴲"]="2", ["𐴳"]="3", ["𐴴"]="4",
["𐴵"]="5", ["𐴶"]="6", ["𐴷"]="7", ["𐴸"]="8", ["𐴹"]="9",
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, ".", tt)
-- tones and special mark
text = mw.ustring.gsub(text, "(.)𐴤", "%1́")
text = mw.ustring.gsub(text, "(.)𐴥", "%1́%1")
text = mw.ustring.gsub(text, "(.)𐴦", "%1%1́")
text = mw.ustring.gsub(text, "(.)𐴧", "%1%1")
return text
end
return export