36 lines
1.7 KiB
Lua
36 lines
1.7 KiB
Lua
|
-- 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)
|