模組:Ital-translit
這個模組會將古意大利字母文字轉寫為拉丁字母。
最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}
做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。
關於測試用例,請參閱Module:Ital-translit/testcases。
函數
编辑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, returnsnil
.
local export = {}
-- Standard transcription
local common_rules = {
['𐌀'] = 'a',
['𐌁'] = 'b',
['𐌂'] = 'c',
['𐌃'] = 'd',
['𐌄'] = 'e',
['𐌅'] = 'v',
['𐌆'] = 'z',
['𐌇'] = 'h',
['𐌈'] = 'θ',
['𐌉'] = 'i',
['𐌊'] = 'k',
['𐌋'] = 'l',
['𐌌'] = 'm',
['𐌍'] = 'n',
['𐌎'] = 'š',
['𐌏'] = 'o',
['𐌐'] = 'p',
['𐌑'] = 'ś',
['𐌒'] = 'q',
['𐌓'] = 'r',
['𐌔'] = 's',
['𐌕'] = 't',
['𐌖'] = 'u',
['𐌗'] = 'x',
['𐌘'] = 'φ',
['𐌙'] = 'χ',
['𐌚'] = 'f',
['𐌛'] = 'ř',
['𐌜'] = 'ç',
['𐌝'] = 'í',
['𐌞'] = 'ú',
['𐌟'] = 'k',
-- Numerals
['𐌠'] = 'Ⅰ',
['𐌡'] = 'Ⅴ',
['𐌢'] = 'Ⅹ',
['𐌣'] = 'Ⅼ',
-- Punctuation
['·'] = ' ',
['⁚'] = ' ',
['⁝'] = ' ',
}
local lang_rules = {
['ett'] = { -- Etruscan
['𐌟'] = 'Ⅽ',
};
['itc-ola'] = { -- Old Latin
['𐌅'] = 'f',
};
['nrc'] = { -- Noric
['𐌂'] = 'g',
['𐌈'] = 'd',
['𐌙'] = 'g',
};
['nrp'] = { -- North Picene
['𐌂'] = 'g',
};
['osc'] = { -- Oscan
['𐌂'] = 'g',
};
['spx'] = { -- South Picene
['𐌂'] = 'g',
['𐌑'] = 'í',
['·'] = 'o',
['⁚'] = 'f',
};
['xcc'] = { -- Camunic
['𐌁'] = 'ś',
['𐌂'] = 'g',
['𐌑'] = 'b',
['𐌙'] = 's',
['𐌟'] = 'þþ',
['𐌣'] = 'þ',
};
['xrr'] = { -- Raetic
['𐌁'] = 'þ',
['𐌂'] = '?',
};
['xum'] = { -- Umbrian
['𐌈'] = 't',
};
['xve'] = { -- Venetic
['𐌂'] = 'j',
['𐌆'] = 'd',
['𐌇𐌅'] = 'f',
['𐌘'] = 'b',
['𐌙'] = 'g',
};
}
function export.tr(text, lang, sc)
-- If the script is not Ital, do not transliterate
if sc ~= "Ital" then
return
end
-- Transliterate language-specific exceptions
if lang == "xve" then
text = mw.ustring.gsub(text, '𐌇𐌅', 'f')
end
if lang_rules[lang] then
text = mw.ustring.gsub(text, '.', lang_rules[lang])
end
-- Transliterate remaining characters
text = mw.ustring.gsub(text, '.', common_rules)
return text
end
return export