2

Maybe this question was asked but I couldn't find. I am new to Vaadin. And how can I set default locale for Vaadin application.

tuazku
  • 129
  • 1
  • 3
  • 17
  • may be this can help: http://stackoverflow.com/questions/9023460/changing-application-locale-makes-changes-to-all-users-vaadin – Unni Kris May 02 '13 at 05:49

1 Answers1

6

Vaadin 6 : Application#setLocale(Locale)

Vaadin 7 : VaadinSession#setLocale(Locale) e.g. VaadinSession.getCurrent().setLocale();

Example code for Vaadin 7, as might be used in the init method of UI.

Locale locale = Locale.CANADA_FRENCH;
this.setLocale( locale ); // Call to affect this current UI. Workaround for bug/issue: http://dev.vaadin.com/ticket/12350
this.getSession().setLocale( locale ); // Affects only future UI instances, not current one. See workaround in line above.
// VaadinSession.getCurrent().setLocale( locale ); // Alternative to "this.getSession".
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Charles Anthony
  • 3,155
  • 17
  • 21
  • This answer inspired me to expand the Vaadin Wiki page on this topic: [Remember to the set the Locale](https://vaadin.com/wiki/-/wiki/Main/Remember+to+the+set+the+Locale). I added example code and some discussion. – Basil Bourque Jul 28 '14 at 00:34
  • Note that Vaadin 7 has a **serious design issue** (or bug) ([ticket # 12350](http://dev.vaadin.com/ticket/12350)) where setting locale on VaadinSession does not take proper effect in the already existing UI object(s). The workaround is simple: [a] call `setLocale` on the current UI(s) to affect them, as well as [b] calling `setLocale` on the VaadinSession to affect future UI objects. See the wiki link in my comment above for discussion and example app. – Basil Bourque Jul 28 '14 at 01:55