List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:net.jcreate.e3.table.message.ResourceBundleMessageSource.java
private String getStringOrNull(ResourceBundle bundle, String key) { try {/*w w w. j a v a 2 s. com*/ return bundle.getString(key); } catch (MissingResourceException ex) { // Assume key not found // -> do NOT throw the exception to allow for checking parent message source. return null; } }
From source file:ambroafb.general.GeneralConfig.java
/** * ? ?? ?? ?? /*from w ww . j a v a 2 s. c o m*/ * * @param key - , ? ?? ?? ? * @param language - ?, ?? ? ?? * ?? ? ? ? ??? ?? ?. ?: * English, ? ... * @return */ public String getTitleForLanguage(String key, String language) { String id = mapLanguageToId(language); ResourceBundle b = loadBundle(new Locale(id)); return StringEscapeUtils.unescapeJava(b.getString(key)); }
From source file:net.kamhon.ieagle.function.language.service.impl.LanguageFrameworkServiceImpl.java
private String getTextByResourceBundle(String key, Locale locale) { String msg = null;//from www .j av a 2 s .c o m if (resourceBaseNames instanceof List) { for (String baseName : (List<String>) resourceBaseNames) { ResourceBundle rb = ResourceBundle.getBundle(baseName, locale); try { msg = rb.getString(key); } catch (MissingResourceException ex) { // log.debug("key " + key + " not found!!"); } if (msg != null) break; } } return msg; }
From source file:com.gettextresourcebundle.GettextResourceBundleControlTest.java
/** * test that the controls picks up PO files by locale * from the filesystem// w w w . j a va 2 s. c o m */ @Test public void testFileReads() { ResourceBundle en_US = ResourceBundle.getBundle("./src/test/resources/locale", Locale.US, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_US for the en_US locale", en_US.getString("locale"), "en_US"); ResourceBundle en_CA = ResourceBundle.getBundle("./src/test/resources/locale", Locale.CANADA, GettextResourceBundleControl.getControl("test")); assertEquals("The locale key should be en_CA for the en_CA locale", en_CA.getString("locale"), "en_CA"); }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.gestor.GestorOrganizacionesControllerImpl.java
public final void submit(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.organizaciones.gestor.SubmitForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String action = form.getAction(); if (action.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.eliminar"))) { if ((form.getIdentifierRowSelectionAsArray() == null) || (form.getIdentifierRowSelectionAsArray().length == 0)) { throw new ValidatorException("{portal_empaquetado.exception.gestorOrganizaciones}"); }/*www . j a va 2 s . co m*/ } String[] identificadores = form.getIdentifierRowSelectionAsArray(); form.setOrganizacionesAsArray(identificadores); }
From source file:eu.apenet.dpt.standalone.gui.validation.DownloadReportActionListener.java
private String getStringFromMap(Map<String, Map<String, Boolean>> map) { ResourceBundle labels = dataPreparationToolGUI.getLabels(); StringBuilder builder = new StringBuilder(); builder.append("----- "); builder.append(labels.getString("dataquality.title")); builder.append(" -----"); builder.append("\r\n"); builder.append(MessageFormat.format(labels.getString("dataquality.missing.unittitle"), "(unittitle)")); builder.append(" "); builder.append(Integer.toString(map.get("unittitle").size())); builder.append("\r\n"); builder.append(MessageFormat.format(labels.getString("dataquality.missing.unitdate"), "(unitdate@normal)")); builder.append(" "); builder.append(Integer.toString(map.get("unitdate").size())); builder.append("\r\n"); builder.append(MessageFormat.format(labels.getString("dataquality.missing.dao"), "(dao@xlink:role)")); builder.append(" "); builder.append(Integer.toString(map.get("dao").size())); builder.append("\r\n"); builder.append(MessageFormat.format(labels.getString("dataquality.missing.href"), "(dao@xlink:href)")); builder.append(" "); builder.append(Integer.toString(map.get("href").size())); builder.append("\r\n"); builder.append("\r\n"); for (String key : map.keySet()) { if (map.get(key).size() > 0) { if (key.equals("unittitle")) { builder.append("--- ").append( MessageFormat.format(labels.getString("dataquality.report.unittitle"), "(unittitle)")) .append(" ---"); } else if (key.equals("unitdate")) { builder.append("--- ").append(MessageFormat .format(labels.getString("dataquality.report.unitdate"), "(unitdate@normal)")) .append(" ---"); } else if (key.equals("dao")) { builder.append("--- ").append( MessageFormat.format(labels.getString("dataquality.report.dao"), "(dao@xlink:role)")) .append(" ---"); } else if (key.equals("href")) { builder.append("--- ").append( MessageFormat.format(labels.getString("dataquality.report.href"), "(dao@xlink:href)")) .append(" ---"); }//w w w . j ava 2s. co m builder.append("\r\n"); for (String id : map.get(key).keySet()) { builder.append(id); if (!map.get(key).get(id)) { builder.append(" ("); builder.append(labels.getString("dataquality.report.idxml")); builder.append(")"); } builder.append("\r\n"); } } } return builder.toString(); }
From source file:org.dspace.app.webui.cris.controller.FormSendMailController.java
protected Object formBackingObject(HttpServletRequest request) throws Exception { String mode_s = request.getParameter("mode"); Integer mode = Integer.parseInt(mode_s); String id_s = request.getParameter("id"); Integer id = null;//from w w w . j a v a 2 s . c o m if (id_s != null) { id = Integer.parseInt(id_s); } ResearcherPage researcher = applicationService.get(ResearcherPage.class, id); MailDTO dto = new MailDTO(); dto.setSubmitter(researcher.getId()); dto.setRp(ResearcherPageUtils.getPersistentIdentifier(researcher)); Locale supportedLocale = request.getLocale(); ResourceBundle labels = ResourceBundle.getBundle("Messages", supportedLocale); switch (mode) { case MODE_BIBLIOMETRIC: dto.setTemplate(TEMPLATE_BIBLIOMETRIC); dto.setSubject(labels.getString("subject.mail.hku.request-changes.two")); break; case MODE_ITEMS: dto.setTemplate(TEMPLATE_ITEMS); dto.setSubject(labels.getString("subject.mail.hku.request-changes.three")); break; default: dto.setTemplate(TEMPLATE_MEDIA); dto.setSubject(labels.getString("subject.mail.hku.request-changes.one")); break; } return dto; }
From source file:fr.certu.chouette.plugin.report.Report.java
/** * get report message for a specified Locale * <p>/*from w w w . j av a 2 s . c o m*/ * if no message available for locale, default locale is assumed * * @param locale * asked locale * @return report message */ public String getLocalizedMessage(Locale locale) { String message = ""; try { ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName(), locale); message = bundle.getString(getOriginKey()); } catch (MissingResourceException e1) { try { ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName()); message = bundle.getString(getOriginKey()); } catch (MissingResourceException e2) { message = getOriginKey(); } } return message; }
From source file:es.pode.empaquetador.presentacion.basico.carpeta.CrearCarpetaBasicoControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.basico.carpeta.CrearCarpetaBasicoController#crear(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.basico.carpeta.CrearForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w w w .ja va2s .c o m public final void crear(ActionMapping mapping, es.pode.empaquetador.presentacion.basico.carpeta.CrearForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String accion = form.getAction(); if (accion == null || accion.equals(i18n.getString("nuevo_grupo.aceptar"))) { // Validamos el nuevo titulo introducido if (form.getTitle() == null || "".equals(form.getTitle().trim())) { logger.error("El titulo " + form.getTitle() + " no ha pasado la validacion"); throw new ValidatorException("{gestor_basico.carpeta.validacion.titulo.obligatorio}"); } // Comprobamos carpetas repetidas GrupoVO[] hijos = gs.buscarHijosIdCollection(request); for (int i = 0; i < hijos.length; i++) { if (form.getTitle().equals(hijos[i].getTitle())) { logger.error("Error de titulo repetido en crear / modificar carpeta"); throw new ValidatorException("{gestor_basico.carpeta.validacion.titulo.repetido}"); } } EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List idCollection = sesEmpaq.getIdCollection(); String identificador = form.getIdentifier(); String identificadorUltimo = sesEmpaq.getIdLocalizador(); Object ultimoIdCollection = idCollection.get(idCollection.size() - 1); String identificadorPadre = ""; GrupoVO[] grupos = null; if (idCollection.size() == 1) { OrganizacionVO organizacion = (OrganizacionVO) ultimoIdCollection; grupos = organizacion.getGrupos(); identificadorPadre = organizacion.getIdentifier(); } else if (idCollection.size() > 1) { GrupoVO grupo = (GrupoVO) ultimoIdCollection; grupos = grupo.getGrupos(); identificadorPadre = grupo.getIdentifier(); } boolean encontrado = false; GrupoVO grupoBuscar = null; for (int i = 0; (encontrado == false && i < grupos.length); i++) { if (grupos[i].getIdentifier().equals(identificador)) { encontrado = true; grupoBuscar = grupos[i]; } } if (form.isEsModificar() == true) { grupoBuscar.setTitle(form.getTitle()); grupoBuscar.setIdentifier(identificador); this.getSrvGestorManifestService().modificarGrupo(identificadorUltimo, grupoBuscar); } else if (form.isEsModificar() == false) { grupoBuscar = new GrupoVO(); grupoBuscar.setTitle(form.getTitle()); grupoBuscar.setIdentifier(identificador); this.getSrvGestorManifestService().crearGrupo(identificadorUltimo, grupoBuscar, identificadorPadre); } } }
From source file:es.pode.empaquetador.presentacion.basico.desagregar.DesagregarBasicoControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.basico.desagregar.DesagregarBasicoController#selectAction(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.basico.desagregar.SelectActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from ww w .j a v a 2s .c o m public final java.lang.String selectAction(ActionMapping mapping, es.pode.empaquetador.presentacion.basico.desagregar.SelectActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String action = form.getAction(); String destino = form.getDestino(); String resultado = "Cancelar"; try { ResourceBundle i18n = ResourceBundle.getBundle("application-resources", (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE)); if (i18n.getString("gestor_basico.desagregar.cancelar").equalsIgnoreCase(action)) { logger.debug("Se ha pulsado cancelar"); } else { if ("Local".equalsIgnoreCase(destino)) { resultado = "Local"; logger.debug("Se ha pulsado local"); } else if ("Personales".equalsIgnoreCase(destino)) { resultado = "Personales"; logger.debug("Se ha pulsado personales"); } else { logger.error("SelectAction no tiene datos para decidir"); } } } catch (Exception e) { logger.error(e); throw new ValidatorException("{gestor_basico.error.inesperado}"); } return resultado; }