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

37 lines
1.7 KiB
Lua
Raw Permalink 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.register_event("file-loaded", function()
local sub = mp.get_property_native("sub-text")
if sub then
mp.msg.info("Original subtitle text: " .. sub)
local converted_sub = convert_halfwidth_to_fullwidth(sub)
mp.set_property("sub-text", converted_sub)
mp.msg.info("Converted subtitle text: " .. converted_sub)
end
end)