/** * Get a plugin bundle using the supplied Locale and classLoader * * @param baseName The bundle base name. * @param locale The Locale. * @param classLoader The classLoader * @return The bundle JSON. */ private static @CheckForNull ResourceBundle getBundle(@Nonnull String baseName, @Nonnull Locale locale, @Nonnull ClassLoader classLoader) { try { return ResourceBundle.getBundle(baseName, locale, classLoader); } catch (MissingResourceException e) { // fall through and return null. logger.finer(e.getMessage()); } return null; }
public final ResourceBundle apply(final String resourceName) { if (resourceName == null || "".equals(resourceName.trim())) { throw new IllegalArgumentException("resourceName must not be null or empty!"); } try { return ResourceBundle.getBundle(resourceName); } catch (final MissingResourceException e) { logger.warn(e.getMessage()); return EMPTY_RESOURCE_BUNDLE; } }
logger.warn("ResourceBundle [" + basename + "] not found for MessageSource: " + ex.getMessage());
/** * Returns an internationalized string loaded from a resource bundle. * The locale used will be the locale specified by JiveGlobals.getLocale(). * * @param key the key to use for retrieving the string from the * appropriate resource bundle. * @return the localized string. */ public static String getLocalizedString(String key) { Locale locale = JiveGlobals.getLocale(); try { ResourceBundle bundle = ResourceBundle.getBundle(resourceBaseName, locale); return getLocalizedString(key, locale, null, bundle); } catch (MissingResourceException mre) { Log.error(mre.getMessage()); return key; } }
logger.warn("ResourceBundle [" + basename + "] not found for MessageSource: " + ex.getMessage());
/** * Prepares all statements to be used. * * @throws DatabaseException thrown if there is an error preparing the * statements */ private void prepareStatements() throws DatabaseException { for (PreparedStatementCveDb key : values()) { PreparedStatement preparedStatement = null; try { final String statementString = statementBundle.getString(key.name()); if (key == INSERT_VULNERABILITY || key == INSERT_CPE) { preparedStatement = connection.prepareStatement(statementString, new String[]{"id"}); } else { preparedStatement = connection.prepareStatement(statementString); } } catch (SQLException ex) { throw new DatabaseException(ex); } catch (MissingResourceException ex) { if (!ex.getMessage().contains("key MERGE_PROPERTY")) { throw new DatabaseException(ex); } } if (preparedStatement != null) { preparedStatements.put(key, preparedStatement); } } }
Log.error(mre.getMessage());
Log.error(mre.getMessage(), mre); return key;
} catch ( MissingResourceException e ) { log.logError( BaseMessages.getString( PKG, "XulDatabaseDialog.Error.ResourcesNotFound.Title" ), e.getMessage(), e );
public void setLocale(Locale locale) { try { this.resources = ResourceBundle.getBundle("org.apache.xmlbeans.impl.regex.message", locale); } catch (MissingResourceException mre) { throw new RuntimeException("Installation Problem??? Couldn't load messages: " +mre.getMessage()); } }
/** * Returns the resource for the key passed in parameters. * <p> * If the key is not found, returns an empty string. * </p> * * @param key a String representing the key we want to get the resource from. * @return The text corresponding to the key passed in parameters, or an empty string if not found. */ public String get(String key) { try { return resources.getString(key); } catch (MissingResourceException e) { logger.error("{}", e.getMessage()); return ""; } } }
/** * Initializes resource bundle with the JVM's default locale. * <p> * If the JVM's default locale doesn't have any resource file, will take the en_US resources instead. * </p> */ I18n() { ResourceBundle bundle; try { bundle = ResourceBundle.getBundle(I18n.RESOURCE_FILE, Locale.getDefault()); } catch (MissingResourceException mre) { logger.error("{}", mre.getMessage()); logger.info("Will use default bundle (en_US) instead"); bundle = ResourceBundle.getBundle(I18n.RESOURCE_FILE, Locale.US); } resources = bundle; }
/** * Tries to format a message using the error code. */ public static String formattedMessage(String code, Object[] args) { if (code == null) return null; String message; try { message = MessageFormat.format(_bundle.getString(code), args); } catch (java.util.MissingResourceException e) { return MessageFormat.format(_bundle.getString("message.missing.resource"), new Object[] { e.getMessage() }); } catch (IllegalArgumentException e) { return MessageFormat.format(_bundle.getString("message.pattern.invalid"), new Object[] { e.getMessage() }); } return message; }
/** * Gets a value from baseName_locale.properties file with the specified key. If not found * baseName_(locale).properties configurations, using {@link Latkes#getLocale()} instead. * * @param baseName base name of resource bundle, options as the following: * <ul> * <li>{@link Keys#LANGUAGE}</li> * </ul> * @param key the specified key * @param locale the specified locale * @return the value of the specified key */ private String get(final String baseName, final String key, final Locale locale) { if (!Keys.LANGUAGE.equals(baseName)) { final RuntimeException e = new RuntimeException("i18n resource [baseName=" + baseName + "] not found"); LOGGER.log(Level.ERROR, e.getMessage(), e); throw e; } try { return replaceVars(ResourceBundle.getBundle(baseName, locale).getString(key)); } catch (final MissingResourceException e) { LOGGER.log(Level.WARN, "{0}, get it from default locale [{1}]", e.getMessage(), Latkes.getLocale()); return replaceVars(ResourceBundle.getBundle(baseName, Latkes.getLocale()).getString(key)); } }
ResourceBundle loadBundle(String packageName) { try { return ResourceBundle.getBundle(packageName + '.' + _resourceName, _locale, _loader); } catch (MissingResourceException e) { // Deliberately surpressing print stack.. just the string for info. log.debug("loadBundle: Ignoring MissingResourceException: " + e.getMessage()); } return null; }
public String getString(String key) { try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { System.err.println(e.getMessage()); return '!' + key + '!'; } } }
ResourceBundle loadBundle(String packageName) { try { return ResourceBundle.getBundle(packageName + '.' + _resourceName, _locale, _loader); } catch (MissingResourceException e) { // Deliberately surpressing print stack.. just the string for info. log.debug("loadBundle: Ignoring MissingResourceException: " + e.getMessage()); } return null; }
ResourceBundle loadBundle(String packageName) { try { return ResourceBundle.getBundle(packageName + '.' + _resourceName, _locale, _loader); } catch (MissingResourceException e) { // Deliberately surpressing print stack.. just the string for info. log.debug("loadBundle: Ignoring MissingResourceException: " + e.getMessage()); } return null; }
public static String getStringFromBundle(String key, List<String> arguments, ResourceBundle bundle) { try { return getStringFromBundleNoMissingCheck(key, arguments, bundle); } catch (MissingResourceException ex) { logger.warning("Could not find key \"" + key + "\" in bundle file: "); logger.log(Level.CONFIG, ex.getMessage(), ex); return null; } }
private static String getLocalString( final Message message, final String field, final Locale locale, final Configuration config ) { try { return Message.getLocalizedMessage( locale, message, config, field ); } catch ( MissingResourceException e ) { LOGGER.error( "unable to display requirement tag for message '" + message.toString() + "': " + e.getMessage() ); } return "UNKNOWN MESSAGE STRING"; }