modern_lisp-machine/.config/mpv/scripts/katakana_conversion.lua~

36 lines
1.7 KiB
Lua
Raw Normal View History

2024-09-08 20:06:38 +00:00
-- katakana_conversion.lua
-- Table mapping half-width katakana to full-width
local half_to_full = {
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', ['ソ'] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = '', [''] = '', [''] = '',
[''] = '', [''] = ''
}
-- Function to convert half-width katakana to full-width
local function convert_halfwidth_to_fullwidth(text)
return text:gsub(".", function(c)
return half_to_full[c] or c
end)
end
-- Hook into the subtitle text before display
mp.add_hook("on_sub_text", 50, function(subtitle)
if subtitle and subtitle.text then
mp.msg.info("Original subtitle text: " .. subtitle.text)
subtitle.text = convert_halfwidth_to_fullwidth(subtitle.text)
mp.msg.info("Converted subtitle text: " .. subtitle.text)
end
return subtitle
end)