Skip to content

Instantly share code, notes, and snippets.

@844196
Created August 11, 2015 16:31
Show Gist options
  • Select an option

  • Save 844196/81a3bf2470f2c61c0358 to your computer and use it in GitHub Desktop.

Select an option

Save 844196/81a3bf2470f2c61c0358 to your computer and use it in GitHub Desktop.
ポストボックス内のテキストをどせいさん語へ変換するmikutterプラグイン
Plugin.create :convert_doseisan_lang do
command(:convert_doseisan_lang,
name: 'どせいさん語へ変換',
condition: lambda {|opt| true },
visible: true,
role: :postbox) do |opt|
postbox = Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer
current_text = postbox.text
before_dosei_char = ['い', 'き', 'く', 'さ', 'し', 'せ', 'そ', 'ち', 'つ', 'て', 'の', 'ひ', 'へ', 'み', 'も', 'や', 'ら', 'り', 'る', 'ん', 'ぎ', 'ぐ', 'ざ', 'じ', 'ぜ', 'ぞ', 'ぢ', 'づ', 'で', 'ば', 'び', 'べ']
after_dosei_char = ['Ɩı', '₹', 'ㄑ', 'ㄜ', 'ι', 'ㄝ', 'ƺ', 'ㄘ', '⊃ ', 'Շ', '๑', 'Ʊ', 'ㄟ', 'Ⴋ', 'Ⱡ', '兯', 'ʖˋ', 'レ)', 'ʓ', 'ƕ ', '₹˝', 'ㄑ˝', 'ㄜ˝', 'ι˝', 'ㄝ˝', 'ƺ˝', 'ㄘ˝', '⊃ ˝', 'Շ˝', '∣ժ̅˝', 'Ʊ˝', 'ㄟ˝']
convert_table = Hash[*before_dosei_char.zip(after_dosei_char).flatten]
rtn = current_text.each_char.map {|c|
r = c.gsub(/./, convert_table)
r.empty? ? c : r
}.join
postbox.text = rtn
end
end
@844196
Copy link
Author

844196 commented Aug 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment