List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:es.pode.empaquetador.presentacion.basico.asociar.archivos.AsociacionArchivosControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.basico.asociar.archivos.AsociacionArchivosController#submitPrincipal(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.basico.asociar.archivos.SubmitPrincipalForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from ww w .j av a 2 s . c o m public final java.lang.String submitPrincipal(ActionMapping mapping, es.pode.empaquetador.presentacion.basico.asociar.archivos.SubmitPrincipalForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AsociarSession asoSes = this.getAsociarSession(request); java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String accion = form.getAction(); String resultado = null; if (accion.equals(i18n.getString("portalempaquetado.Aceptar"))) { asoSes.setHref(form.getPrincipal()); resultado = "Aceptar"; } else { resultado = "Cancelar"; } return resultado; }
From source file:com.salesmanager.core.util.LabelUtil.java
public String getText(Locale locale, String key) { Iterator bundleListIterator = bundleList.iterator(); ResourceBundle myResources = null; String label = ""; while (bundleListIterator.hasNext()) { String bundle = (String) bundleListIterator.next(); try {// ww w.j a v a 2s.com myResources = ResourceBundle.getBundle(bundle, locale); if (myResources != null) { String l = myResources.getString(key); if (l != null) { label = l; break; } } } catch (Exception e) { // TODO: handle exception } } return label; }
From source file:com.cburch.logisim.util.LocaleManager.java
public String get(String key) { String ret;/*from www. j a v a 2 s . c o m*/ try { ret = locale.getString(key); } catch (MissingResourceException e) { ResourceBundle backup = dflt_locale; if (backup == null) { Locale backup_loc = Locale.US; backup = ResourceBundle.getBundle(dir_name + "/en/" + file_start, backup_loc); dflt_locale = backup; } try { ret = backup.getString(key); } catch (MissingResourceException e2) { ret = key; } } HashMap<Character, String> repl = LocaleManager.repl; if (repl != null) ret = replaceAccents(ret, repl); return ret; }
From source file:com.balero.controllers.PageController.java
/** * New page controller//from w ww. ja v a 2 s . co m * * @param name Page name * @param model Framework model * @param redirectAttributes Message center * @param locale Framework locale * @param baleroAdmin Magic cookie * @return Home controller */ @RequestMapping(value = "/page/new", method = RequestMethod.POST) public String newPage(@RequestParam("name") String name, Model model, RedirectAttributes redirectAttributes, Locale locale, @CookieValue(value = "baleroAdmin") String baleroAdmin, HttpServletRequest request) { /** * Security */ UsersAuth security = new UsersAuth(); security.setCredentials(baleroAdmin, UsersDAO); if (security.auth(baleroAdmin, security.getLocalUsername(), security.getLocalPassword()) == false) return "hacking"; if (name.equals("")) { name = "(No Title)"; } String html; html = "<p>\n" + "Lorem ipsum es el texto que se usa habitualmente en diseo grfico en demostraciones de tipografas o de borradores de diseo para probar el diseo visual antes de insertar el texto final.\n" + "\n" + "Aunque no posee actualmente fuentes para justificar sus hiptesis, el profesor de filologa clsica Richard McClintock asegura que su uso se remonta a los impresores de comienzos del siglo XVI.1 Su uso en algunos editores de texto muy conocidos en la actualidad ha dado al texto lorem ipsum nueva popularidad.\n" + "\n" + "El texto en s no tiene sentido, aunque no es completamente aleatorio, sino que deriva de un texto de Cicern en lengua latina, a cuyas palabras se les han eliminado slabas o letras.\n" + "</p>"; logger.debug("UTF-8->name: " + name); /** * Referer: * lingobit.com/solutions/java/java_localization.html */ ResourceBundle messages = ResourceBundle.getBundle("messages", locale); String slug = InitSlugifyTag.getSlugify().slugify(name); try { StaticPagesDAO.addPage(name, html, slug, locale); } catch (Exception e) { redirectAttributes.addFlashAttribute("message", messages.getString("label.page.slugerror")); } String referer = request.getHeader("Referer"); return "redirect:" + referer; }
From source file:com.salesmanager.core.util.LabelUtil.java
public String getText(Locale locale, String key, String parameter) { Iterator bundleListIterator = bundleList.iterator(); ResourceBundle myResources = null; String label = ""; while (bundleListIterator.hasNext()) { String bundle = (String) bundleListIterator.next(); try {// ww w . j a v a2 s . co m myResources = ResourceBundle.getBundle(bundle, locale); if (myResources != null) { String l = myResources.getString(key); if (l != null) { MessageFormat mFormat = new MessageFormat(l); l = mFormat.format(parameter); label = l; break; } } } catch (Exception e) { // TODO: handle exception } } return label; }
From source file:org.wso2.carbon.event.output.adaptor.http.HTTPEventAdaptor.java
private void populateAdapterMessageProps() { this.outputAdapterProps = new ArrayList<Property>(); this.outputMessageProps = new ArrayList<Property>(); ResourceBundle resourceBundle = ResourceBundle .getBundle("org.wso2.carbon.event.output.adaptor.http.i18n.Resources", Locale.getDefault()); Property urlProp = new Property(HTTPEventAdaptorConstants.ADAPTER_MESSAGE_URL); urlProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_MESSAGE_URL)); urlProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_MESSAGE_URL_HINT)); urlProp.setRequired(true);/*from www . ja v a 2 s . com*/ Property usernameProp = new Property(HTTPEventAdaptorConstants.ADAPTER_USERNAME); usernameProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_USERNAME)); usernameProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_USERNAME_HINT)); usernameProp.setRequired(false); Property passwordProp = new Property(HTTPEventAdaptorConstants.ADAPTER_PASSWORD); passwordProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PASSWORD)); passwordProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PASSWORD_HINT)); passwordProp.setRequired(false); passwordProp.setSecured(true); Property headersProp = new Property(HTTPEventAdaptorConstants.ADAPTER_HEADERS); headersProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_HEADERS)); headersProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_HEADERS_HINT)); headersProp.setRequired(false); Property proxyHostProp = new Property(HTTPEventAdaptorConstants.ADAPTER_PROXY_HOST); proxyHostProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PROXY_HOST)); proxyHostProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PROXY_HOST_HINT)); proxyHostProp.setRequired(false); Property proxyPortProp = new Property(HTTPEventAdaptorConstants.ADAPTER_PROXY_PORT); proxyPortProp.setDisplayName(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PROXY_PORT)); proxyPortProp.setHint(resourceBundle.getString(HTTPEventAdaptorConstants.ADAPTER_PROXY_PORT_HINT)); proxyPortProp.setRequired(false); this.outputMessageProps.add(urlProp); this.outputMessageProps.add(usernameProp); this.outputMessageProps.add(passwordProp); this.outputMessageProps.add(headersProp); this.outputAdapterProps.add(proxyHostProp); this.outputAdapterProps.add(proxyPortProp); }
From source file:com.salesmanager.core.util.LabelUtil.java
public String getText(Locale locale, String key, List parameters) { Iterator bundleListIterator = bundleList.iterator(); ResourceBundle myResources = null; String label = ""; while (bundleListIterator.hasNext()) { String bundle = (String) bundleListIterator.next(); try {// w w w .j a v a2 s. com myResources = ResourceBundle.getBundle(bundle, locale); if (myResources != null) { String l = myResources.getString(key); if (l != null) { MessageFormat mFormat = new MessageFormat(l); String[] params = new String[parameters.size()]; params = (String[]) parameters.toArray(params); l = mFormat.format(params); label = l; break; } } } catch (Exception e) { // Handle exception } } return label; }
From source file:eu.europa.ec.markt.dss.applet.PersonalDataPanel.java
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The * content of this method is always regenerated by the Form Editor. *//*from ww w. ja va 2 s .c om*/ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { implicitExplicitSP = new javax.swing.ButtonGroup(); claimedRoleText = new javax.swing.JTextField(); signaturePolicyOid = new javax.swing.JTextField(); implicitRadioButton = new javax.swing.JRadioButton(); explicitRadioButton = new javax.swing.JRadioButton(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); hashAlgo = new javax.swing.JComboBox(); jLabel4 = new javax.swing.JLabel(); hashValue = new javax.swing.JTextField(); includeSigPolicy = new javax.swing.JCheckBox(); includeSignerClaimedRole = new javax.swing.JCheckBox(); setBackground(new java.awt.Color(255, 255, 255)); claimedRoleText.setName("signer_claimed_role"); // NOI18N signaturePolicyOid.setName("oid"); // NOI18N implicitRadioButton.setBackground(new java.awt.Color(255, 255, 255)); implicitExplicitSP.add(implicitRadioButton); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("eu/europa/ec/markt/dss/applet/i18n"); // NOI18N implicitRadioButton.setText(bundle.getString("IMPLICIT")); // NOI18N implicitRadioButton.setName("implicit"); // NOI18N implicitRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { implicitRadioButtonActionPerformed(evt); } }); explicitRadioButton.setBackground(new java.awt.Color(255, 255, 255)); implicitExplicitSP.add(explicitRadioButton); explicitRadioButton.setText(bundle.getString("EXPLICIT")); // NOI18N explicitRadioButton.setName("explicit"); // NOI18N explicitRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { explicitRadioButtonActionPerformed(evt); } }); jLabel2.setText(bundle.getString("OID")); // NOI18N jLabel3.setText(bundle.getString("HASH_ALGORITHM")); // NOI18N hashAlgo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SHA1" })); hashAlgo.setName("hash_algo"); // NOI18N jLabel4.setText(bundle.getString("HASH_VALUE")); // NOI18N hashValue.setName("hash_value"); // NOI18N includeSigPolicy.setBackground(new java.awt.Color(255, 255, 255)); includeSigPolicy.setFont(new java.awt.Font("Tahoma", 1, 11)); includeSigPolicy.setText(bundle.getString("SIGNATURE_POLICY")); // NOI18N includeSigPolicy.setName("signature_policy_check"); // NOI18N includeSigPolicy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { includeSigPolicyActionPerformed(evt); } }); includeSignerClaimedRole.setBackground(new java.awt.Color(255, 255, 255)); includeSignerClaimedRole.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N includeSignerClaimedRole.setText(bundle.getString("CLAIMED_ROLE")); // NOI18N includeSignerClaimedRole.setName("signer_claimed_role_checkbox"); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(includeSignerClaimedRole) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(claimedRoleText, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup().addComponent(includeSigPolicy) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(explicitRadioButton).addComponent(implicitRadioButton) .addGroup(layout.createSequentialGroup().addGap(21, 21, 21) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(hashAlgo, 0, 158, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(signaturePolicyOid, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(hashValue, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))))))) .addGap(14, 14, 14))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(claimedRoleText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(includeSignerClaimedRole)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(implicitRadioButton).addComponent(includeSigPolicy)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(explicitRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(signaturePolicyOid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3).addComponent(hashAlgo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4).addComponent(hashValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(142, Short.MAX_VALUE))); }
From source file:ispok.pres.bb.VisitorEdit.java
public String update() { logger.entry();/*from ww w. java2 s . co m*/ cityService.saveCity(cityDto); postalCodeService.savePostalCode(postalCodeDto); regionService.saveRegion(regionDto); domicileDto.setCityId(cityDto.getId()); domicileDto.setPostalCodeId(postalCodeDto.getId()); domicileDto.setCountryId(countryDto.getId()); domicileDto.setRegionId(regionDto.getId()); domicileService.saveDomicile(domicileDto); visitorDto.setDomicileId(domicileDto.getId()); if (foreignerNewVal == false) { visitorDto.setCitizenshipId(countryDto.getId()); } else { visitorDto.setCitizenshipId(citizenshipDto.getId()); } logger.trace("Update visitor"); visitorService.updateVisitor(visitorDto); logger.trace("Update visitor finish"); FacesContext fc = FacesContext.getCurrentInstance(); Locale l = fc.getViewRoot().getLocale(); ResourceBundle rb = ResourceBundle.getBundle("ispok/pres/inter/ispok", l); fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, rb.getString("visitor_edit_success"), selectedVisitor.getFirstName() + " " + selectedVisitor.getLastName())); logger.exit(); return "/admin/management/visitors/visitors.xhtml"; }
From source file:edu.toronto.cs.phenotips.measurements.internal.DefaultMeasurementsChartConfigurationsFactory.java
/** * Read and return a setting from the configuration, parsing it as an {@code int} number, falling back on the * provided default value./*from w ww. j a va 2 s .c o m*/ * * @param settingName the name of the setting to read * @param defaultValue the default value to use when there's no value specified in the configuration, or the * specified value is not a valid number * @param configuration the configuration bundle with all the settings * @return the configured value, if one is configured as a valid {@code int} number, or the default value otherwise */ private int getIntSetting(String settingName, int defaultValue, ResourceBundle configuration) { int result = defaultValue; if (configuration.containsKey(settingName)) { try { result = Integer.parseInt(configuration.getString(settingName)); if (result < 0) { this.logger.warn( "Invalid chart settings for [{}]: value should be a positive integer, was [{}]", settingName, configuration.getString(settingName)); result = defaultValue; } } catch (NumberFormatException ex) { // Fall back to the default value this.logger.warn("Invalid chart settings for [{}]: invalid integer [{}]", settingName, configuration.getString(settingName)); } } return result; }