@Override public String loadStringResource(final Component component, String key, final Locale locale, final String style, final String variation) { if (key.contains(",")) { key = key.substring(0, key.lastIndexOf(',')); return resourceSettings.getLocalizer().getStringIgnoreSettings(key, component, null, locale, style, variation); } return null; } });
/** * @see org.apache.wicket.resource.IPropertiesFactory#clearCache() */ public final void clearCache() { propertiesCache.clear(); // clear the localizer cache as well application.getResourceSettings().getLocalizer().clearCache(); }
/** * Convenience method to provide easy access to the localizer object within any component. * * @return The localizer object */ public final Localizer getLocalizer() { return getApplication().getResourceSettings().getLocalizer(); }
/** * Convenience method to provide easy access to the localizer object within any component. * * @return The localizer object */ public final Localizer getLocalizer() { return getApplication().getResourceSettings().getLocalizer(); }
/** * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ @Override public String getObject() { // this shouldn't be called always wrapped! return Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, defaultValue); }
/** * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ public Object getObject() { // this shouldn't be called always wrapped! return Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, defaultValue); }
private void reportError(String resourceKey, final String identity) { String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, new Model<Serializable>(new Serializable() { @SuppressWarnings("unused") public String getIdentity() { return identity; } })); component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message))); }
private String getMessage(String key) { return Application.get().getResourceSettings().getLocalizer().getString(key, component); } }
/** * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ @Override public String getObject() { return Application.get().getResourceSettings().getLocalizer().getString(resourceKey, component, defaultValue); }
/** * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ public Object getObject() { return Application.get().getResourceSettings().getLocalizer().getString(resourceKey, component, defaultValue); }
private void reportError(String resourceKey, final String identity) { String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, new Model<Serializable>(new Serializable() { @SuppressWarnings("unused") public String getIdentity() { return identity; } })); component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message))); }
private String getMessage(String key) { return Application.get().getResourceSettings().getLocalizer().getString(key, component); }
private void reportError(String resourceKey, final String value, final String regex) { try { String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, new Model<Serializable>(new Serializable() { @SuppressWarnings("unused") public String getValue() { return value; } @SuppressWarnings("unused") public String getRegex() { return regex; } })); component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message))); } catch (Exception e) { component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>("Regexp validation error (value='" + value+ "', regex='" + regex + "')"))); } }
/** * Clears all the wicket caches so that resources and localization files will be re-read */ public void clearWicketCaches() { getResourceSettings().getPropertiesFactory().clearCache(); getResourceSettings().getLocalizer().clearCache(); }
@Override protected void onValidate(IValidatable<String> validatable) { final String value = validatable.getValue(); if (value == null) return; try { new URILocator(value); } catch (Exception e) { String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null, new Model<Serializable>(new Serializable() { @SuppressWarnings("unused") public String getValue() { return value; } })); component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message))); } }
/** * @see org.apache.wicket.validation.IErrorMessageSource#getMessage(java.lang.String) */ public final String getMessage(String key) { Localizer localizer = Application.get().getResourceSettings().getLocalizer(); // Note: It is important that the default value of "" is provided // to getString() not to throw a MissingResourceException or to // return a default string like "[Warning: String ..." String message = localizer.getString(key, getComponent(), ""); if (Strings.isEmpty(message)) return null; return message; }
/** * Utility method for localizing strings using Wicket i18n subsystem. Useful if your model * needs to be localized and you don't have access to a Component instance. * Use with care, in most cases you should be able to localize your messages directly in * pages or components. * @param key * @param model * @param params * @return */ public static String localize(String key, IModel model, Object... params) { StringResourceModel rm = new StringResourceModel(key, null, model, params); rm.setLocalizer(GeoServerApplication.get().getResourceSettings().getLocalizer()); return rm.getString(); }
@Override public String getObject() { return RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + "doc/" + Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, (String)null); } }
@Override public String getObject() { return RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + "doc/" + Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null, (String)null); } }
/** {@inheritDoc} */ public final Object getDisplayValue(T object) { final String value; String key = resourceKey(object); if (resourceSource != null) { value = resourceSource.getString(key); } else { value = Application.get().getResourceSettings().getLocalizer().getString(key, null); } return postprocess(value); }