Example usage for com.google.gwt.language.client LanguageUtils loadTranslation

List of usage examples for com.google.gwt.language.client LanguageUtils loadTranslation

Introduction

In this page you can find the example usage for com.google.gwt.language.client LanguageUtils loadTranslation.

Prototype

public static void loadTranslation(Runnable onLoad) 

Source Link

Document

Call this method to load the Translation API before using any API methods.

Usage

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

License:Apache License

/**
 * The onModuleLoad() method is called when the body of the document is
 * finished loading. The JavaScript APIs are not loaded unless they were
 * included in the body of the .html file. Use the LanguageUtils.loadXXX()
 * methods to load them after the app starts, but before any API calls are
 * made./*from  ww w .  jav  a2s  .  c  o m*/
 */
public void onModuleLoad() {

    final TabPanel demoTabPanel = new TabPanel();
    demoTabPanel.getDeckPanel().setPixelSize(Window.getClientWidth() - 30, DEMO_PANEL_HEIGHT);
    RootPanel.get().add(demoTabPanel);

    Window.addResizeHandler(new ResizeHandler() {
        public void onResize(ResizeEvent event) {
            demoTabPanel.getDeckPanel().setPixelSize(Window.getClientWidth() - 30, DEMO_PANEL_HEIGHT);
        }
    });

    final VerticalPanel transDemoPanel = new VerticalPanel();
    transDemoPanel.add(loadingLabel());

    final VerticalPanel langDetectDemoPanel = new VerticalPanel();
    langDetectDemoPanel.add(loadingLabel());

    final VerticalPanel translitDemoPanel = new VerticalPanel();
    translitDemoPanel.add(loadingLabel());

    demoTabPanel.add(transDemoPanel, "Translation demo");
    demoTabPanel.add(langDetectDemoPanel, "Language detection demo");
    demoTabPanel.add(translitDemoPanel, "Transliteration demo");
    demoTabPanel.selectTab(0);

    LanguageUtils.loadTranslation(new Runnable() {
        public void run() {
            transDemoPanel.clear();
            transDemoPanel.add(new TranslationDemo());

            langDetectDemoPanel.clear();
            langDetectDemoPanel.add(new LanguageDetectionDemo());
        }
    });

    LanguageUtils.loadTransliteration(new Runnable() {
        public void run() {
            translitDemoPanel.clear();
            TransliterationDemo translitDemo = new TransliterationDemo();
            translitDemoPanel.add(translitDemo);
        }
    });
}