none
Translate from Japanese to Romaji

    Question

  • I need to write C# program that translate from Japanese to Romaji. I have installed Microsoft Visual Studio International Pack v.1.0 and 2.0.

    However, it has only conversion from Romaji to Japanese. Please let me know what else I can use to be able to translate from Japanese to Romaji.

    Thank you,

    KlimG

    Thursday, August 09, 2012 2:35 PM

All replies

  • For translations, I have used in the past the google api shown below that I access through a webpage.  The webpage code shown below is in VBA but can be easily translated to C#.  the getElementById() method can be accessed through an XML document class().

    --------------------------------------------------------------------------------------------------------------

    HTML Code - Can be put into a file

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Google Translate API</title>
    </head>
    <body>
    <form name="f" id="f" action="#" onsubmit="translate(); return false;">
    <textarea name="foreign_text" id="foreign_text" rows="4"
    cols="60"></textarea>
    <br />
    <br />
    <input type="submit" id="submit_button" value="Translate into English"
    onfocus="this.blur();" />
    <br />
    <br />
    <textarea name="translation" id="translation" rows="4" cols="60"
    onfocus="this.select();" readonly="true"></textarea></form>
    <br />
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("language", "1");
    function translate() {var
    originaltext=document.forms["f"].foreign_text.value;
    google.language.translate(originaltext, "", "en", function(result) {
    document.forms["f"].translation.value = (result.error)?("Error:
    "+result.error.message):result.translation; }); }
    </script>
    </body>
    </html>

    -----------------------------------------------------------------------------------------------------------

    VBA Code

    Sub translate()

    Dim objIE As Object
    Dim strServAcct As String

    URL = "c:\temp\working\translation.html"
    'Open Internet Explorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate URL

    Do While IE.Busy = True Or IE.readystate <> 4
    DoEvents
    Loop

    Set ForeignCells = Range("A1:B1")
    For Each cell In ForeignCells
    Set ForeignText = IE.document.getElementById("foreign_text")
    Set submit = IE.document.getElementById("submit_button")

    ForeignText.innertext = cell.Value
    submit.Select
    submit.Click
    Do While IE.Busy = True Or IE.readystate <> 4
    DoEvents
    Loop
    Set Translation = IE.document.getElementById("Translation")
    Translation.innertext = cell.Offset(1, 0).Value
    Next cell
    End Sub

     


    jdweng

    • Proposed as answer by Mike FengModerator Friday, August 10, 2012 11:30 AM
    • Marked as answer by Mike FengModerator Thursday, August 16, 2012 9:41 AM
    • Unmarked as answer by KlimG Thursday, September 06, 2012 7:37 PM
    • Unproposed as answer by KlimG Thursday, September 06, 2012 8:26 PM
    Thursday, August 09, 2012 3:28 PM
  • Thank you for your response. I am not an expert in the field but your program never can translate for example any Japanese word like 助けて (Help) into Romaji "tasuke te" ? This translated word "tasuke te" is what I need. Looks like your program translate in English only. If I am wrong how your program reads Kanji, Hiragana or Katakana characters or where in your program it takes place. Also, I think I can't use Google API because Romaji is not supported language ( see http://support.google.com/translate/toolkit/bin/answer.py?hl=en&answer=147837). Please let me know.


    KlimG



    • Edited by KlimG Thursday, September 06, 2012 7:47 PM
    Thursday, September 06, 2012 7:28 PM
  • The code I provided can use any of the Google Api languages.  I just gae an example that I had working.  The function below deterines the languages

    function translate() {var
    originaltext=document.forms["f"].foreign_text.value;
    google.language.translate(originaltext, "", "en", function(result) {
    document.forms["f"].translation.value = (result.error)?("Error:
    "+result.error.message):result.translation; }); }

    It will automatically determine the originating language.  I think you are correct that Google doesn't handle Romaji .  My program is simple an interface to the Google API.  Instead of typing characters into the Google webpage you can bypass the webpage and send a stream directly to the API.


    jdweng

    Thursday, September 06, 2012 10:46 PM
  • Hi KlimG,

    Complete code is given here. Please have a look at it once:

    http://www.codeproject.com/Articles/87444/Convert-Japanese-string-to-Romaji


    Regards, http://www.shwetalodha.blogspot.in/

    Friday, September 07, 2012 3:31 AM
  • Hi, Shweta/ Joel

    I found this example a while ago. However, if read it carefully this example covers Hiragana and Katakana only. That's why there are only two .pdf files attached. This example uses simple look up algorithm. I have created similar to this example and it works perfect for Hiragana and Katakana. There are only several hundreds of characters are required. What the author of the article forgot to tell that Kanji uses around 15,000 characters that have very complicated spelling. If Hiragana and Katakana use always one tranlation for the character Kanji always use many. If you take Kanji character  which means "rest" there are five possible translation for it: Yasumu, Ikou, Yameru, Kyuu, Ku. Which one I should take? Look at this link: http://www.isthisthingon.org/unicode/?page=03&subpage=0

    So, looks like the author of the article you have referenced stopped exactly in the same place where I am now.

    Thanks for your response.

    KlimG

    Friday, September 07, 2012 8:33 PM