Apache Wicket custom IStringResourceLoader

Created 2017-01-24 14:53:57.746120

back
				getResourceSettings().getStringResourceLoaders().add(new IStringResourceLoader() {
					@Override
					public String loadStringResource(final Class<?> clazz, final String key, final Locale locale, final String style, final String variation) {
						String value = "::missing translation::";
						try {
							ResourceBundle bundle = new PropertyResourceBundle(getClass().getResourceAsStream("/themes/default/stringResources_de.utf8.properties"));
							value = bundle.getString(key);
						} catch (IOException e) {
							LOG.error(e);
						}
						LOG.debug("Loaded string resource: " + key + "=" + value);
						return value;
					}

					@Override
					public String loadStringResource(final Component component, final String key, final Locale locale, final String style, final String variation) {
						return loadStringResource(component.getClass(), key, locale, style, variation);
					}
				});
back