private String notLocalizedKey(Enum<?> key, MissingResourceException e) { String logString = "Missing Enum resource '" + key + "'."; //$NON-NLS-1$ if (e != null) { logString += " " + e.getLocalizedMessage(); } logger.warning(logString); return key.name(); }
/** Extract the value from the hard-coded configuration. * * @param key the key of the configuration entry. * @return the value. * @throws MojoExecutionException on error. */ public String getConfig(String key) throws MojoExecutionException { ResourceBundle resource = null; try { resource = ResourceBundle.getBundle( "io/sarl/maven/compiler/config", //$NON-NLS-1$ java.util.Locale.getDefault(), MavenHelper.class.getClassLoader()); } catch (MissingResourceException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } String value = resource.getString(key); if (value == null || value.isEmpty()) { value = Strings.nullToEmpty(value); this.log.warn(MessageFormat.format(Messages.MavenHelper_1, key)); } return value; }
/** * Creates a new bundle with text ressources for the given class. * @param clazz the class to create bundle for - may not be null * @throws IllegalArgumentException if class argument is null */ private TextResourceBundle(final Class<?> clazz) { if (clazz == null) { throw new IllegalArgumentException("Parameter clazz may not be null."); } this.clazz = clazz; try { final String [] superPackageNames = clazz.getPackage().getName().split("\\."); // Get name of the current package String currentPackageName = ""; if (superPackageNames.length > 0) { currentPackageName = superPackageNames[superPackageNames.length - 1]; } resourceBundle = ResourceBundle.getBundle( clazz.getPackage().getName() + "." + StringUtils.capitalize(currentPackageName) + "Texts", Locale.getDefault(), clazz.getClassLoader() ); } catch (MissingResourceException e) { log.error(e.getLocalizedMessage(), e); } }
private static ResourceBundle getResourceBundle(String packageName, String propertyFile) throws CommandException { ResourceBundle resBundle = (ResourceBundle) resourceBundles.get(packageName); if (resBundle == null) { try { resBundle = ResourceBundle.getBundle( packageName + "." + propertyFile); resourceBundles.put(packageName, resBundle); } catch(java.util.MissingResourceException mre) { throw new CommandException(mre.getLocalizedMessage()); } } return resBundle; }
/** * Obtain a localized message from one of the resource bundles associated * with this logger. * * The user supplied parameter <code>key</code> is replaced by its localized * version from the resource bundle. * * @param key unique key to identify an entry in the resource bundle. * @return The localised string according to user's locale and available resource bundles. placeholder message * if the resource bundle or key cannot be found. */ public String getString(String key) { try { return getResourceBundleString(key); } catch (MissingResourceException mre) { return mre.getLocalizedMessage() + ": [key='" + key + "']"; } }
try { strings[i] = rb.getString(strings[i]); } catch (java.util.MissingResourceException e) { strings[i] = e.getLocalizedMessage();
sb.append( ", "); return mre.getLocalizedMessage() + ": [key='" + key + "']" + sb.toString();
/** * Returns a description of the valid locations supported for annotations of this annotation validator. * <p> * A annotation validator implementation must provide the key <code>"_UI_Valid" + {@link #annotationName annotationName} + "AnnotationLocation_substitution"</code> in its {@link #getResourceLocator() resource locator} * with a very short description of the valid locations of annotations. * </p> * @return a description of the valid locations supported for annotations of this annotation validator. * @see #reportInvalidLocation(EAnnotation, DiagnosticChain, Map) */ protected String getValidLocationDescription() { String description; try { description = getString(getResourceLocator(), "_UI_Valid" + annotationName + "AnnotationLocation_substitution"); } catch (MissingResourceException exception) { EcorePlugin.INSTANCE.log(exception); description = "unknown; Implementation error for " + getClass().getName() + ":" + exception.getLocalizedMessage(); } return description; }
public static MessageFormat getMessage(String module, String error, Object[] parameters, Locale locale) { ResourceBundle rb = findBundle(locale, BUNDLE_NAME); String messageRef = module + Separator + error; String messageTemplate; try { messageTemplate = rb.getString(messageRef); } catch (MissingResourceException mre) { try { messageTemplate = RESOURCE_BUNDLE.getString(messageRef); } catch (MissingResourceException mre2) { messageTemplate = mre2.getLocalizedMessage(); // logger.trace(ExceptionToString.toString(mre)); } } // handle nonexistent template if (messageTemplate == null) { messageTemplate = "Cannot find message {0} for {1} locale"; parameters = new Object[] { messageRef, (locale == null) ? "default " : locale.getDisplayName() }; } return new MessageFormat(messageTemplate, parameters, locale); }
/** Returns the instance of the LocalStringsManager object, the caller can access all the methods in this class. @param packageName name of the package */ public static LocalStringsManager getLocalStringsManager( String packageName, String propertiesFileName) throws CommandValidationException { LocalStringsManager stringsManager = (LocalStringsManager) stringManagers.get(packageName); if ((stringsManager == null) || (!stringsManager.getPropertiesFile().equals(propertiesFileName))) { try { stringsManager = new LocalStringsManager(packageName, propertiesFileName); stringManagers.put(packageName, stringsManager); } catch(java.util.MissingResourceException mre) { //throw new CommandException(mre.getLocalizedMessage()); throw new CommandValidationException(mre.getLocalizedMessage(), mre); } } return stringsManager; }
public static boolean forceinit(FileHandle baseFileHandle) { if (GlobalConf.program == null || GlobalConf.program.LOCALE.isEmpty()) { // Use system default locale = Locale.getDefault(); } else { locale = forLanguageTag(GlobalConf.program.LOCALE); // Set as default locale Locale.setDefault(locale); } try { bundle = I18NBundle.createBundle(baseFileHandle, locale); return true; } catch (MissingResourceException e) { logger.info(e.getLocalizedMessage()); // Use default locale - en_GB locale = new Locale("en", "GB"); try { bundle = I18NBundle.createBundle(baseFileHandle, locale); } catch (Exception e2) { logger.error(e); } return false; } }
exception.getLocalizedMessage(), exception);
public ResourceBundle getResourceBundle(){ if (resourceBundle != null) return resourceBundle; // Determine the properties file location if (site == null) return null; ResourceBundle bundle = null; try { URL propertiesURL = new URL(site.getResolvedURL(), getURL()); ClassLoader l = new URLClassLoader(new URL[] { propertiesURL }, null); bundle = ResourceBundle.getBundle(IConfigurationConstants.CFG_FEATURE_ENTRY, Utils.getDefaultLocale(), l); } catch (MissingResourceException e) { Utils.log(e.getLocalizedMessage()); } catch (MalformedURLException e) { Utils.log(e.getLocalizedMessage()); } return bundle; }
Util.showInformation(ex.getLocalizedMessage()); } catch (IOException ex) { Util.showInformation(ex.getLocalizedMessage());
@Override public void set(String val) throws InvalidConfigValueException { if(val == null || get().equalsIgnoreCase(val)) return; try { NodeL10n.getBase().setLanguage(BaseL10n.LANGUAGE.mapToLanguage(val)); } catch (MissingResourceException e) { throw new InvalidConfigValueException(e.getLocalizedMessage()); } PluginManager.setLanguage(NodeL10n.getBase().getSelectedLanguage()); }
); } catch (MissingResourceException ex) { Util.showInformation(ex.getLocalizedMessage()); } catch (IOException ex) { Util.showInformation(ex.getLocalizedMessage());
exception.getLocalizedMessage(), exception);