如何将罗马拉丁字母转换成日文字母?

时间:2013-08-13 14:14:24

标签: android converter

我正在开发日英词典。 SQLite数据库包括平假名中的日语单词。如何将罗马(罗马字母)字母转换为日文(平假名)字母?是否有支持Android的现成方式?如果不是如何转换为平假名?什么是最简单的方法?

1 个答案:

答案 0 :(得分:0)

public class Converter {
public String RomajiToHiragana(String wordRomaji) {
    wordRomaji = wordRomaji.toLowerCase();
    // Seion
    if (wordRomaji.contains("kya")) {
        wordRomaji = wordRomaji.replace("kya", "きゃ");
    }
    if (wordRomaji.contains("kyu")) {
        wordRomaji = wordRomaji.replace("kyu", "きゅ");
    }
    if (wordRomaji.contains("kyo")) {
        wordRomaji = wordRomaji.replace("kyo", "きょ");
    }
    if (wordRomaji.contains("sha")) {
        wordRomaji = wordRomaji.replace("sha", "しゃ");
    }
    if (wordRomaji.contains("shu")) {
        wordRomaji = wordRomaji.replace("shu", "しゅ");
    }
    if (wordRomaji.contains("sho")) {
        wordRomaji = wordRomaji.replace("sho", "しょ");
    }
    if (wordRomaji.contains("cha")) {
        wordRomaji = wordRomaji.replace("cha", "ちゃ");
    }
    if (wordRomaji.contains("chu")) {
        wordRomaji = wordRomaji.replace("chu", "ちゅ");
    }
    if (wordRomaji.contains("cho")) {
        wordRomaji = wordRomaji.replace("cho", "ちょ");
    }
    if (wordRomaji.contains("nya")) {
        wordRomaji = wordRomaji.replace("nya", "にゃ");
    }
    if (wordRomaji.contains("nyu")) {
        wordRomaji = wordRomaji.replace("nyu", "にゅ");
    }
    if (wordRomaji.contains("nyo")) {
        wordRomaji = wordRomaji.replace("nyo", "にょ");
    }
    if (wordRomaji.contains("hya")) {
        wordRomaji = wordRomaji.replace("hya", "ひゃ");
    }
    if (wordRomaji.contains("hyu")) {
        wordRomaji = wordRomaji.replace("hyu", "ひゅ");
    }
    if (wordRomaji.contains("hyo")) {
        wordRomaji = wordRomaji.replace("hyo", "ひょ");
    }
    if (wordRomaji.contains("mya")) {
        wordRomaji = wordRomaji.replace("mya", "みゃ");
    }
    if (wordRomaji.contains("myu")) {
        wordRomaji = wordRomaji.replace("myu", "みゅ");
    }
    if (wordRomaji.contains("myo")) {
        wordRomaji = wordRomaji.replace("myo", "みょ");
    }
    if (wordRomaji.contains("rya")) {
        wordRomaji = wordRomaji.replace("rya", "りゃ");
    }
    if (wordRomaji.contains("ryu")) {
        wordRomaji = wordRomaji.replace("ryu", "りゅ");
    }
    if (wordRomaji.contains("ryo")) {
        wordRomaji = wordRomaji.replace("ryo", "りょ");
    }

    // Dakuon
    if (wordRomaji.contains("gya")) {
        wordRomaji = wordRomaji.replace("gya", "ぎゃ");
    }
    if (wordRomaji.contains("gyu")) {
        wordRomaji = wordRomaji.replace("gyu", "ぎゅ");
    }
    if (wordRomaji.contains("gyo")) {
        wordRomaji = wordRomaji.replace("gyo", "ぎょ");
    }
    if (wordRomaji.contains("ja")) {
        wordRomaji = wordRomaji.replace("ja", "じゃ");
    }
    if (wordRomaji.contains("ju")) {
        wordRomaji = wordRomaji.replace("ju", "じゅ");
    }
    if (wordRomaji.contains("jo")) {
        wordRomaji = wordRomaji.replace("jo", "じょ");
    }
    if (wordRomaji.contains("ja")) {
        wordRomaji = wordRomaji.replace("ja", "ぢゃ");
    }
    if (wordRomaji.contains("ju")) {
        wordRomaji = wordRomaji.replace("ju", "ぢゅ");
    }
    if (wordRomaji.contains("jo")) {
        wordRomaji = wordRomaji.replace("jo", "ぢょ");
    }
    if (wordRomaji.contains("bya")) {
        wordRomaji = wordRomaji.replace("bya", "びゃ");
    }
    if (wordRomaji.contains("byu")) {
        wordRomaji = wordRomaji.replace("byu", "びゅ");
    }
    if (wordRomaji.contains("byo")) {
        wordRomaji = wordRomaji.replace("byo", "びょ");
    }
    if (wordRomaji.contains("pya")) {
        wordRomaji = wordRomaji.replace("pya", "ぴゃ");
    }
    if (wordRomaji.contains("pyu")) {
        wordRomaji = wordRomaji.replace("pyu", "ぴゅ");
    }
    // HD
    if (wordRomaji.contains("pyo")) {
        wordRomaji = wordRomaji.replace("pyo", "ぴょ");
    }

    // Seion:Ka
    if (wordRomaji.contains("ka")) {
        wordRomaji = wordRomaji.replace("ka", "か");
    }
    if (wordRomaji.contains("ki")) {
        wordRomaji = wordRomaji.replace("ki", "き");
    }
    if (wordRomaji.contains("ku")) {
        wordRomaji = wordRomaji.replace("ku", "く");
    }
    if (wordRomaji.contains("ke")) {
        wordRomaji = wordRomaji.replace("ke", "け");
    }
    if (wordRomaji.contains("ko")) {
        wordRomaji = wordRomaji.replace("ko", "こ");
    }
    // Seion:Ga
    if (wordRomaji.contains("ga")) {
        wordRomaji = wordRomaji.replace("ga", "が");
    }
    if (wordRomaji.contains("gi")) {
        wordRomaji = wordRomaji.replace("gi", "ぎ");
    }
    if (wordRomaji.contains("gu")) {
        wordRomaji = wordRomaji.replace("gu", "ぐ");
    }
    if (wordRomaji.contains("ge")) {
        wordRomaji = wordRomaji.replace("ge", "げ");
    }
    if (wordRomaji.contains("go")) {
        wordRomaji = wordRomaji.replace("go", "ご");
    }
    // Seion:Sa
    if (wordRomaji.contains("sa")) {
        wordRomaji = wordRomaji.replace("sa", "さ");
    }
    if (wordRomaji.contains("shi")) {
        wordRomaji = wordRomaji.replace("shi", "し");
    }
    if (wordRomaji.contains("su")) {
        wordRomaji = wordRomaji.replace("su", "す");
    }
    if (wordRomaji.contains("se")) {
        wordRomaji = wordRomaji.replace("se", "せ");
    }
    if (wordRomaji.contains("so")) {
        wordRomaji = wordRomaji.replace("so", "そ");
    }
    // Seion:Za
    if (wordRomaji.contains("za")) {
        wordRomaji = wordRomaji.replace("za", "ざ");
    }
    if (wordRomaji.contains("ji")) {
        wordRomaji = wordRomaji.replace("ji", "じ");
    }
    if (wordRomaji.contains("zu")) {
        wordRomaji = wordRomaji.replace("zu", "ず");
    }
    if (wordRomaji.contains("ze")) {
        wordRomaji = wordRomaji.replace("ze", "ぜ");
    }
    if (wordRomaji.contains("zo")) {
        wordRomaji = wordRomaji.replace("zo", "ぞ");
    }
    // Seion:Ta
    if (wordRomaji.contains("ta")) {
        wordRomaji = wordRomaji.replace("ta", "た");
    }
    if (wordRomaji.contains("chi")) {
        wordRomaji = wordRomaji.replace("chi", "ち");
    }
    if (wordRomaji.contains("tsu")) {
        wordRomaji = wordRomaji.replace("tsu", "つ");
    }
    if (wordRomaji.contains("te")) {
        wordRomaji = wordRomaji.replace("te", "て");
    }
    if (wordRomaji.contains("to")) {
        wordRomaji = wordRomaji.replace("to", "と");
    }
    // Seion:Da
    if (wordRomaji.contains("da")) {
        wordRomaji = wordRomaji.replace("da", "だ");
    }
    if (wordRomaji.contains("di")) {
        wordRomaji = wordRomaji.replace("di", "ぢ");
    }
    if (wordRomaji.contains("du")) {
        wordRomaji = wordRomaji.replace("du", "づ");
    }
    if (wordRomaji.contains("de")) {
        wordRomaji = wordRomaji.replace("de", "で");
    }
    if (wordRomaji.contains("do")) {
        wordRomaji = wordRomaji.replace("do", "ど");
    }
    // Seion:Ha
    if (wordRomaji.contains("ha")) {
        wordRomaji = wordRomaji.replace("ha", "は");
    }
    if (wordRomaji.contains("hi")) {
        wordRomaji = wordRomaji.replace("hi", "ひ");
    }
    if (wordRomaji.contains("fu")) {
        wordRomaji = wordRomaji.replace("fu", "ふ");
    }
    if (wordRomaji.contains("he")) {
        wordRomaji = wordRomaji.replace("he", "へ");
    }
    if (wordRomaji.contains("ho")) {
        wordRomaji = wordRomaji.replace("ho", "ほ");
    }
    // Seion:Ba
    if (wordRomaji.contains("ba")) {
        wordRomaji = wordRomaji.replace("ba", "ば");
    }
    if (wordRomaji.contains("bi")) {
        wordRomaji = wordRomaji.replace("bi", "び");
    }
    if (wordRomaji.contains("bu")) {
        wordRomaji = wordRomaji.replace("bu", "ぶ");
    }
    if (wordRomaji.contains("be")) {
        wordRomaji = wordRomaji.replace("be", "べ");
    }
    if (wordRomaji.contains("bo")) {
        wordRomaji = wordRomaji.replace("bo", "ぼ");
    }
    // Seion:Pa
    if (wordRomaji.contains("pa")) {
        wordRomaji = wordRomaji.replace("pa", "ぱ");
    }
    if (wordRomaji.contains("pi")) {
        wordRomaji = wordRomaji.replace("pi", "ぴ");
    }
    if (wordRomaji.contains("pu")) {
        wordRomaji = wordRomaji.replace("pu", "ぷ");
    }
    if (wordRomaji.contains("pe")) {
        wordRomaji = wordRomaji.replace("pe", "ぺ");
    }
    if (wordRomaji.contains("po")) {
        wordRomaji = wordRomaji.replace("po", "ぽ");
    }
    // Seion:Na
    if (wordRomaji.contains("na")) {
        wordRomaji = wordRomaji.replace("na", "な");
    }
    if (wordRomaji.contains("ni")) {
        wordRomaji = wordRomaji.replace("ni", "に");
    }
    if (wordRomaji.contains("nu")) {
        wordRomaji = wordRomaji.replace("nu", "ぬ");
    }
    if (wordRomaji.contains("ne")) {
        wordRomaji = wordRomaji.replace("ne", "ね");
    }
    if (wordRomaji.contains("no")) {
        wordRomaji = wordRomaji.replace("no", "の");
    }
    // Seion:Ma
    if (wordRomaji.contains("ma")) {
        wordRomaji = wordRomaji.replace("ma", "ま");
    }
    if (wordRomaji.contains("mi")) {
        wordRomaji = wordRomaji.replace("mi", "み");
    }
    if (wordRomaji.contains("mu")) {
        wordRomaji = wordRomaji.replace("mu", "む");
    }
    if (wordRomaji.contains("me")) {
        wordRomaji = wordRomaji.replace("me", "め");
    }
    if (wordRomaji.contains("mo")) {
        wordRomaji = wordRomaji.replace("mo", "も");
    }
    // Seion:Ra
    if (wordRomaji.contains("ra")) {
        wordRomaji = wordRomaji.replace("ra", "ら");
    }
    if (wordRomaji.contains("ri")) {
        wordRomaji = wordRomaji.replace("ri", "り");
    }
    if (wordRomaji.contains("ru")) {
        wordRomaji = wordRomaji.replace("ru", "る");
    }
    if (wordRomaji.contains("re")) {
        wordRomaji = wordRomaji.replace("re", "れ");
    }
    if (wordRomaji.contains("ro")) {
        wordRomaji = wordRomaji.replace("ro", "ろ");
    }
    // Seion:Ya
    if (wordRomaji.contains("ya")) {
        wordRomaji = wordRomaji.replace("ya", "や");
    }
    if (wordRomaji.contains("yu")) {
        wordRomaji = wordRomaji.replace("yu", "ゆ");
    }
    if (wordRomaji.contains("yo")) {
        wordRomaji = wordRomaji.replace("yo", "よ");
    }
    // Seion:Wa
    if (wordRomaji.contains("wa")) {
        wordRomaji = wordRomaji.replace("wa", "わ");
    }
    if (wordRomaji.contains("wo")) {
        wordRomaji = wordRomaji.replace("wo", "を");
    }
    // Seion:n
    if (wordRomaji.contains("n")) {
        wordRomaji = wordRomaji.replace("n", "ん");
    }
    // Seion:a
    if (wordRomaji.contains("a")) {
        wordRomaji = wordRomaji.replace("a", "あ");
    }
    if (wordRomaji.contains("i")) {
        wordRomaji = wordRomaji.replace("i", "い");
    }
    if (wordRomaji.contains("u")) {
        wordRomaji = wordRomaji.replace("u", "う");
    }
    if (wordRomaji.contains("e")) {
        wordRomaji = wordRomaji.replace("e", "え");
    }
    if (wordRomaji.contains("o")) {
        wordRomaji = wordRomaji.replace("o", "お");
    }

    // Double letters with little tsu
    if (wordRomaji.contains("k")) {
        wordRomaji = wordRomaji.replace("k", "っ");
    }
    if (wordRomaji.contains("sh")) {
        wordRomaji = wordRomaji.replace("s", "っ");
    }
    if (wordRomaji.contains("t")) {
        wordRomaji = wordRomaji.replace("t", "っ");
    }
    if (wordRomaji.contains("n")) {
        wordRomaji = wordRomaji.replace("n", "っ");
    }
    if (wordRomaji.contains("h")) {
        wordRomaji = wordRomaji.replace("h", "っ");
    }
    if (wordRomaji.contains("m")) {
        wordRomaji = wordRomaji.replace("m", "っ");
    }
    if (wordRomaji.contains("y")) {
        wordRomaji = wordRomaji.replace("y", "っ");
    }
    if (wordRomaji.contains("r")) {
        wordRomaji = wordRomaji.replace("r", "っ");
    }
    if (wordRomaji.contains("w")) {
        wordRomaji = wordRomaji.replace("w", "っ");
    }
    if (wordRomaji.contains("g")) {
        wordRomaji = wordRomaji.replace("g", "っ");
    }
    if (wordRomaji.contains("z")) {
        wordRomaji = wordRomaji.replace("z", "っ");
    }
    if (wordRomaji.contains("d")) {
        wordRomaji = wordRomaji.replace("d", "っ");
    }
    if (wordRomaji.contains("s")) {
        wordRomaji = wordRomaji.replace("s", "っ");
    }
    if (wordRomaji.contains("j")) {
        wordRomaji = wordRomaji.replace("j", "っ");
    }
    if (wordRomaji.contains("ch")) {
        wordRomaji = wordRomaji.replace("ch", "っ");
    }
    if (wordRomaji.contains("b")) {
        wordRomaji = wordRomaji.replace("b", "っ");
    }
    if (wordRomaji.contains("p")) {
        wordRomaji = wordRomaji.replace("p", "っ");
    }


    return wordRomaji;
}

}