List of usage examples for com.google.gwt.i18n.client LocaleInfo getLocaleQueryParam
public static String getLocaleQueryParam()
From source file:com.arcbees.website.client.application.ApplicationView.java
License:Apache License
private String getSwitchLangUrl() { return Location.createUrlBuilder().setPath(buildPath()).removeParameter(LocaleInfo.getLocaleQueryParam()) .buildString(); }
From source file:com.dingziran.effective.client.ShowcaseShell.java
License:Apache License
/** * Initialize the {@link ListBox} used for locale selection. *///from w w w. j a v a2 s . com private void initializeLocaleBox() { final String cookieName = LocaleInfo.getLocaleCookieName(); final String queryParam = LocaleInfo.getLocaleQueryParam(); if (cookieName == null && queryParam == null) { // if there is no way for us to affect the locale, don't show the selector localeSelectionCell.getStyle().setDisplay(Display.NONE); return; } String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName(); if (currentLocale.equals("default")) { currentLocale = "en"; } String[] localeNames = LocaleInfo.getAvailableLocaleNames(); for (String localeName : localeNames) { if (!localeName.equals("default")) { String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName); localeBox.addItem(nativeName, localeName); if (localeName.equals(currentLocale)) { localeBox.setSelectedIndex(localeBox.getItemCount() - 1); } } } localeBox.addChangeHandler(new ChangeHandler() { @SuppressWarnings("deprecation") public void onChange(ChangeEvent event) { String localeName = localeBox.getValue(localeBox.getSelectedIndex()); if (cookieName != null) { // expire in one year Date expires = new Date(); expires.setYear(expires.getYear() + 1); Cookies.setCookie(cookieName, localeName, expires); } if (queryParam != null) { UrlBuilder builder = Location.createUrlBuilder().setParameter(queryParam, localeName); Window.Location.replace(builder.buildString()); } else { // If we are using only cookies, just reload Window.Location.reload(); } } }); }
From source file:com.goodow.web.ui.client.search.DefaultHeader.java
License:Apache License
/** * Initialize the {@link ListBox} used for locale selection. *//* w ww. ja v a 2s .c om*/ private void initializeLocaleBox() { final String cookieName = LocaleInfo.getLocaleCookieName(); final String queryParam = LocaleInfo.getLocaleQueryParam(); if (cookieName == null && queryParam == null) { // if there is no way for us to affect the locale, don't show the selector localeSelectionCell.getStyle().setDisplay(Display.NONE); return; } String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName(); if (currentLocale.equals("default")) { currentLocale = "zh"; } String[] localeNames = LocaleInfo.getAvailableLocaleNames(); for (String localeName : localeNames) { if (!localeName.equals("default")) { String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName); localeBox.addItem(nativeName, localeName); if (localeName.equals(currentLocale)) { localeBox.setSelectedIndex(localeBox.getItemCount() - 1); } } } localeBox.addChangeHandler(new ChangeHandler() { @Override @SuppressWarnings("deprecation") public void onChange(final ChangeEvent event) { String localeName = localeBox.getValue(localeBox.getSelectedIndex()); if (cookieName != null) { // expire in one year Date expires = new Date(); expires.setYear(expires.getYear() + 1); Cookies.setCookie(cookieName, localeName, expires); } if (queryParam != null) { UrlBuilder builder = Location.createUrlBuilder().setParameter(queryParam, localeName); Window.Location.replace(builder.buildString()); } else { // If we are using only cookies, just reload Window.Location.reload(); } } }); }
From source file:com.jci.client.application.ui.HeaderPresenter.java
License:Apache License
@Override public void switchLocale() { LocaleInfo currentLocale = LocaleInfo.getCurrentLocale(); String newLocale;/*from w w w . jav a 2 s.c om*/ if (currentLocale.getLocaleName().equals("fr")) { newLocale = "en"; } else { newLocale = "fr"; } Window.Location.assign(Window.Location.createUrlBuilder() .setParameter(LocaleInfo.getLocaleQueryParam(), newLocale).buildString()); }
From source file:mx.org.pescadormvp.core.client.placesandactivities.PescadorMVPPlaceMapperImpl.java
License:Open Source License
@Override public void setupURLInfo(PescadorMVPPlace place) { String historyTokenFromPlaceObj = place.getHistoryToken(); String historyToken = historyTokenFromPlaceObj == null ? getToken(place) : historyTokenFromPlaceObj; place.setHistoryToken(historyToken); PescadorMVPLocale newLocale = place.getNewLocale(); if (newLocale == null) { place.setURL("#" + historyToken); // instructs Session not to reload the whole app when going here place.setRequiresReload(false);/* ww w . j a v a 2s. c om*/ } else { // TODO check that the locale is not the same as the current one (?) String queryParam = LocaleInfo.getLocaleQueryParam(); UrlBuilder builder = Location.createUrlBuilder(); builder.setParameter(queryParam, newLocale.getLocaleName()); builder.setHash(historyToken); place.setURL(builder.buildString()); // in this case, do reload the whole app when going here place.setRequiresReload(true); } }
From source file:org.glom.web.client.activity.TableSelectionActivity.java
License:Open Source License
/** * Invoked by the ActivityManager to start a new Activity *///from ww w . java 2s. c o m @Override public void start(final AcceptsOneWidget containerWidget, final EventBus eventBus) { final TableSelectionView tableSelectionView = clientFactory.getTableSelectionView(); tableSelectionView.setPresenter(this); // TODO: Check for authentication here? // Or just let it fail to retrieve the list of tables, // and let the other activity on the page ask for authentication. // For table changes with the tableSelector: final HasChangeHandlers tableSelector = tableSelectionView.getTableSelector(); tableChangeHandlerRegistration = tableSelector.addChangeHandler(new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { // Fire a table change event so that other views (e.g. the details view) know about the change and can // update themselves. eventBus.fireEvent(new TableChangeEvent(tableSelectionView.getSelectedTableName())); // Update the browser title because there's a place change and the setPlace() method will not be called. Window.setTitle(documentTitle + ": " + tableSelectionView.getSelectedTableTitle()); } }); // For quick find changes with the quick find box: final HasChangeHandlers quickFindBox = tableSelectionView.getQuickFindBox(); quickFindChangeHandlerRegistration = quickFindBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { // Fire a quickfind change event so that other views (e.g. the details view) know about the change and // can // update themselves. eventBus.fireEvent(new QuickFindChangeEvent(tableSelectionView.getQuickFindText())); // Update the browser title because there's place change and the setPlace() method will not be called. // TODO? Window.setTitle(documentTitle + ": " + tableSelectionView.getSelectedTableTitle()); } }); // For locale changes with the localeSelector: final HasChangeHandlers localeSelector = tableSelectionView.getLocaleSelector(); localeChangeHandlerRegistration = localeSelector.addChangeHandler(new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { // Show the translated version of the document title and the table names: final String localeID = tableSelectionView.getSelectedLocale(); fillView(tableSelectionView); final String newURL = Window.Location.createUrlBuilder() .setParameter(LocaleInfo.getLocaleQueryParam(), localeID).buildString(); Window.Location.assign(newURL); // Fire a locale change event so that other views (e.g. the details view) know about the change and can // update themselves. eventBus.fireEvent(new LocaleChangeEvent(localeID)); } }); // For report choices with the reportSelector: final HasChangeHandlers reportSelector = tableSelectionView.getReportSelector(); reportChangeHandlerRegistration = reportSelector.addChangeHandler(new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { final String reportName = tableSelectionView.getSelectedReport(); if (StringUtils.isEmpty(reportName)) { // Interpret selecting no report as requesting the list view. goTo(new ListPlace(documentID, tableName, quickFind)); } else { // Show the selected report: goTo(new ReportPlace(documentID, tableName, reportName, quickFind)); } } }); fillView(tableSelectionView); // we're done, set the widget containerWidget.setWidget(tableSelectionView.asWidget()); }
From source file:org.glom.web.client.Utils.java
License:Open Source License
public static String getCurrentLocaleID() { String localeID = LocaleInfo.getCurrentLocale().getLocaleName(); if (localeID.equals("default")) { localeID = ""; // This is how libglom refers to the default locale. }//from w w w . ja v a2 s. com if (StringUtils.isEmpty(localeID)) { // LocaleInfo.getCurrentLocale() returns "default" even if a real locale was specified in the URL, // if the locale is not specified as supported in our OnlineGlom.gwt.xml file, // but people could use locales in .glom files that we have not thought of, // so we should allow their use by getting the query parameter value directly: final String paramValue = Window.Location.getParameter(LocaleInfo.getLocaleQueryParam()); localeID = paramValue; // Prevent a null string from being used, // in case the caller does not expect it. if (localeID == null) { localeID = ""; } } return localeID; }
From source file:org.kie.workbench.common.widgets.client.handlers.workbench.configuration.LanguageConfigurationHandler.java
License:Apache License
@Override public void configurationSetting(final boolean isInit) { String languageName = languageItem.getSelectedItem().getK2(); String isRefresh = Window.Location.getParameter("isRefresh"); if ((isRefresh == null || isRefresh.equals("")) && isInit) { Window.Location/*w w w . j a va 2s . c o m*/ .assign(Window.Location.createUrlBuilder().removeParameter(LocaleInfo.getLocaleQueryParam()) .setParameter(LocaleInfo.getCurrentLocale().getLocaleQueryParam(), languageName) .setParameter("isRefresh", "false").buildString()); } else if (!isInit) { Window.Location.assign(Window.Location.createUrlBuilder() .removeParameter(LocaleInfo.getLocaleQueryParam()) .setParameter(LocaleInfo.getCurrentLocale().getLocaleQueryParam(), languageName).buildString()); } }
From source file:org.kie.workbench.common.widgets.client.popups.language.LanguageSelectorPopup.java
License:Apache License
private void setCurrentLanguage(String languageName) { Window.Location.assign(Window.Location.createUrlBuilder().removeParameter(LocaleInfo.getLocaleQueryParam()) .setParameter(LocaleInfo.getCurrentLocale().getLocaleQueryParam(), languageName).buildString()); }
From source file:org.kie.workbench.common.widgets.client.popups.workbench.configuration.WorkbenchConfigurationPopup.java
License:Apache License
private void setCurrentLanguage(final String languageName, final UserWorkbenchPreferences response) { String isRefresh = Window.Location.getParameter("isRefresh"); if (response != null && (isRefresh == null || isRefresh.equals(""))) { Window.Location//from w w w .jav a 2 s. c om .assign(Window.Location.createUrlBuilder().removeParameter(LocaleInfo.getLocaleQueryParam()) .setParameter(LocaleInfo.getCurrentLocale().getLocaleQueryParam(), languageName) .setParameter("isRefresh", "false").buildString()); } else if (response == null) { Window.Location.assign(Window.Location.createUrlBuilder() .removeParameter(LocaleInfo.getLocaleQueryParam()) .setParameter(LocaleInfo.getCurrentLocale().getLocaleQueryParam(), languageName).buildString()); } }