-- 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)