renpy/doc/cookbook/Kana Converter

From Ren'Py

Jump to: navigation, search

This is a kana converter for Ren'py. There are three files: one for hiragana, one for katakana without dashes, and another for katakana with dashes. The code is open-source, and should be improved wherever possible.

Hiragana Version:

# Ren'Py Kana Converter v1.0 (Hiragana)
# Originally programmed by Ivlivs from the Lemmasoft Forums.
#
# For a long time, renpy.input() was limited to not only Roman
# letters, but those used in the English language. Officially, it still is,
# but the following code offers a powerful workaround.
#
# Allowing the input of kanji into Ren'Py through the input is possible
# but horrendously impractical as of now, so I did the next best
# thing: I made a kana converter, since kana proper nouns are
# perfectly legitimate in the Japanese language.
#
# This code is open-source. Feel free to modify it, so long as you
# credit me.
#
# NOTE: Converters can be made for other left-to-right non-ligature
# alphabets, like those used in the Romance, Germanic (excluding English),
# Scandinavian, or Slavic languages.

init:
    pass

label hiragana:

    $ brew = renpy.input(u"ローマ字で名前を入力してください。\nEnter your name in romaji.")

    python:

        # -*- coding: utf-8 -*-

        # This is a program that would be able to change a string typed
        # in Roman letters into a string of kana.
        # It will later be appended to Ren'Py in order to further internationalize it.
        # Double vowels are converted thusly: "aa" ---> "ああ"

        # Weed out non-alphanumeric characters.

        l = list(brew) # The same string, converted into a list.

        n = "" # An empty string to put the newly-converted name.

        # A list of acceptable characters.
        accept = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
          "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
          "u", "v", "w", "x", "y", "z", "1", "2", "3", "4",
          "5", "6", "7", "8", "9", "0", "\'"]

        for letter in l: # On the first run, letter will be the first character in l. It will equal subsequent characters as the for-loop continues.
            if letter.lower() in accept: # The lowercase version of the variable letter is now checked against the list of acceptable characters.
                n += letter # Put a letter in variable n.

        brew = n # Replace the contents of s with the contents of n.
        n = "" # n is erased in case it is needed again.

        # Here are dictionaries for letters and their corresponding kana.

        # In the oneLetterHiragana dictionary, numerals are mapped to themselves.
        # This is so that the parsing code will include it and still convert letters to kana.

        oneLetterHiragana = {"a": u"あ", "i": u"い", "u": u"う", "e": u"え", "o": u"お",
                     "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6",
                     "7": "7", "8": "8", "9": "9", "0": "0"}

        twoLetterHiragana = {"ka": u"か", "ki": u"き", "ku": u"く", "ke": u"け", "ko": u"こ",
                 "sa": u"さ", "si": u"し", "su": u"す", "se": u"せ", "so": u"そ",
                 "ta": u"た", "ti": u"ち", "tu": u"つ", "te": u"て", "to": u"と",
                 "na": u"な", "ni": u"に", "nu": u"ぬ", "ne": u"ね", "no": u"の",
                 "ha": u"は", "hi": u"ひ", "hu": u"ふ", "he": u"へ", "ho": u"ほ",
                 "ma": u"ま", "mi": u"み", "mu": u"む", "me": u"め", "mo": u"も",
                 "ya": u"や", "yi": u"い", "yu": u"ゆ", "ye": u"いぇ", "yo": u"よ",
                 "ra": u"ら", "ri": u"り", "ru": u"る", "re": u"れ", "ro": u"ろ",
                 "wa": u"わ", "wi": u"うぃ", "wu": u"う", "we": u"うぇ", "wo": u"うぉ",
                 "la": u"ら", "li": u"り", "lu": u"る", "le": u"れ", "lo": u"ろ",
                 "fu": u"ふ",
                 "ga": u"が", "gi": u"ぎ", "gu": u"ぐ", "ge": u"げ", "go": u"ご",
                 "za": u"ざ", "zi": u"じ", "zu": u"ず", "ze": u"ぜ", "zo": u"ぞ",
                 "da": u"だ", "di": u"ぢ", "du": u"づ", "de": u"で", "do": u"ど",
                 "ba": u"ば", "bi": u"び", "bu": u"ぶ", "be": u"べ", "bo": u"ぼ",
                 "pa": u"ぱ", "pi": u"ぴ", "pu": u"ぷ", "pe": u"ぺ", "po": u"ぽ",
                 "ji": u"じ", "ju": u"じゅ", "n\'": u"ん"}

        threeLetterHiragana = {"shi": u"し", "chi": u"ち", "dzu": u"づ", "tsu": u"つ",
                   "kya": u"きゃ", "kyi": u"きぃ", "kyu": u"きゅ", "kye": u"きぇ", "kyo": u"きょ",
                   "sya": u"しゃ", "syi": u"しぃ", "syu": u"しゅ", "sye": u"しぇ", "syo": u"しょ",
                   "tya": u"ちゃ", "tyi": u"ちぃ", "tyu": u"ちゅ", "tye": u"ちぇ", "tyo": u"ちょ",
                   "nya": u"にゃ", "nyi": u"にぃ", "nyu": u"にゅ", "nye": u"にぇ", "nyo": u"にょ",
                   "hya": u"ひゃ", "hyi": u"ひぃ", "hyu": u"ひゅ", "hye": u"ひぇ", "hyo": u"ひょ",
                   "mya": u"みゃ", "myi": u"みぃ", "myu": u"みゅ", "mye": u"みぇ", "myo": u"みょ",
                   "rya": u"りゃ", "ryi": u"りぃ", "ryu": u"りゅ", "rye": u"りぇ", "ryo": u"りょ",
                   "gya": u"ぎゃ", "gyi": u"ぎぃ", "gyu": u"ぎゅ", "gye": u"ぎぇ", "gyo": u"ぎょ",
                   "zya": u"じゃ", "zyi": u"じぃ", "zyu": u"じゅ", "zye": u"じぇ", "zyo": u"じょ",
                   "dya": u"ぢゃ", "dyi": u"ぢぃ", "dyu": u"ぢゅ", "dye": u"ぢぇ", "dyo": u"ぢょ",
                   "bya": u"びゃ", "byi": u"びぃ", "byu": u"びゅ", "bye": u"びぇ", "byo": u"びょ",
                   "pya": u"ぴゃ", "pyi": u"ぴぃ", "pyu": u"ぴゅ", "pye": u"ぴぇ", "pyo": u"ぴょ",
                   "sha": u"しゃ", "shu": u"しゅ", "she": u"しぇ", "sho": u"しょ",
                   "cha": u"ちゃ", "chu": u"ちゅ", "che": u"ちぇ", "cho": u"ちょ",
                       "nka": u"んか", "nki": u"んき", "nku": u"んく", "nke": u"んけ", "nko": u"んこ",
                       "nsa": u"んさ", "nsi": u"んし", "nsu": u"んす", "nse": u"んせ", "nso": u"んそ",
                       "nta": u"んた", "nti": u"んち", "ntu": u"んつ", "nte": u"んて", "nto": u"んと",
                       "nna": u"んな", "nni": u"んに", "nnu": u"んぬ", "nne": u"んね", "nno": u"んの",
                       "nha": u"んは", "nhi": u"んひ", "nhu": u"んふ", "nhe": u"んへ", "nho": u"んほ",
                       "nma": u"んま", "nmi": u"んみ", "nmu": u"んむ", "nme": u"んめ", "nmo": u"んも",
                       "nra": u"んら", "nri": u"んり", "nru": u"んる", "nre": u"んれ", "nro": u"んろ",
                       "nwa": u"んわ", "nwi": u"んうぃ", "nwu": u"んう", "nwe": u"んうぇ", "nwo": u"んうぉ",
                       "nga": u"んが", "ngi": u"んぎ", "ngu": u"んぐ", "nge": u"んげ", "ngo": u"んご",
                       "nza": u"んざ", "nzi": u"んじ", "nzu": u"んず", "nze": u"んぜ", "nzo": u"んぞ",
                       "nda": u"んだ", "ndi": u"んぢ", "ndu": u"んづ", "nde": u"んで", "ndo": u"んど",
                       "nba": u"んば", "nbi": u"んび", "nbu": u"んぶ", "nbe": u"んべ", "nbo": u"んぼ",
                       "mba": u"んば", "mbi": u"んび", "mbu": u"んぶ", "mbe": u"んべ", "mbo": u"んぼ",
                       "npa": u"んぱ", "npi": u"んぴ", "npu": u"んぷ", "npe": u"んぺ", "npo": u"んぽ",
                       "mpa": u"んぱ", "mpi": u"んぴ", "mpu": u"んぷ", "mpe": u"んぺ", "mpo": u"んぽ",
                       "kka": u"っか", "kki": u"っき", "kku": u"っく", "kke": u"っけ", "kko": u"っこ",
                       "ssa": u"っさ", "ssi": u"っし", "ssu": u"っす", "sse": u"っせ", "sso": u"っそ",
                       "tta": u"った", "tti": u"っち", "ttu": u"っつ", "tte": u"って", "tto": u"っと",
                       "hha": u"っは", "hhi": u"っひ", "hhu": u"っふ", "hhe": u"っへ", "hho": u"っほ",
                       "mma": u"んま", "mmi": u"んみ", "mmu": u"んむ", "mme": u"んめ", "mmo": u"んも",
                       "rra": u"っら", "rri": u"っり", "rru": u"っる", "rre": u"っれ", "rro": u"っろ",
                       "wwa": u"っわ", "wwi": u"っうぃ", "wwu": u"っう", "wwe": u"っうぇ", "wwo": u"っうぉ",
                       "nja": u"んじゃ", "nji": u"んじ", "nju": u"んじゅ", "nje": u"んじぇ", "njo": u"んじょ",
                       "jja": u"っじゃ", "jji": u"っじ", "jju": u"っじゅ", "jje": u"っじぇ", "jjo": u"っじょ"}

        fourLetterHiragana = {"nshi": u"んし", "nchi": u"んち", "ndzu": u"んづ",
                   "nkya": u"んきゃ", "nkyi": u"んきぃ", "nkyu": u"んきゅ", "nkye": u"んきぇ", "nkyo": u"んきょ",
                   "nsya": u"んしゃ", "nsyi": u"んしぃ", "nsyu": u"んしゅ", "nsye": u"んしぇ", "nsyo": u"んしょ",
                   "ntya": u"んちゃ", "ntyi": u"んちぃ", "ntyu": u"んちゅ", "ntye": u"んちぇ", "ntyo": u"んちょ",
                   "nnya": u"んにゃ", "nnyi": u"んにぃ", "nnyu": u"んにゅ", "nnye": u"んにぇ", "nnyo": u"んにょ",
                   "nhya": u"んひゃ", "nhyi": u"んひぃ", "nhyu": u"んひゅ", "nhye": u"んひぇ", "nhyo": u"んひょ",
                   "nmya": u"んみゃ", "nmyi": u"んみぃ", "nmyu": u"んみゅ", "nmye": u"んみぇ", "nmyo": u"んみょ",
                   "nrya": u"んりゃ", "nryi": u"んりぃ", "nryu": u"んりゅ", "nrye": u"んりぇ", "nryo": u"んりょ",
                   "ngya": u"んぎゃ", "ngyi": u"んぎぃ", "ngyu": u"んぎゅ", "ngye": u"んぎぇ", "ngyo": u"んぎょ",
                   "nzya": u"んじゃ", "nzyi": u"んじぃ", "nzyu": u"んじゅ", "nzye": u"んじぇ", "nzyo": u"んじょ",
                   "ndya": u"んぢゃ", "ndyi": u"んぢぃ", "ndyu": u"んぢゅ", "ndye": u"んぢぇ", "ndyo": u"んぢょ",
                   "nbya": u"んびゃ", "nbyi": u"んびぃ", "nbyu": u"んびゅ", "nbye": u"んびぇ", "nbyo": u"んびょ",
                   "npya": u"んぴゃ", "npyi": u"んぴぃ", "npyu": u"んぴゅ", "npye": u"んぴぇ", "npyo": u"んぴょ",
                   "nsha": u"んしゃ", "nshu": u"んしゅ", "nshe": u"んしぇ", "nsho": u"んしょ",
                   "ncha": u"んちゃ", "nchu": u"んちゅ", "nche": u"んちぇ", "ncho": u"んちょ",
                       "sshi": u"っし", "cchi": u"っち", "ddzu": u"っづ",
                   "kkya": u"っきゃ", "kkyi": u"っきぃ", "kkyu": u"っきゅ", "kkye": u"っきぇ", "kkyo": u"っきょ",
                   "ssya": u"っしゃ", "ssyi": u"っしぃ", "ssyu": u"っしゅ", "ssye": u"っしぇ", "ssyo": u"っしょ",
                   "ttya": u"っちゃ", "ttyi": u"っちぃ", "ttyu": u"っちゅ", "ttye": u"っちぇ", "ttyo": u"っちょ",
                   "hhya": u"っひゃ", "hhyi": u"っひぃ", "hhyu": u"っひゅ", "hhye": u"っひぇ", "hhyo": u"っひょ",
                   "mmya": u"んみゃ", "mmyi": u"んみぃ", "mmyu": u"んみゅ", "mmye": u"んみぇ", "mmyo": u"んみょ",
                   "rrya": u"っりゃ", "rryi": u"っりぃ", "rryu": u"っりゅ", "rrye": u"っりぇ", "rryo": u"っりょ",
                   "ggya": u"っぎゃ", "ggyi": u"っぎぃ", "ggyu": u"っぎゅ", "ggye": u"っぎぇ", "ggyo": u"っぎょ",
                   "zzya": u"っじゃ", "zzyi": u"っじぃ", "zzyu": u"っじゅ", "zzye": u"っじぇ", "zzyo": u"っじょ",
                   "ddya": u"っぢゃ", "ddyi": u"っぢぃ", "ddyu": u"っぢゅ", "ddye": u"っぢぇ", "ddyo": u"っぢょ",
                   "bbya": u"っびゃ", "bbyi": u"っびぃ", "bbyu": u"っびゅ", "bbye": u"っびぇ", "bbyo": u"っびょ",
                   "ppya": u"っぴゃ", "ppyi": u"っぴぃ", "ppyu": u"っぴゅ", "ppye": u"っぴぇ", "ppyo": u"っぴょ",
                   "ssha": u"っしゃ", "sshu": u"っしゅ", "sshe": u"っしぇ", "ssho": u"っしょ",
                   "ccha": u"っちゃ", "cchu": u"っちゅ", "cche": u"っちぇ", "ccho": u"っちょ"}

        while brew != "": # The parsing will continue until the string is empty.

            if brew[:1].lower() in oneLetterHiragana: # Check the letter against the one-letter dictionary.
                n += oneLetterHiragana[brew[:1].lower()] # Add the corresponding kana to n.
                brew = brew[1:] # Remove the letters from s.

            elif brew.lower() == "n": # This parses "n" when it is by itself.
                n += u"ん"
                brew = brew[1:]

            elif brew[:2].lower() in twoLetterHiragana: # Check the letters against the two-letter dictionary.
                n += twoLetterHiragana[brew[:2].lower()] # Add the corresponding kana to n.
                brew = brew[2:] # Remove the letters from brew.

            elif brew[:3].lower() in threeLetterHiragana: # Check the letters against the three-letter dictionary.
                n += threeLetterHiragana[brew[:3].lower()] # Add the corresponding kana to n.
                brew = brew[3:] # Remove the letters from brew.

            elif brew[:4].lower() in fourLetterHiragana: # Check the letters against the four-letter dictionary.
                n += fourLetterHiragana[brew[:4].lower()] # Add the corresponding kana to n.
                brew = brew[4:] # Remove the letters from brew.

            else: # Simply use the unconvertable string as-is.
                n += brew[:4].lower()
                brew = brew[4:]

        brew = n

    # Kick the Python variable back out to Ren'Py so it could be displayed properly.
    $ whatt = brew

    return



