List of usage examples for java.util MissingResourceException getMessage
public String getMessage()
From source file:ch.entwine.weblounge.common.impl.language.LanguageUtils.java
/** * Returns the language object that represents the given locale. * //from w w w . j ava2 s . c om * @param locale * the locale * @return the language * @throws UnknownLanguageException * if there is no language for the given locale */ public static Language getLanguage(Locale locale) throws UnknownLanguageException { // Do we know this language already? Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; // Makes sure we get the locale in the right format (might be hand crafted) Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } // Check the system locales for a match Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } // Is there a matching system locale? if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } // Apparently not... throw new UnknownLanguageException(locale.getLanguage()); }
From source file:edu.ualberta.med.biobank.reporting.DynamicJasperHelper.java
private final static void registerEntities(DynamicJasperDesign jd, DynamicReport dr, LayoutManager layoutManager) { ColumnRegistrationManager columnRegistrationManager = new ColumnRegistrationManager(jd, dr, layoutManager); columnRegistrationManager.registerEntities(dr.getColumns()); DJGroupRegistrationManager djGroupRegistrationManager = new DJGroupRegistrationManager(jd, dr, layoutManager);/* w ww .j a v a 2s. c o m*/ djGroupRegistrationManager.registerEntities(dr.getColumnsGroups()); registerPercentageColumnsVariables(jd, dr, layoutManager); registerOtherFields(jd, dr.getFields()); Locale locale = dr.getReportLocale() == null ? Locale.getDefault() : dr.getReportLocale(); if (log.isDebugEnabled()) { log.debug("Requested Locale = " + dr.getReportLocale() //$NON-NLS-1$ + ", Locale to use: " + locale); //$NON-NLS-1$ } ResourceBundle messages = null; if (dr.getResourceBundle() != null) { try { messages = ResourceBundle.getBundle(dr.getResourceBundle(), locale); } catch (MissingResourceException e) { log.warn(e.getMessage() + ", usign default (dj-messages)"); //$NON-NLS-1$ } } if (messages == null) { try { messages = ResourceBundle.getBundle(DJ_RESOURCE_BUNDLE, locale); } catch (MissingResourceException e) { log.warn(e.getMessage() + ", usign default (dj-messages)"); //$NON-NLS-1$ try { messages = ResourceBundle.getBundle(DJ_RESOURCE_BUNDLE, Locale.ENGLISH); // this cannot fail because is included // in the DJ jar } catch (MissingResourceException e2) { log.error("Default messajes not found: " //$NON-NLS-1$ + DJ_RESOURCE_BUNDLE + ", " + e2.getMessage(), e2); //$NON-NLS-1$ throw new DJException("Default messajes file not found: " //$NON-NLS-1$ + DJ_RESOURCE_BUNDLE + "en.properties", e2); //$NON-NLS-1$ } } } jd.getParametersWithValues().put(JRDesignParameter.REPORT_RESOURCE_BUNDLE, messages); jd.getParametersWithValues().put(JRDesignParameter.REPORT_LOCALE, locale); // JRDesignParameter.REPORT_RESOURCE_BUNDLE // report. }
From source file:modelibra.swing.app.config.NatLang.java
/** * Gets the text based on a given text key for the current language. * /* w w w . j a va2 s. co m*/ * @param key * text key * @return current language text */ public String getText(String key) { String lookFor = null; try { lookFor = resource.getString(key); } catch (MissingResourceException e) { System.out.println(e.getMessage() + " // Missing string: " + key); lookFor = "Missing string: " + key; } return lookFor; }
From source file:org.modelibra.util.NatLang.java
/** * Sets the language with the location for text resources. * /*from w w w . j a va 2 s . com*/ * @param language * language * @param textResources * text resources */ public void setNaturalLanguage(String language, String textResources) { try { if ((language == null) || (language.equals("en"))) { locale = Locale.ENGLISH; } else if (language.equals("fr")) { locale = Locale.FRENCH; } else if (language.equals("ba")) { locale = new Locale("ba"); // bosnian language } else if (language.equals("hr")) { locale = new Locale("hr"); // croatian language } else if (language.equals("sr")) { locale = new Locale("sr"); // serbian language } else { // other languages are not supported, English used locale = Locale.ENGLISH; } resource = ResourceBundle.getBundle(textResources, locale); } catch (MissingResourceException e) { System.out.println(e.getMessage()); } }
From source file:modelibra.swing.app.config.NatLang.java
/** * Sets the language with the location for text resources. * //from w w w. ja va 2 s . c o m * @param language * language * @param textResources * text resources */ public void setNaturalLanguage(String language, String textResources) { try { if ((language == null) || (language.equals("en"))) { locale = Locale.ENGLISH; } else if (language.equals("fr")) { locale = Locale.FRENCH; } else if (language.equals("ba")) { locale = new Locale("ba"); // bosnian language } else if (language.equals("hr")) { locale = new Locale("hr"); // croatian language } else if (language.equals("sr")) { locale = new Locale("sr"); // serbian language } else { // other languages are not supported, English used locale = Locale.ENGLISH; } resource = ResourceBundle.getBundle(textResources, locale); } catch (MissingResourceException e) { System.out.println(e.getMessage()); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:de.awtools.lang.Translator.java
/** * Liefert die bersetzung fr einen String. Das Array der * <code>replaces</code> ersetzt alle Vorkommen von {0}...{n}. * * @param key Der Schlssel.//from w ww . j a v a 2 s . c om * @param replaces Die Ersetzungen. * @return Die bersetzung. */ public String getString(final String key, final Object... replaces) { String text; try { text = (bundle.getString(key)); } catch (MissingResourceException ex) { log.debug(ex.getMessage()); text = key; } if (replaces != null && replaces.length > 0) { text = (MessageFormat.format(text, replaces)); } return text; }
From source file:eu.dasish.annotation.backend.rest.ProjectInfoResource.java
/** * /*from ww w . j a v a 2 s . c o m*/ * @return a message string containing the number of the version of the backend. * @throws IOException if getting a principal or sending an error fails. */ @GET @Produces(MediaType.TEXT_PLAIN) @Path("version") @Transactional(readOnly = true) public String getVersion() throws IOException { Number principalID = this.getPrincipalID(); String retVal = "?.?"; ResourceBundle rb; try { rb = ResourceBundle.getBundle("projectinfo"); retVal = rb.getString("application.version"); } catch (MissingResourceException e) { httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } return "DWAN backend " + retVal; }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolver.java
private String resolvePlainDescription(Constraint constraint) { try {//w w w .jav a 2 s . c o m return delegate.resolveDescription(constraint); } catch (MissingResourceException e) { log.warn("No description found for constraint {}: {}", constraint.getName(), e.getMessage()); return ""; } }
From source file:org.silverpeas.core.contribution.model.ContributionLocalizationBundle.java
private String getStringWithParams(final String key, Object... params) { if (componentBundle != null) { try {/*from ww w .ja va 2s . co m*/ return componentBundle.getStringWithParams(key, params); } catch (MissingResourceException mre) { SilverLogger.getLogger(this).silent(mre).debug(mre.getMessage()); } } return mainBundle.getStringWithParams(key, params); }
From source file:de.xirp.util.ResourceBundleWrapper.java
/** * Gets the string for the given key in the current {@link Locale}.<br> * If the key is empty or <code>null</code> an empty string is * returned.// w w w. j a v a2s .c om * * @param key * key to get the string for * @return translated string for given key. If no translation for * the given key is found the key surrounded by * <code>!</code> is returned. */ public String getString(String key) { if (StringUtils.isEmpty(key)) { return ""; //$NON-NLS-1$ } try { return resourceBundle.getString(key); } catch (MissingResourceException e) { logClass.trace("Translation error at key '" + key + "', " + e.getMessage() + Constants.LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$ return '!' + key + '!'; } catch (NullPointerException e) { logClass.trace("Translation error at key '" + key + "'" + Constants.LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$ return '!' + key + '!'; } }