List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static ResourceBundle getBundle(String baseName, Module module)
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;// w w w . ja 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:org.accelerators.activiti.admin.AdminApp.java
@Override public void init() { // Set theme//from w w w.ja va2s .c om setTheme(Consts.THEME); // Set default locale setLocale(new Locale("en")); // Init resource bundle final ResourceBundle i18n = ResourceBundle.getBundle(Messages.class.getName(), getLocale()); // Add title mainWindow = new Window(i18n.getString(Messages.AppTitle)); // Set window to full size mainWindow.setSizeFull(); // Set as main window setMainWindow(mainWindow); // Add window to view manager viewManager = new ViewManager(mainWindow); // Create the login screen viewManager.switchScreen(LoginView.class.getName(), new LoginView(this)); }
From source file:com.cyclopsgroup.waterview.core.DefaultModuleManager.java
private void addBundleToList(List resourceBundles, String base, Locale locale) { try {/*from www .ja v a2 s .c om*/ ResourceBundle rb = ResourceBundle.getBundle(base, locale); if (rb != null) { resourceBundles.add(rb); } } catch (Exception ignored) { //do nothing } }
From source file:es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarRecursosControllerImpl.java
public final void importarZIP(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarZIPForm 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 opcion = form.getAction(); if (opcion.equals(i18n.getString("portalempaquetado.avanzado.recursos.aceptar"))) { FormFile fichero = form.getFichero(); if (fichero.getFileName() == null || fichero.getFileName().equals("") || fichero.getFileSize() == 0) { throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception}"); //tratar exception }// w w w. j av a2s . com try { InternetHeaders ih = new InternetHeaders(); MimeBodyPart mbp = null; DataSource source = null; DataHandler dFichero = null; mbp = new MimeBodyPart(ih, fichero.getFileData()); source = new MimePartDataSource(mbp); dFichero = new DataHandler(source); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List listSubmPath = sesEmpaq.getSubmanifestPath(); //cojo el primer elemento que dedberia ser el padre String identificador = sesEmpaq.getIdLocalizador(); if (listSubmPath.size() == 1) { this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, null); } else if (listSubmPath.size() > 1) { OdeVO odeultim = (OdeVO) listSubmPath.get(listSubmPath.size() - 1); String submanifestId = odeultim.getIdentifier(); this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, submanifestId); } } catch (Exception e) { throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception.validar}"); } } }
From source file:it.cnr.icar.eric.common.CommonResourceBundle.java
protected CommonResourceBundle(Locale locale) { // Load the resource bundle of specified locale bundle = ResourceBundle.getBundle(BASE_NAME, locale); }
From source file:mb.MbAdministrator.java
public String logOut() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); administrator = new Administrator(); filteredGamesList = gameList;/*from ww w. jav a2 s. c om*/ JsfUtil.addSuccessMessage(ResourceBundle.getBundle("localization.messages", locale) .getString("AdministratorMessage_successLogOut")); return "index?faces-redirect=true"; }
From source file:com.beginner.core.utils.PropertyUtil.java
/** * java.util.ResourceBundle?classpathproperties??TestResourcesUtil * @param key key//from w w w .j a v a 2 s . c om * @param fileName +????.properties?? * @return String keyvalue */ public static String getProperty(String key, String fileName) { if (StringUtils.isBlank(key)) throw new IllegalArgumentException("The key cannot be null and cannot be empty."); if (StringUtils.isBlank(fileName)) throw new IllegalArgumentException("The fileName cannot be null and cannot be empty."); Locale locale = Locale.getDefault(); ResourceBundle resource = ResourceBundle.getBundle(fileName, locale); String value = StringUtils.EMPTY; try { value = resource.getString(key); } catch (Exception e) { return value; } return value; }
From source file:at.alladin.rmbt.controlServer.OpenTestQoSResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();// w ww. j a va2s. co m final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; System.out.println(MessageFormat.format(labels.getString("NEW_QOS_RESULT_REQUEST"), getIP())); try { String lang = null; String openUUID = getRequest().getAttributes().get("open_test_uuid").toString(); if (getRequest().getAttributes().containsKey("lang")) { lang = getRequest().getAttributes().get("lang").toString(); } else { List<Preference<Language>> languageList = getRequest().getClientInfo().getAcceptedLanguages(); if (languageList != null && languageList.size() > 0) { lang = languageList.get(0).getMetadata().getName(); } } // Load Language Files for Client final List<String> langs = Arrays.asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { labels = (PropertyResourceBundle) ResourceBundle.getBundle("at.alladin.rmbt.res.SystemMessages", new Locale(lang)); } else { lang = settings.getString("RMBT_DEFAULT_LANGUAGE"); } errorList.setLanguage(lang); if (conn != null) { QoSUtil.evaluate(settings, conn, new TestUuid(openUUID, UuidType.OPEN_TEST_UUID), answer, lang, errorList); } else { errorList.addError("ERROR_DB_CONNECTION"); } } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (SQLException e) { errorList.addError("ERROR_DB_CONNECTION"); e.printStackTrace(); } catch (HstoreParseException e) { errorList.addErrorString(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperationException e) { errorList.addError("ERROR_REQUEST_QOS_RESOURCE_DETAIL_NO_UUID"); } try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); return answerString; }
From source file:es.pode.empaquetador.presentacion.agregar.AgregarSubmanifiestoControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.agregar.AgregarSubmanifiestoController#seleccionarOrigen(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.agregar.SeleccionarOrigenForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from ww w . jav a 2 s .co m*/ public final java.lang.String seleccionarOrigen(ActionMapping mapping, es.pode.empaquetador.presentacion.agregar.SeleccionarOrigenForm 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 origen = form.getOrigen(); String accion = form.getAction(); String resultado = null; if (accion.equals(i18n.getString("portal_empaquetado_agregarSubmanifiestos.continuar"))) { if ((origen.equals("Local")) || (origen.equals("Personales")) || (origen.equals("Repositorio"))) { resultado = origen; } else { throw new ValidatorException("{portal_empaquetado.exception}"); } } else { resultado = "Cancelar"; } return resultado; }
From source file:es.pode.empaquetador.presentacion.avanzado.recursos.exportar.ExportarRecursosControllerImpl.java
public final void exportar(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.recursos.exportar.ExportarForm 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 opcion = form.getAction(); if (opcion.equals(i18n.getString("presentacion.avanzado.recursos.exportar.aceptar"))) { String nombre = form.getNombre(); GestorSesion gs = new GestorSesion(); gs.validarNombreFichero(nombre); List recursosVO = this.getExportarRecursosSession(request).getRecursosVO(); if (logger.isDebugEnabled()) logger.debug("Recursos recuperados de la sesion " + recursosVO); List recursosList = new ArrayList(); String identificadorRec = ""; String[] recursos = new String[recursosVO.size()]; for (int i = 0; i < recursosVO.size(); i++) { identificadorRec = ((RecursoVO) recursosVO.get(i)).getIdentifier(); recursosList.add(i, identificadorRec); recursos[i] = identificadorRec; }// w w w . jav a2s. co m // String[] recursos=(String[]) recursosList.toArray(); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List listSubmPath = sesEmpaq.getSubmanifestPath(); //cojo el primer elemento que dedberia ser el padre String identificador = sesEmpaq.getIdLocalizador(); DataHandler dh = null; if (listSubmPath.size() == 1) { dh = this.getSrvGestorManifestService().exportarRecursos(identificador, recursos, null, nombre); } else if (listSubmPath.size() > 1) { OdeVO odeultim = (OdeVO) listSubmPath.get(listSubmPath.size() - 1); String submanifestId = odeultim.getIdentifier(); dh = this.getSrvGestorManifestService().exportarRecursos(identificador, recursos, submanifestId, nombre); } // Introducir el Datahandler en el response para la descarga try { (new GestorSesion()).iniciarDescargaFichero(dh, response, nombre + ".zip"); } catch (Exception e) { logger.error("Error en la descarga de recursos exportados"); if (logger.isDebugEnabled()) logger.debug(e); throw new ValidatorException("{presentacion.avanzado.recursos.exportar.error}"); } } }