Export (0) Print
Expand All

GetAutoDetectedLanguage Method

The Widget can auto-detect the language of the page – this method returns a string containing the last automatically-detected language.

Syntax


Microsoft.Translator.Widget.GetAutoDetectedLanguage();
						

Parameters

none

Returns

A string containing the last Auto-detected Language Code. This method needs to be called after at least one Translate call has been issued with 'from' input parameter set to null or empty string. Otherwise, returns null.


Dn341977.alert_note(en-us,MSDN.10).gif Note

This method should be used after the first onProgress callback as the detected language will be be known only by then.


Example



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Microsoft Widget API Sample</title>
    <script src="http://microsofttranslator.com/ajax/v3/widgetv3.ashx" type="text/javascript"></script>
    <script type="text/javascript" defer="defer">
        document.onreadystatechange = function () {
            if (document.readyState == 'complete') {
                Microsoft.Translator.Widget.Translate(null, 'en', null, null, function () {
                    alert('Detected Language Code: ' + Microsoft.Translator.Widget.GetAutoDetectedLanguage());
                });
            }
        }
        //You can use Microsoft.Translator.Widget.GetLanguagesForTranslate to map the language code with the language name
    </script>
</head>
<body>
    <div>
        Este es el texto de los bloques de prueba.
    </div>
</body>
</html>
						

Show:
© 2014 Microsoft