goldendict-ng/romaji.cc
2021-07-15 22:58:32 +08:00

127 lines
8.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "romaji.hh"
#include <QCoreApplication>
namespace Romaji {
class HepburnHiragana: public Transliteration::Table
{
public:
HepburnHiragana();
};
HepburnHiragana::HepburnHiragana()
{
// Raw UTF8 -- handle with care. We'd better remap those to \xAB hex encoding
ins( "a", "" ); ins( "i", "" ); ins( "u", "" ); ins( "e", "" ); ins( "o", "" );
ins( "ka", "" ); ins( "ki", "" ); ins( "ku", "" ); ins( "ke", "" ); ins( "ko", "" ); ins( "kya", "きゃ" ); ins( "kyu", "きゅ" ); ins( "kyo", "きょ" );
ins( "sa", "" ); ins( "shi", "" ); ins( "su", "" ); ins( "se", "" ); ins( "so", "" ); ins( "sha", "しゃ" ); ins( "shu", "しゅ" ); ins( "sho", "しょ" );
ins( "ta", "" ); ins( "chi", "" ); ins( "tsu", "" ); ins( "te", "" ); ins( "to", "" ); ins( "cha", "ちゃ" ); ins( "chu", "ちゅ" ); ins( "cho", "ちょ" );
ins( "na", "" ); ins( "ni", "" ); ins( "nu", "" ); ins( "ne", "" ); ins( "no", "" ); ins( "nya", "にゃ" ); ins( "nyu", "にゅ" ); ins( "nyo", "にょ" );
ins( "ha", "" ); ins( "hi", "" ); ins( "fu", "" ); ins( "he", "" ); ins( "ho", "" ); ins( "hya", "ひゃ" ); ins( "hyu", "ひゅ" ); ins( "hyo", "ひょ" );
ins( "ma", "" ); ins( "mi", "" ); ins( "mu", "" ); ins( "me", "" ); ins( "mo", "" ); ins( "mya", "みゃ" ); ins( "myu", "みゅ" ); ins( "myo", "みょ" );
ins( "ya", "" ); ins( "yu", "" ); ins( "yo", "" );
ins( "ra", "" ); ins( "ri", "" ); ins( "ru", "" ); ins( "re", "" ); ins( "ro", "" ); ins( "rya", "りゃ" ); ins( "ryu", "りゅ" ); ins( "ryo", "りょ" );
ins( "wa", "" ); /*ゐ wi† ゑ we† */ ins( "wo", "" );
ins( "n", "" );
ins( "ga", "" ); ins( "gi", "" ); ins( "gu", "" ); ins( "ge", "" ); ins( "go", "" ); ins( "gya", "ぎゃ" ); ins( "gyu", "ぎゅ" ); ins( "gyo", "ぎょ" );
ins( "za", "" ); ins( "ji", "" ); ins( "zu", "" ); ins( "ze", "" ); ins( "zo", "" ); ins( "ja", "じゃ" ); ins( "ju", "じゅ" ); ins( "jo", "じょ" );
ins( "da", "" ); ins( "(ji)", "" ); ins( "(zu)", "" ); ins( "de", "" ); ins( "do", "" ); ins( "(ja)", "ぢゃ" ); ins( "(ju)", "ぢゅ" ); ins( "(jo)", "ぢょ" );
ins( "ba", "" ); ins( "bi", "" ); ins( "bu", "" ); ins( "be", "" ); ins( "bo", "" ); ins( "bya", "びゃ" ); ins( "byu", "びゅ" ); ins( "byo", "びょ" );
ins( "pa", "" ); ins( "pi", "" ); ins( "pu", "" ); ins( "pe", "" ); ins( "po", "" ); ins( "pya", "ぴゃ" ); ins( "pyu", "ぴゅ" ); ins( "pyo", "ぴょ" );
// Double consonants
ins( "kka", "っか" ); ins( "kki", "っき" ); ins( "kku", "っく" ); ins( "kke", "っけ" ); ins( "kko", "っこ" ); ins( "kkya", "っきゃ" ); ins( "kkyu", "っきゅ" ); ins( "kkyo", "っきょ" );
ins( "ssa", "っさ" ); ins( "sshi", "っし" ); ins( "ssu", "っす" ); ins( "sse", "っせ" ); ins( "sso", "っそ" ); ins( "ssha", "っしゃ" ); ins( "sshu", "っしゅ" ); ins( "ssho", "っしょ" );
ins( "tta", "った" ); ins( "tchi", "っち" ); ins( "ttsu", "っつ" ); ins( "tte", "って" ); ins( "tto", "っと" ); ins( "tcha", "っちゃ" ); ins( "tchu", "っちゅ" ); ins( "tcho", "っちょ" );
ins( "ppa", "っぱ" ); ins( "ppi", "っぴ" ); ins( "ppu", "っぷ" ); ins( "ppe", "っぺ" ); ins( "ppo", "っぽ" ); ins( "ppya", "っぴゃ" ); ins( "ppyu", "っぴゅ" ); ins( "ppyo", "っぴょ" );
}
class HepburnKatakana: public Transliteration::Table
{
public:
HepburnKatakana();
};
HepburnKatakana::HepburnKatakana()
{
// Raw UTF8 -- handle with care. We'd better remap those to \xAB hex encoding
ins( "a", "" ); ins( "i", "" ); ins( "u", "" ); ins( "e", "" ); ins( "o", "" );
ins( "ka", "" ); ins( "ki", "" ); ins( "ku", "" ); ins( "ke", "" ); ins( "ko", "" ); ins( "kya", "キャ" ); ins( "kyu", "キュ" ); ins( "kyo", "キョ" );
ins( "sa", "" ); ins( "shi", "" ); ins( "su", "" ); ins( "se", "" ); ins( "so", "" ); ins( "sha", "シャ" ); ins( "shu", "シュ" ); ins( "sho", "ショ" );
ins( "ta", "" ); ins( "chi", "" ); ins( "tsu", "" ); ins( "te", "" ); ins( "to", "" ); ins( "cha", "チャ" ); ins( "chu", "チュ" ); ins( "cho", "チョ" );
ins( "na", "" ); ins( "ni", "" ); ins( "nu", "" ); ins( "ne", "" ); ins( "no", "" ); ins( "nya", "ニャ" ); ins( "nyu", "ニュ" ); ins( "nyo", "ニョ" );
ins( "ha", "" ); ins( "hi", "" ); ins( "fu", "" ); ins( "he", "" ); ins( "ho", "" ); ins( "hya", "ヒャ" ); ins( "hyu", "ヒュ" ); ins( "hyo", "ヒョ" );
ins( "ma", "" ); ins( "mi", "" ); ins( "mu", "" ); ins( "me", "" ); ins( "mo", "" ); ins( "mya", "ミャ" ); ins( "myu", "ミュ" ); ins( "myo", "ミョ" );
ins( "ya", "" ); ins( "yu", "" ); ins( "yo", "" );
ins( "ra", "" ); ins( "ri", "" ); ins( "ru", "" ); ins( "re", "" ); ins( "ro", "" ); ins( "rya", "リャ" ); ins( "ryu", "リュ" ); ins( "ryo", "リョ" );
ins( "wa", "" ); /*ヰ wi† ヱ we† ヲ wo‡ */
ins( "n", "" );
ins( "ga", "" ); ins( "gi", "" ); ins( "gu", "" ); ins( "ge", "" ); ins( "go", "" ); ins( "gya", "ギャ" ); ins( "gyu", "ギュ" ); ins( "gyo", "ギョ" );
ins( "za", "" ); ins( "ji", "" ); ins( "zu", "" ); ins( "ze", "" ); ins( "zo", "" ); ins( "ja", "ジャ" ); ins( "ju", "ジュ" ); ins( "jo", "ジョ" );
ins( "da", "" ); ins( "(ji)", "" ); ins( "(zu)", "" ); ins( "de", "" ); ins( "do", "" ); ins( "(ja)", "ヂャ" ); ins( "(ju)", "ヂュ" ); ins( "(jo)", "ヂョ" );
ins( "ba", "" ); ins( "bi", "" ); ins( "bu", "" ); ins( "be", "" ); ins( "bo", "" ); ins( "bya", "ビャ" ); ins( "byu", "ビュ" ); ins( "byo", "ビョ" );
ins( "pa", "" ); ins( "pi", "" ); ins( "pu", "" ); ins( "pe", "" ); ins( "po", "" ); ins( "pya", "ピャ" ); ins( "pyu", "ピュ" ); ins( "pyo", "ピョ" );
ins( "ye", "イェ" );
ins( "wi", "ウィ" ); ins( "we", "ウェ" ); ins( "wo", "ウォ" );
ins( "va", "" ); /*ヸ vi† ヹ ve†*/ ins( "vo", "" );
ins( "va", "ヴァ" ); ins( "vi", "ヴィ" ); ins( "vu", "" ); ins( "ve", "ヴェ" ); ins( "vo", "ヴォ" );
ins( "she", "シェ" );
ins( "je", "ジェ" );
ins( "che", "チェ" );
ins( "ti", "ティ" ); ins( "tu", "トゥ" );
ins( "tyu", "テュ" );
ins( "di", "ディ" ); ins( "du", "ドゥ" );
ins( "dyu", "デュ" );
ins( "tsa", "ツァ" ); ins( "tse", "ツェ" ); ins( "tso", "ツォ" );
ins( "fa", "ファ" ); ins( "fi", "フィ" ); ins( "fe", "フェ" ); ins( "fo", "フォ" );
ins( "fyu", "フュ" );
// Long vowel mark
ins( "-", "" );
// Double consonants
ins( "kka", "ッカ" ); ins( "kki", "ッキ" ); ins( "kku", "ック" ); ins( "kke", "ッケ" ); ins( "kko", "ッコ" ); ins( "kkya", "ッキャ" ); ins( "kkyu", "ッキュ" ); ins( "kkyo", "ッキョ" );
ins( "ssa", "ッサ" ); ins( "sshi", "ッシ" ); ins( "ssu", "ッス" ); ins( "sse", "ッセ" ); ins( "sso", "ッソ" ); ins( "ssha", "ッシャ" ); ins( "sshu", "ッシュ" ); ins( "ssho", "ッショ" );
ins( "tta", "ッタ" ); ins( "tchi", "ッチ" ); ins( "ttsu", "ッツ" ); ins( "tte", "ッテ" ); ins( "tto", "ット" ); ins( "tcha", "ッチャ" ); ins( "tchu", "ッチュ" ); ins( "tcho", "ッチョ" );
ins( "ppa", "ッパ" ); ins( "ppi", "ッピ" ); ins( "ppu", "ップ" ); ins( "ppe", "ッペ" ); ins( "ppo", "ッポ" ); ins( "ppya", "ッピャ" ); ins( "ppyu", "ッピュ" ); ins( "ppyo", "ッピョ" );
}
vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & r )
THROW_SPEC( std::exception )
{
vector< sptr< Dictionary::Class > > result;
if ( r.enable )
{
if ( r.enableHepburn )
{
if ( r.enableHiragana )
{
static HepburnHiragana t;
result.push_back( new Transliteration::TransliterationDictionary( "94eae5a5aaf5b0a900490f4d6b36aac0",
QCoreApplication::translate( "Romaji", "Hepburn Romaji for Hiragana" ).toUtf8().data(),
QIcon( ":/flags/jp.png" ), t, false ) );
}
if ( r.enableKatakana )
{
static HepburnKatakana t;
result.push_back( new Transliteration::TransliterationDictionary( "3252a35767d3f6e85e3e39069800dd2f",
QCoreApplication::translate( "Romaji", "Hepburn Romaji for Katakana" ).toUtf8().data(),
QIcon( ":/flags/jp.png" ), t, false ) );
}
}
}
return result;
}
}