【问题标题】:How to translate text from English to German如何将文本从英语翻译成德语
【发布时间】:2018-05-09 03:51:38
【问题描述】:

我想将文本从英语翻译成德语。音译只是从英语翻译成除德语以外的另一种语言。如何从英语翻译成德语?

这是我正在使用的代码:

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="https://www.google.com/jsapi">
    </script>
    <script type="text/javascript">
        // Load the Google Transliterate API
        google.load("elements", "1", {
            packages: "transliteration"
        });

        function onLoad() {
            var options = {
                sourceLanguage: 'en',
                destinationLanguage: ['hi', 'kn', 'ml', 'ta', 'te'],
                shortcutKey: 'ctrl+g',
                transliterationEnabled: true
            };

            // Create an instance on TransliterationControl with the required
            // options.
            var control =
                new google.elements.transliteration.TransliterationControl(options);

            // Enable transliteration in the textfields with the given ids.
            var ids = ["transl1", "transl2"];
            control.makeTransliteratable(ids);

            // Show the transliteration control which can be used to toggle between
            // English and Hindi and also choose other destination language.
            control.showControl('translControl');
        }
        google.setOnLoadCallback(onLoad);
    </script>
</head>

<body>
    <center>Type in Indian languages (Press Ctrl+g to toggle between English and Hindi)</center>
    <div id='translControl'></div>
    <br>Title : <input type='textbox' id="transl1" />
    <br>Body<br><textarea id="transl2" style="width:600px;height:200px"></textarea>
</body>

</html>

【问题讨论】:

    标签: javascript jquery language-translation google-translator-toolkit translators


    【解决方案1】:

    这是正确的代码:

    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            // Load the Google Transliterate API
            google.load("elements", "1", {
                packages: "transliteration"
            });
    
            function onLoad() {
                var options = {
                    sourceLanguage: 'en',
                    destinationLanguage: ['hi', 'kn', 'ml', 'ta', 'te'],
                    shortcutKey: 'ctrl+g',
                    transliterationEnabled: true
                };
    
                // Create an instance on TransliterationControl with the required
                // options.
                var control =
                    new
                google.elements.transliteration.TransliterationControl(options);
    
                // Enable transliteration in the textfields with the given ids.
                var ids = ["transl1", "transl2"];
                control.makeTransliteratable(ids);
    
                // Show the transliteration control which can be used to toggle 
                between
                // English and Hindi and also choose other destination language.
                control.showControl('translControl');
            }
            google.setOnLoadCallback(onLoad);
        </script>
    </head>
    <body>
        <!-- <center>Type in Indian languages (Press Ctrl+g to toggle between English and Hindi)</center> -->
        <div id='translControl'></div>
        <br />Title:
        <input type='textbox' id="transl1" />
        <br />Body
        <br />
        <textarea id="transl2" style="width:600px;height:200px"></textarea>
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 2019-09-12
      • 1970-01-01
      • 1970-01-01
      • 2013-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多