@Override public Locale getLocale() { if (locale != null) { return locale; } HasComponents parent = getParent(); if (parent != null) { return parent.getLocale(); } final VaadinSession session = getSession(); if (session != null) { return session.getLocale(); } return null; }
Locale locale = session.getLocale(); if (locale != null) { return locale;
public String getMessage(String code) { Locale locale = VaadinSession.getCurrent().getLocale(); return messageSource.getMessage(code, null, locale); }
public String getMessage(String code, String defaultMessage) { Locale locale = VaadinSession.getCurrent().getLocale(); return messageSource.getMessage(code, null, defaultMessage, locale); }
public String getMessage(String code, Object[] args) { Locale locale = VaadinSession.getCurrent().getLocale(); return messageSource.getMessage(code, args, locale); } }
public Locale getLocale() { return VaadinSession.getCurrent().getLocale(); }
/** * Create a VaadinSession * @param locale Client locale * @return VaadinSession instance * @throws Exception Failed to create session */ protected VaadinSession createVaadinSession(Locale locale) throws Exception { WrappedSession wrappedSession = mock(WrappedSession.class); VaadinServletService vaadinService = mock(VaadinServletService.class); when(vaadinService.getDeploymentConfiguration()) .thenReturn(new DefaultDeploymentConfiguration(VaadinServletService.class, getDeploymentProperties())); VaadinSession session = mock(VaadinSession.class); when(session.getState()).thenReturn(VaadinSession.State.OPEN); when(session.getSession()).thenReturn(wrappedSession); when(session.getService()).thenReturn(vaadinService); when(session.getSession().getId()).thenReturn(TEST_SESSION_ID); when(session.hasLock()).thenReturn(true); when(session.getLocale()).thenReturn(locale != null ? locale : Locale.US); return session; }
/** * Create a VaadinSession * @param locale Client locale * @return VaadinSession instance * @throws Exception Failed to create session */ protected VaadinSession createVaadinSession(Locale locale) throws Exception { WrappedSession wrappedSession = mock(WrappedSession.class); VaadinServletService vaadinService = mock(VaadinServletService.class); when(vaadinService.getDeploymentConfiguration()) .thenReturn(new DefaultDeploymentConfiguration(VaadinServletService.class, getDeploymentProperties())); VaadinSession session = mock(VaadinSession.class); when(session.getState()).thenReturn(VaadinSession.State.OPEN); when(session.getSession()).thenReturn(wrappedSession); when(session.getService()).thenReturn(vaadinService); when(session.getSession().getId()).thenReturn(TEST_SESSION_ID); when(session.hasLock()).thenReturn(true); when(session.getLocale()).thenReturn(locale != null ? locale : Locale.US); return session; }
Locale locale = session.getLocale(); if (locale != null) { return locale;
@SuppressWarnings("deprecation") private void prepAttach() { when(request.getParameter("v-loc")).thenReturn(baseUri + "/#home"); ui.getPage() .init(request); when(session.createConnectorId(Matchers.any(ClientConnector.class))).thenAnswer(new ConnectorIdAnswer()); when(session.getLocale()).thenReturn(Locale.FRANCE); when(session.hasLock()).thenReturn(true); ui.setSession(session); }
when(vaadinSession.getLocale()).thenReturn(DEFAULT_LOCALE); when(vaadinSession.hasLock()).thenReturn(true); ComponentsTestUtil.setInstance(VaadinSession.class, vaadinSession);