Katakana Version, no dashes:

# Ren'Py Kana Converter v1.0 (Katakana, no dashes)
# Originally programmed by Ivlivs from the Lemmasoft Forums.
#
# For a long time, renpy.input() was limited to not only Roman
# letters, but those used in the English language. Officially, it still is,
# but the following code offers a powerful workaround.
#
# Allowing the input of kanji into Ren'Py through the input is possible
# but horrendously impractical as of now, so I did the next best
# thing: I made a kana converter, since kana proper nouns are
# perfectly legitimate in the Japanese language.
#
# This code is open-source. Feel free to modify it, so long as you
# credit me.
#
# NOTE: Converters can be made for other left-to-right non-ligature
# alphabets, like those used in the Romance, Germanic (excluding English),
# Scandinavian, or Slavic languages.

init:
    pass

label katakana:

    $ brew = renpy.input(u"ローマ字で名前を入力してください。\nEnter your name in romaji.")

    python:

        # -*- coding: utf-8 -*-

        # This is a program that would be able to change a string typed
        # in Roman letters into a string of kana.
        # It will later be appended to Ren'Py in order to further internationalize it.
        # Double vowels are converted thusly: "aa" ---> "アア"

        # Weed out non-alphanumeric characters.

        l = list(brew) # The same string, converted into a list.

        n = "" # An empty string to put the newly-converted name.

        # A list of acceptable characters.
        accept = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
          "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
          "u", "v", "w", "x", "y", "z", "1", "2", "3", "4",
          "5", "6", "7", "8", "9", "0", "\'"]

        for letter in l: # On the first run, letter will be the first character in l. It will equal subsequent characters as the for-loop continues.
            if letter.lower() in accept: # The lowercase version of the variable letter is now checked against the list of acceptable characters.
                n += letter # Put a letter in variable n.

        brew = n # Replace the contents of s with the contents of n.
        n = "" # n is erased in case it is needed again.

        # Here are dictionaries for letters and their corresponding kana.

        # In the oneLetterHiragana dictionary, numerals are mapped to themselves.
        # This is so that the parsing code will include it and still convert letters to kana.

        oneLetterKatakana = {"a": u"ア", "i": u"イ", "u": u"ウ", "e": u"エ", "o": u"オ",
                     "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6",
                     "7": "7", "8": "8", "9": "9", "0": "0"}

        twoLetterKatakana = {"ka": u"カ", "ki": u"キ", "ku": u"ク", "ke": u"ケ", "ko": u"コ",
                 "sa": u"サ", "si": u"シ", "su": u"ス", "se": u"セ", "so": u"ソ",
                 "ta": u"タ", "ti": u"チ", "tu": u"ツ", "te": u"テ", "to": u"ト",
                 "na": u"ナ", "ni": u"ニ", "nu": u"ヌ", "ne": u"ネ", "no": u"ノ",
                 "ha": u"ハ", "hi": u"ヒ", "hu": u"フ", "he": u"ヘ", "ho": u"ホ",
                 "ma": u"マ", "mi": u"ミ", "mu": u"ム", "me": u"メ", "mo": u"モ",
                 "ya": u"や", "yi": u"イー", "yu": u"ユ", "ye": u"イェ", "yo": u"ヨ",
                 "ra": u"ラ", "ri": u"リ", "ru": u"ル", "re": u"レ", "ro": u"ロ",
                 "wa": u"わ", "wi": u"ウィ", "wu": u"ウ", "we": u"ウェ", "wo": u"ウォ",
                 "la": u"ラ", "li": u"リ", "lu": u"ル", "le": u"レ", "lo": u"ロ",
                 "fu": u"フ",
                 "ga": u"ガ", "gi": u"ギ", "gu": u"グ", "ge": u"ゲ", "go": u"ゴ",
                 "za": u"ザ", "zi": u"ジ", "zu": u"ズ", "ze": u"ゼ", "zo": u"ゾ",
                 "da": u"ダ", "di": u"ヂ", "du": u"ヅ", "de": u"デ", "do": u"ド",
                 "ba": u"バ", "bi": u"ビ", "bu": u"ブ", "be": u"ベ", "bo": u"ボ",
                 "pa": u"パ", "pi": u"ピ", "pu": u"プ", "pe": u"ペ", "po": u"ポ",
                 "ji": u"ジ", "ju": u"ジュ", "n\'": u"ン"}

        threeLetterKatakana = {"shi": u"シ", "chi": u"チ", "dzu": u"ヅ", "tsu": "ツ",
                   "kya": u"キャ", "kyi": u"キィ", "kyu": u"キュ", "kye": u"キェ", "kyo": u"キョ",
                   "sya": u"シャ", "syi": u"シィ", "syu": u"シュ", "sye": u"シェ", "syo": u"ショ",
                   "tya": u"チャ", "tyi": u"チィ", "tyu": u"チュ", "tye": u"チェ", "tyo": u"チョ",
                   "nya": u"ニャ", "nyi": u"ニィ", "nyu": u"ニュ", "nye": u"ニェ", "nyo": u"ニョ",
                   "hya": u"ヒャ", "hyi": u"ヒィ", "hyu": u"ヒュ", "hye": u"ヒェ", "hyo": u"ヒョ",
                   "mya": u"ミャ", "myi": u"ミィ", "myu": u"ミュ", "mye": u"ミェ", "myo": u"ミョ",
                   "rya": u"リャ", "ryi": u"リィ", "ryu": u"リュ", "rye": u"リェ", "ryo": u"リョ",
                   "gya": u"ギャ", "gyi": u"ギィ", "gyu": u"ギュ", "gye": u"ギェ", "gyo": u"ギョ",
                   "zya": u"ジャ", "zyi": u"ジィ", "zyu": u"ジュ", "zye": u"ジェ", "zyo": u"ジョ",
                   "dya": u"ヂャ", "dyi": u"ヂィ", "dyu": u"ヂュ", "dye": u"ヂェ", "dyo": u"ヂョ",
                   "bya": u"ビャ", "byi": u"ビィ", "byu": u"ビュ", "bye": u"ビェ", "byo": u"ビョ",
                   "pya": u"ピャ", "pyi": u"ピィ", "pyu": u"ピュ", "pye": u"ピェ", "pyo": u"ピョ",
                   "sha": u"シャ", "shu": u"シュ", "she": u"シェ", "sho": u"ショ",
                   "cha": u"チャ", "chu": u"チュ", "che": u"チェ", "cho": u"チョ",
                       "nka": u"ンカ", "nki": u"ンキ", "nku": u"ンク", "nke": u"ンケ", "nko": u"ンコ",
                       "nsa": u"ンサ", "nsi": u"ンシ", "nsu": u"ンす", "nse": u"ンセ", "nso": u"ンソ",
                       "nta": u"ンタ", "nti": u"ンチ", "ntu": u"ンつ", "nte": u"ンて", "nto": u"ンと",
                       "nna": u"ンナ", "nni": u"ンニ", "nnu": u"ンヌ", "nne": u"ンネ", "nno": u"ンノ",
                       "nha": u"ンハ", "nhi": u"ンヒ", "nhu": u"ンフ", "nhe": u"ンヘ", "nho": u"ンホ",
                       "nma": u"ンマ", "nmi": u"ンミ", "nmu": u"ンム", "nme": u"ンメ", "nmo": u"ンモ",
                       "nra": u"ンラ", "nri": u"ンリ", "nru": u"ンル", "nre": u"ンレ", "nro": u"ンロ",
                       "nwa": u"ンわ", "nwi": u"ンウィ", "nwu": u"ンウ", "nwe": u"ンウェ", "nwo": u"ンウォ",
                       "nga": u"ンガ", "ngi": u"ンギ", "ngu": u"ング", "nge": u"ンゲ", "ngo": u"ンゴ",
                       "nza": u"ンザ", "nzi": u"ンジ", "nzu": u"ンズ", "nze": u"ンゼ", "nzo": u"ンゾ",
                       "nda": u"ンダ", "ndi": u"ンヂ", "ndu": u"ンヅ", "nde": u"ンデ", "ndo": u"ンド",
                       "nba": u"ンバ", "nbi": u"ンビ", "nbu": u"ンブ", "nbe": u"ンベ", "nbo": u"ンボ",
                       "mba": u"ンバ", "mbi": u"ンビ", "mbu": u"ンブ", "mbe": u"ンベ", "mbo": u"ンボ",
                       "npa": u"ンパ", "npi": u"ンピ", "npu": u"ンプ", "npe": u"ンペ", "npo": u"ンポ",
                       "mpa": u"ンパ", "mpi": u"ンピ", "mpu": u"ンプ", "mpe": u"ンペ", "mpo": u"ンポ",
                       "kka": u"ッカ", "kki": u"ッキ", "kku": u"ック", "kke": u"ッケ", "kko": u"ッコ",
                       "ssa": u"ッサ", "ssi": u"ッシ", "ssu": u"ッす", "sse": u"ッセ", "sso": u"ッソ",
                       "tta": u"ッタ", "tti": u"ッチ", "ttu": u"ッつ", "tte": u"ッて", "tto": u"ット",
                       "hha": u"ッハ", "hhi": u"ッヒ", "hhu": u"ッフ", "hhe": u"ッヘ", "hho": u"ッホ",
                       "mma": u"ンマ", "mmi": u"ンミ", "mmu": u"ンム", "mme": u"ンメ", "mmo": u"ンモ",
                       "rra": u"ッラ", "rri": u"ッリ", "rru": u"ッル", "rre": u"ッレ", "rro": u"ッロ",
                       "wwa": u"ッわ", "wwi": u"ッウィ", "wwu": u"ッウ", "wwe": u"ッウェ", "wwo": u"ッウォ",
                       "nja": u"ンジャ", "nji": u"ンジ", "nju": u"ンジュ", "nje": u"ンジェ", "njo": u"ンジョ",
                       "jja": u"ッジャ", "jji": u"ッジ", "jju": u"ッジュ", "jje": u"ッジェ", "jjo": u"ッジョ"}

        fourLetterKatakana = {"nshi": u"ンシ", "nchi": u"ンチ", "ndzu": u"ンヅ",
                   "nkya": u"ンキャ", "nkyi": u"ンキィ", "nkyu": u"ンキュ", "nkye": u"ンキェ", "nkyo": u"ンキョ",
                   "nsya": u"ンシャ", "nsyi": u"ンシィ", "nsyu": u"ンシュ", "nsye": u"ンシェ", "nsyo": u"ンショ",
                   "ntya": u"ンチャ", "ntyi": u"ンチィ", "ntyu": u"ンチュ", "ntye": u"ンチェ", "ntyo": u"ンチョ",
                   "nnya": u"ンニャ", "nnyi": u"ンニィ", "nnyu": u"ンニュ", "nnye": u"ンニェ", "nnyo": u"ンニョ",
                   "nhya": u"ンヒャ", "nhyi": u"ンヒィ", "nhyu": u"ンヒュ", "nhye": u"ンヒェ", "nhyo": u"ンヒョ",
                   "nmya": u"ンミャ", "nmyi": u"ンミィ", "nmyu": u"ンミュ", "nmye": u"ンミェ", "nmyo": u"ンミョ",
                   "nrya": u"ンリャ", "nryi": u"ンリィ", "nryu": u"ンリュ", "nrye": u"ンリェ", "nryo": u"ンリョ",
                   "ngya": u"ンギャ", "ngyi": u"ンギィ", "ngyu": u"ンギュ", "ngye": u"ンギェ", "ngyo": u"ンギョ",
                   "nzya": u"ンジャ", "nzyi": u"ンジィ", "nzyu": u"ンジュ", "nzye": u"ンジェ", "nzyo": u"ンジョ",
                   "ndya": u"ンヂャ", "ndyi": u"ンヂィ", "ndyu": u"ンヂュ", "ndye": u"ンヂェ", "ndyo": u"ンヂョ",
                   "nbya": u"ンビャ", "nbyi": u"ンビィ", "nbyu": u"ンビュ", "nbye": u"ンビェ", "nbyo": u"ンビョ",
                   "npya": u"ンピャ", "npyi": u"ンピィ", "npyu": u"ンピュ", "npye": u"ンピェ", "npyo": u"ンピョ",
                   "nsha": u"ンシャ", "nshu": u"ンシュ", "nshe": u"ンシェ", "nsho": u"ンショ",
                   "ncha": u"ンチャ", "nchu": u"ンチュ", "nche": u"ンチェ", "ncho": u"ンチョ",
                       "sshi": u"ッシ", "cchi": u"ッチ", "ddzu": u"ッヅ",
                   "kkya": u"ッキャ", "kkyi": u"ッキィ", "kkyu": u"ッキュ", "kkye": u"ッキェ", "kkyo": u"ッキョ",
                   "ssya": u"ッシャ", "ssyi": u"ッシィ", "ssyu": u"ッシュ", "ssye": u"ッシェ", "ssyo": u"ッショ",
                   "ttya": u"ッチャ", "ttyi": u"ッチィ", "ttyu": u"ッチュ", "ttye": u"ッチェ", "ttyo": u"ッチョ",
                   "hhya": u"ッヒャ", "hhyi": u"ッヒィ", "hhyu": u"ッヒュ", "hhye": u"ッヒェ", "hhyo": u"ッヒョ",
                   "mmya": u"ンミャ", "mmyi": u"ンミィ", "mmyu": u"ンミュ", "mmye": u"ンミェ", "mmyo": u"ンミョ",
                   "rrya": u"ッリャ", "rryi": u"ッリィ", "rryu": u"ッリュ", "rrye": u"ッリェ", "rryo": u"ッリョ",
                   "ggya": u"ッギャ", "ggyi": u"ッギィ", "ggyu": u"ッギュ", "ggye": u"ッギェ", "ggyo": u"ッギョ",
                   "zzya": u"ッジャ", "zzyi": u"ッジィ", "zzyu": u"ッジュ", "zzye": u"ッジェ", "zzyo": u"ッジョ",
                   "ddya": u"ッヂャ", "ddyi": u"ッヂィ", "ddyu": u"ッヂュ", "ddye": u"ッヂェ", "ddyo": u"ッヂョ",
                   "bbya": u"ッビャ", "bbyi": u"ッビィ", "bbyu": u"ッビュ", "bbye": u"ッビェ", "bbyo": u"ッビョ",
                   "ppya": u"ッピャ", "ppyi": u"ッピィ", "ppyu": u"ッピュ", "ppye": u"ッピェ", "ppyo": u"ッピョ",
                   "ssha": u"ッシャ", "sshu": u"ッシュ", "sshe": u"ッシェ", "ssho": u"ッショ",
                   "ccha": u"ッチャ", "cchu": u"ッチュ", "cche": u"ッチェ", "ccho": u"ッチョ"}

        while brew != "": # The parsing will continue until the string is empty.

            if brew[:1].lower() in oneLetterKatakana: # Check the letter against the one-letter dictionary.
                n += oneLetterKatakana[brew[:1].lower()] # Add the corresponding kana to n.
                brew = brew[1:] # Remove the letters from s.

            elif brew.lower() == "n": # This parses "n" when it is by itself.
                n += u"ン"
                brew = brew[1:]

            elif brew[:2].lower() in twoLetterKatakana: # Check the letters against the two-letter dictionary.
                n += twoLetterKatakana[brew[:2].lower()] # Add the corresponding kana to n.
                brew = brew[2:] # Remove the letters from brew.

            elif brew[:3].lower() in threeLetterKatakana: # Check the letters against the three-letter dictionary.
                n += threeLetterKatakana[brew[:3].lower()] # Add the corresponding kana to n.
                brew = brew[3:] # Remove the letters from brew.

            elif brew[:4].lower() in fourLetterKatakana: # Check the letters against the four-letter dictionary.
                n += fourLetterKatakana[brew[:4].lower()] # Add the corresponding kana to n.
                brew = brew[4:] # Remove the letters from brew.

            else: # Simply use the unconvertable string as-is.
                n += brew[:4].lower()
                brew = brew[4:]

        brew = n

    # Kick the Python variable back out to Ren'Py so it could be displayed properly.
    $ whatt = brew

    return


Katakana Version (dashes):

# Ren'Py Kana Converter v1.0 (Katakana, dashes)
# Originally programmed by Ivlivs from the Lemmasoft Forums.
#
# For a long time, renpy.input() was limited to not only Roman
# letters, but those used in the English language. Officially, it still is,
# but the following code offers a powerful workaround.
#
# Allowing the input of kanji into Ren'Py through the input is possible
# but horrendously impractical as of now, so I did the next best
# thing: I made a kana converter, since kana proper nouns are
# perfectly legitimate in the Japanese language.
#
# This code is open-source. Feel free to modify it, so long as you
# credit me.