List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static ResourceBundle getBundle(String baseName, Module module)
From source file:org.pmp.budgeto.app.SwaggerDispatcherConfigTest.java
@Test public void customImplementation() throws Exception { ResourceBundle bundle = ResourceBundle.getBundle("i18n/common", Locale.ENGLISH); Mockito.when(translatorTools.get("app.title")).thenReturn(bundle.getString("app.title")); Mockito.when(translatorTools.get("app.description")).thenReturn(bundle.getString("app.description")); Mockito.when(translatorTools.get("app.terms")).thenReturn(bundle.getString("app.terms")); Mockito.when(translatorTools.get("app.contact")).thenReturn(bundle.getString("app.contact")); Mockito.when(translatorTools.get("app.licence")).thenReturn(bundle.getString("app.licence")); Mockito.when(translatorTools.get("app.licence.url")).thenReturn(bundle.getString("app.licence.url")); SwaggerSpringMvcPlugin swaggerSpringMvcPlugin = swaggerDispatcherConfig.customImplementation(); Assertions.assertThat(swaggerSpringMvcPlugin).isNotNull(); Assertions.assertThat(//from w w w. j a va 2s .co m TestTools.getField(swaggerSpringMvcPlugin, "springSwaggerConfig", SpringSwaggerConfig.class)) .isEqualTo(springSwaggerConfig); Assertions.assertThat(TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getTitle()) .isEqualTo("Budgeto api"); Assertions.assertThat(TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getDescription()) .isEqualTo("Rest services for budgeto"); Assertions .assertThat( TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getTermsOfServiceUrl()) .isEqualTo(""); Assertions.assertThat(TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getContact()) .isEqualTo("pmpinson@gmail.com"); Assertions.assertThat(TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getLicense()) .isEqualTo("no"); Assertions.assertThat(TestTools.getField(swaggerSpringMvcPlugin, "apiInfo", ApiInfo.class).getLicenseUrl()) .isEqualTo(""); }
From source file:fr.hoteia.qalingo.core.service.impl.ReferentialDataServiceImpl.java
private ResourceBundle getTitlesBundleByLocale(final Locale locale) { return ResourceBundle.getBundle(Constants.TITLES_RESOURCE_BUNDLE, locale); }
From source file:net.sf.jcprogress.ProgressThread.java
/** * create new progress indicator. /*from w w w. j av a 2 s .c o m*/ * @param statusProvider ProgressStatusProvider to use * @param locale preferred locale */ public ProgressThread(ProgressStatusProvider statusProvider, Locale locale) { this.statusProvider = statusProvider; long now = System.currentTimeMillis(); //memorize current time int wholeCount = getWholeCount(); checkpointSwitchTime = now; checkpoint = new Checkpoint(wholeCount, 0, 0, stalledTimeWindowMs, now); secondCheckpoint = checkpoint; wholeProgess = new ProgressCalculator(now, wholeCount, stalledTimeWindowMs); lastIndicatorUpdate = now; lastInfoUpdate = now; this.resourceBundle = ResourceBundle.getBundle("net.sf.jcprogress.resources.ProgressResources", locale); //$NON-NLS-1$ }
From source file:es.pode.visualizador.presentacion.agregaSlider.AgregaSliderControllerImpl.java
/** * Metodo que construye el codigo html que el usuario debe copiar en su web para aadir * la galeria de imagenes// w ww . j a v a 2s .c o m * * @param mapping * @param form Formulario con los datos necesarios * @param request * @param response * @throws Exception */ public final void construirCodigo(ActionMapping mapping, es.pode.visualizador.presentacion.agregaSlider.ConstruirCodigoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String keywords = form.getKeywords(); String idioma = form.getIdiomasCombo(); try { if (keywords == null || keywords == "") { //Lanzamos la excepcion porque las keywords estan vacias throw new ValidatorException("{agregaSlider.keywordVacia}"); } boolean keywordsOK = comprobarKeywords(keywords); if (keywordsOK) { //Construimos el codigo html embebido String codigo = new String(); ficheroRecursos = ResourceBundle.getBundle("application-resources", request.getLocale()); String controller = ficheroRecursos.getString("agregaSlider.url.controller"); String nodo = AgregaPropertiesImpl.getInstance().getProperty("host") + AgregaPropertiesImpl.getInstance().getProperty("admin.ws.subdominio"); String url = "http://" + nodo + "/" + ficheroRecursos.getString("agregaSlider.url.sfw"); //rellenamos el codigo que le pasamos a la jsp para que el usuario lo recoja codigo = "<object width='400' height='400' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " + "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'>" + "<param name='movie' value='" + url + "' />" + "<param name='Flashvars' value='palabras=" + keywords + "&idioma=" + idioma + "&nodo=" + nodo + "&controller=" + controller + "' />" + "<param name='bgcolor' value='#FFFFFF' /> " + "<embed src='" + url + "' " + "type='application/x-shockwave-flash' " + "Flashvars='palabras=" + keywords + "&idioma=" + idioma + "&nodo=" + nodo + "&controller=" + controller + "' " + "bgcolor='#FFFFFF' " + "pluginspage='http://www.macromedia.com/go/getflashplayer'" + "width='400' " + "height='400'>" + "</embed>" + "</object> "; form.setCodigo(codigo); } else //Lanzamos la excepcion porque alguna keywords no esta bien metida throw new ValidatorException("{agregaSlider.keywordIncorrecta}"); } catch (ValidatorException Ve) { log.error("Ve ->" + Ve); throw Ve; } catch (Exception e) { log.error("Error al crear el codigo embebido para el agregaSlider: " + e); throw new ValidatorException("{agregaSilder.errorCrearCodigoEmbebido}"); } }
From source file:es.pode.administracion.presentacion.monitorizarnodos.monitorizar.MonitorizarNodosControllerImpl.java
private void prepararInformacion(EstadoNodoVO[] estadosVO, Locale locale) { String descripcion = null;//ww w . j a v a 2 s . c o m ficheroRecursos = ResourceBundle.getBundle("application-resources", locale); for (int i = 0; i < estadosVO.length; i++) { //intentamos traducir el nombre del servicio, si no se puede dejamos el de la BBDD try { descripcion = ficheroRecursos.getString(estadosVO[i].getNombreServicio()); } catch (Exception ex) { log.warn("El nombre del servicio " + estadosVO[i].getNombreServicio() + " no esta en el fichero de internacionalizacion"); descripcion = estadosVO[i].getDescripcionServicio(); } estadosVO[i].setDescripcionServicio(descripcion); } }
From source file:mb.MbAdministrator.java
public void increaseUserBalance() { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); if (selectedUser == null || balanceIncrement == null || !StringUtils.isNumeric(balanceIncrement)) { JsfUtil.addErrorMessage(ResourceBundle.getBundle("localization.messages", locale) .getString("AdministratorUserBalance_failure")); return;/*from w w w. j av a 2s . c o m*/ } double newBalance = selectedUser.getBalance() + Double.parseDouble(balanceIncrement); selectedUser.setBalance(newBalance); try { getEjbUser().edit(selectedUser); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("localization.messages", locale) .getString("AdministratorUserBalance_success")); } catch (Exception e) { JsfUtil.addErrorMessage(ResourceBundle.getBundle("localization.messages", locale) .getString("AdministratorUserBalance_failure")); } setDefaultUserBalanceTableValue(); }
From source file:eu.optimis.tf.sp.service.SPOperation.java
public String getHistoricTrust(String providerId) { String historic = ""; // String historicHeader = "<trust xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"; String historicBody = ""; // try { // TrecIPTrustDAO iptdao = new TrecIPTrustDAO(); // List<IpTrust> iptlst = iptdao.getIPTrusts(providerId); // //from w w w .j a v a2 s . c o m // for (IpTrust ipt : iptlst){ // historicBody = historicBody + "<value>" + (ipt.getIpTrust() * rate) // + "</value>"; // } // String historicEnd = "</trust>"; // historic = historicHeader + historicBody + historicEnd; // return historic; // } catch (Exception e) { ResourceBundle rb = ResourceBundle.getBundle("trustframework", Locale.getDefault()); try { String url = rb.getString("db.sp.host"); String user = rb.getString("db.user"); String password = rb.getString("db.pass"); Driver myDriver = new com.mysql.jdbc.Driver(); DriverManager.registerDriver(myDriver); Connection conn = DriverManager.getConnection(url, user, password); // Get a statement from the connection Statement stmt = conn.createStatement(); // Execute the query ResultSet rs = stmt.executeQuery( "SELECT `ip_trust` FROM `ip_trust` WHERE `ip_id` = '" + providerId + "' limit 100"); // Loop through the result set while (rs.next()) { // historicBody = historicBody + "<value>" + (Double.valueOf(rs.getString(1)) * rate) // + "</value>"; historicBody = historicBody + (Double.valueOf(rs.getString(1)) * rate) + ","; } // Close the result set, statement and the connection rs.close(); stmt.close(); conn.close(); return historicBody; } catch (SQLException e1) { System.out.println("Error: unable to load infrastructure provider trust"); return ""; } // } }
From source file:be.fedict.eid.dss.document.zip.ZIPDSSDocumentService.java
public DocumentVisualization visualizeDocument(byte[] document, String language, List<MimeType> mimeTypes, String documentViewerServlet) throws Exception { // get i18n//w w w . j a v a 2 s. c om ResourceBundle zipResourceBundle = ResourceBundle.getBundle("ZIPMessages", new Locale(language)); ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(document)); ZipEntry zipEntry; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<html>"); stringBuilder.append("<head>"); stringBuilder.append("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">"); stringBuilder.append("<title>ZIP package</title>"); stringBuilder.append("</head>"); stringBuilder.append("<body>"); stringBuilder.append(String.format("<h2>%s</h2>", zipResourceBundle.getObject("zipTitle"))); stringBuilder.append("<table>"); while (null != (zipEntry = zipInputStream.getNextEntry())) { if (ODFUtil.isSignatureFile(zipEntry)) { continue; } String zipEntryName = zipEntry.getName(); boolean browserViewable = MimeTypeMapper.browserViewable(mimeTypes, zipEntryName); String image = browserViewable ? "view.png" : "download.png"; stringBuilder.append("<tr>"); stringBuilder.append("<td>"); stringBuilder.append(String.format("<a href=\"%s\" target=_blank>", documentViewerServlet + getResourceId(zipEntry))); stringBuilder.append( "<img src=\"./images/" + image + "\" style=\" width: 25px; vertical-align: bottom;\" />"); stringBuilder.append(zipEntryName); stringBuilder.append("</a>"); stringBuilder.append("</td>"); stringBuilder.append("</tr>"); } stringBuilder.append("</table>"); stringBuilder.append("</body></html>"); return new DocumentVisualization("text/html;charset=utf-8", stringBuilder.toString().getBytes()); }
From source file:fr.certu.chouette.plugin.report.Report.java
/** * get report message for a specified Locale * <p>//from w w w .java2s . 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.avanzado.organizaciones.elementos.secuencia.SecuenciaControllerImpl.java
public final void submit(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.secuencia.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 accion = form.getAction(); if (accion.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) { if ((form.getChoice() == null) || (form.getChoiceExit() == null) || (form.getFlow() == null) || (form.getForwardOnly() == null)) { throw new ValidatorException("{portal_empaquetado.exception}"); }//from w ww. jav a 2s .com } }