Module:ConvertToAe
Appearance
local p = {}
function p.convert(frame)
local input = frame.args[1]
-- If no input is provided, return an empty string
if not input or input == '' then
return ''
end
local lastChar = mw.ustring.sub(input, -1)
-- Define the mappings of last letters to their "ඒ" forms
local suffixMap = {
['ක'] = 'කේ',
['ග'] = 'ගේ',
['ච'] = 'චේ',
['ජ'] = 'ජේ',
['ඛ'] = 'ඛේ',
['ය'] = 'යේ',
['ව'] = 'වේ',
['ම'] = 'මේ',
['ර'] = 'රේ',
['ද'] = 'දේ',
['බ'] = 'බේ',
['ප'] = 'පේ',
['න'] = 'නේ',
['ඝ'] = 'ඝේ',
['ඟ'] = 'ඟේ',
['ඡ'] = 'ඡේ',
['ඣ'] = 'ඣේ',
['ඥ'] = 'ඥේ',
['ඤ'] = 'ඤේ',
['ට'] = 'ටේ',
['ඨ'] = 'ඨේ',
['ඩ'] = 'ඩේ',
['ඪ'] = 'ඪේ',
['ණ'] = 'ණේ',
['ඬ'] = 'ඬේ',
['ත'] = 'තේ',
['ථ'] = 'ථේ',
['ධ'] = 'ධේ',
['ඳ'] = 'ඳේ',
['ඵ'] = 'ඵේ',
['භ'] = 'භේ',
['ඹ'] = 'ඹේ',
['ල'] = 'ලේ',
['ශ'] = 'ශේ',
['ෂ'] = 'ෂේ',
['ස'] = 'සේ',
['හ'] = 'හේ',
['ළ'] = 'ළේ',
['ෆ'] = 'ෆේ',
-- Add other mappings as needed
}
-- Find the suffix based on the last character
local suffix = suffixMap[lastChar]
if suffix then
-- Replace the last character with its "ඒ" version
return mw.ustring.sub(input, 1, -2) .. suffix
else
-- If there's no matching suffix, add "හි" as a default
return input .. ' හි'
end
end
return p