Search code examples
javagwtlocalizationvaadincustom-widgets

Vaadin and custom Gwt Widget - setting language for widget


We have a vaadin application and custom gwt widget included as external jar. Widget has its own translations (polish and english). The problem is, when running custom widget in external app, it does translate properly, but when it is inside a vaadin application, regardless the application (and even browser) locale - it is only in english, all the time.

Question is, how gwt custom widgets obtain information about language to use and is there any option to override this (force widget language/locale)?


Solution

  • One of the problem was locale name mismatch. Where vaadin application was able to be translated ony for language-tag locale. e.g. "pl" (polish),gwt widget needed locale with country code e.g. "pl_PL" (polish, Poland).

    The actual solution was to force gwt to search for locale in meta tag only and create this tag

    <meta name="gwt:property" content="locale=x_X" />
    

    on server side, respecting application language and before any gwt javascripts are attached. Unfortunately, this leads to refreshing page after language change, but I guess it cannot be done any other way due to gwt internationalization methods.