Language code in page name (User:Sinonquoi/ks
) not recognized.
local u = mw.ustring.char -- unicode
local gsub = mw.ustring.gsub -- string manipulation
-- TODO
-- 1. Aspirate aspirables
-- 2. Vowels with fixed characters (ā, ạ̄, ū, o, ō, e, ē, ọ, ọ̄)
-- 3. Initial variants of vowels (with alef)
-- 4. Medial variants of vowels (diacritics or standalone)
-- 5. Final variants of vowels (same as medial except: e, ē)
-- 6. Treat final yē and vāv differently depending on what comes before
-- 7. Treat final hē with vowel diacritic
-- 8. Fixed consonants and provided vowels
-- 9. Disregard hat for nūn
-- 10. Work around hat for rē
-- 11. yē with hat is a palatal
-- 12. Kashmiri yē medial is 'a; final '
-- 12b. Check support for compound words
-- 13. Add vowels to consonants
-- 14. Add vowels to dual role characters
-- How to add vowels
-- Make list of consonants and vowels
-- Check if conditions are met (C+V; alef initial+V; vowel carrier + V)
-- Change
local export = {}
local aspirable = "پتٹچژک"
local aspirate_h = "ھ"
local hattable = "یر"
local vowel_diacritics = u(0x064E) .. u(0x064F) .. u(0x0650) .. u(0x0654) .. u(0x0655) .. u(0x065F)
-- DIACRITICS
local v_sign = u(0x065A) -- V
local inverted_v_sign = u(0x065B) -- inverted V
local hats = v_sign .. inverted_v_sign
local conv = {
= 'b', = 'p', = 't', = 'ṭ', = 's',
= 'j', = 'c', = 'h', = 'kh',
= 'd', = 'ḍ', = 'z',
= 'r', = 'ḍ', = 'z', = 'ċ',
= 's', = 'ś', = 's', = 'z',
= 't', = 'z',
= 'ʿ', = 'ġ',
= 'f', = 'q',
= 'k', = 'g',
= 'l', = 'm', = 'n',
= 'h',
-- treatment varies
= 'h',
-- extended set
= 'y', = 'v',
}
local vowels_conv = {
= 'a', = 'u', = 'i', = 'ạ', = 'ụ', = 'ụ̄',
}
local consonants = 'بپتٹثجچحخدڈذرڑزژسشصضطظعغفقکگلمنھ'
local consonants_extended = 'بپتٹثجچحخدڈذرڑزژسشصضطظعغفقکگلمنھوی'
function export.transliterate(text)
-- ASPIRATE
-- text = gsub(text, aspirable .. aspirate_h, "hhhh")
-- REMOVE HAT FROM NŪN and RĒ
text = gsub(text, '()' .. inverted_v_sign, "%1")
-- C2=r/palatal
text = gsub(text, '()()' .. inverted_v_sign, "%1%2")
-- YĒ with INVERTED HAT
text = gsub(text, 'ی' .. inverted_v_sign, "\'")
-- FINAL HALF-YĒ IS A PALATAL
text = gsub(text, 'ؠ$', "\'")
-- BEFORE A SPACE
text = gsub(text, 'ؠ+', "\' ")
-- MEDIAL HALF-YĒ IS 'a
text = gsub(text, '()ؠ()', "%1\'a%2")
-- CONSONANT + VOWEL
text = gsub(text,
'()()',
function(c,v)
return conv .. vowels_conv
end)
-- text = gsub(text, '()', vowels_conv)
-- FINAL HE + VOWEL
-- text = gsub(text, 'ہ()$', short_vowels)
text = gsub(text, '', conv)
return text
end
return export