Example usage for com.google.gwt.language.client.translation Translation detect

List of usage examples for com.google.gwt.language.client.translation Translation detect

Introduction

In this page you can find the example usage for com.google.gwt.language.client.translation Translation detect.

Prototype

public static native void detect(String text, LangDetCallback callback) ;

Source Link

Document

A global method that will return the language code that describes the language of the given text.

Usage

From source file:com.google.gwt.language.sample.hellolanguage.client.LanguageDetectionDemo.java

License:Apache License

/**
 * Creates a "Detect" button to do language detection.
 *
 * @return button/*w  w  w  . j a  va2  s. com*/
 */
private Button createLanguageDetectionButton() {
    Button langDetButton = new Button("Detect");
    langDetButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Translation.detect(inputTextArea.getText(), new LangDetCallback() {
                @Override
                protected void onCallback(LangDetResult result) {
                    outputDiv.setText("Detected language: " + result.getLanguage() + ", Confidence: "
                            + result.confidence());
                }
            });
        }
    });
    return langDetButton;
}