/** * Gets a human readable message for the given Win32 error code. * * @return * null if no such message is available. */ @CheckForNull public static String getWin32ErrorMessage(int n) { try { ResourceBundle rb = ResourceBundle.getBundle("/hudson/win32errors"); return rb.getString("error"+n); } catch (MissingResourceException e) { LOGGER.log(Level.WARNING,"Failed to find resource bundle",e); return null; } }
private static ResourceBundle getResourceBundle(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } return ResourceBundle.getBundle(RESOURCE_NAME, locale); } }
throws MissingResourceException Locale locale = Locale.getDefault(); return (ListResourceBundle)ResourceBundle.getBundle(className, locale); return (ListResourceBundle)ResourceBundle.getBundle( className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles." + className, className, "");
locale = Locale.getDefault(); if (null == (rb = (ResourceBundle) threadMap.get(locale.toString()))) { rb = ResourceBundle.getBundle("javax.el.PrivateMessages", locale); threadMap.put(locale.toString(), rb); result = rb.getString(messageId); if (null != params) { result = MessageFormat.format(result, params);
/** * Gets the ResourceBundle AKA language package. * Used for choosing the language of the UI. * * @return Returns the default resource bundle using the language specified in the config file. */ public static ResourceBundle getResourceBundle(String langSelect) { if (langSelect == null) { if (!getConfigString("lang", "").equals("")) { String[] langCode = getConfigString("lang", "").split("_"); LOGGER.info("Setting locale to " + getConfigString("lang", "")); return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control()); } } else { String[] langCode = langSelect.split("_"); LOGGER.info("Setting locale to " + langSelect); return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control()); } try { LOGGER.info("Setting locale to default"); return ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control()); } catch (MissingResourceException e) { LOGGER.info("Setting locale to root"); return ResourceBundle.getBundle("LabelsBundle", Locale.ROOT); } }
@Test public void testSetResourceBundle_overwritesSubcommandBundle() { Locale original = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); try { assertArgsHaveBundle(orig, help.getCommandSpec().positionalParameters()); ResourceBundle update = ResourceBundle.getBundle("picocli.I18nSuperclass_Messages"); assertNotSame(update, orig); assertNotEquals(orig.getString("usage.header"), update.getString("usage.header"));
/** * Method init * * @param languageCode * @param countryCode */ public static synchronized void init(String languageCode, String countryCode) { if (alreadyInitialized) { return; } I18n.resourceBundle = ResourceBundle.getBundle( Constants.exceptionMessagesResourceBundleBase, new Locale(languageCode, countryCode) ); alreadyInitialized = true; }
if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { throw new MissingResourceException("Failed to load the specified resource bundle \"" + resourceBundleName + "\"", resourceBundleName, null);
@Override public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) { String basename = (String) args.get("bundle"); String key = (String) args.get("key"); Object params = args.get("params"); Locale locale = context.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle(basename, locale, new UTF8Control()); Object phraseObject = bundle.getObject(key); if (params != null) { if (params instanceof List) { List<?> list = (List<?>) params; return MessageFormat.format(phraseObject.toString(), list.toArray()); } else { return MessageFormat.format(phraseObject.toString(), params); } } return phraseObject; }
return (XResourceBundle) ResourceBundle.getBundle(resourceName, locale); return (XResourceBundle) ResourceBundle.getBundle( XSLT_RESOURCE, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles.", className, "");
/** * Returns a {@link ResourceBundle} corresponding to the given {@link Locale} package and resource class. Falls-back * on the ROOT {@link Locale}, if the {@code fallbackOnRoot} flag is true and the requested Locale is not available. * * @param locale the {@link Locale} for which the {@link ResourceBundle} is being requested * @param packagePath * @param resourceClass * @param fallbackOnRoot if true, and a {@link ResourceBundle} cannot be found for the requested {@link Locale}, falls * back on the ROOT {@link Locale} * @return a {@link ResourceBundle} corresponding to the given {@link Locale} package and resource class */ public static ResourceBundle getBundle( final Locale locale, final String packagePath, final Class<?> resourceClass, final boolean fallbackOnRoot ) { final GlobalMessageControl control = new GlobalMessageControl( fallbackOnRoot ); final String resourceName = control.toResourceName( control.toBundleName( packagePath, locale ), "properties" ); ResourceBundle bundle; try { bundle = ResourceBundle.getBundle( packagePath, locale, resourceClass.getClassLoader(), new GlobalMessageControl( fallbackOnRoot ) ); } catch ( final MissingResourceException e ) { final StringBuilder msg = new StringBuilder(); msg.append( "Unable to find properties file '" ).append( resourceName ).append( "': " ).append( e.toString() ); throw new MissingResourceException( msg.toString(), resourceClass.getName(), packagePath ); } return bundle; }
Locale locale = Locale.getDefault(); String suffix = getResourceSuffix(locale); return (XPATHErrorResources) ResourceBundle.getBundle(className + suffix, locale); return (XPATHErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles.", className, "");
/** * Gets the check message 'as is' from appropriate 'messages.properties' * file. * * @param messageBundle the bundle name. * @param messageKey the key of message in 'messages.properties' file. * @param arguments the arguments of message in 'messages.properties' file. * @return The message of the check with the arguments applied. */ private static String internalGetCheckMessage( String messageBundle, String messageKey, Object... arguments) { final ResourceBundle resourceBundle = ResourceBundle.getBundle( messageBundle, Locale.getDefault(), Thread.currentThread().getContextClassLoader(), new LocalizedMessage.Utf8Control()); final String pattern = resourceBundle.getString(messageKey); final MessageFormat formatter = new MessageFormat(pattern, Locale.ROOT); return formatter.format(arguments); }
private GT() { try { //JCP! if mvn.project.property.postgresql.jdbc.spec < "JDBC4.1" //JCP> _bundle = ResourceBundle.getBundle("org.postgresql.translation.messages"); //JCP! else _bundle = ResourceBundle.getBundle("org.postgresql.translation.messages", Locale.getDefault(Locale.Category.DISPLAY)); //JCP! endif } catch (MissingResourceException mre) { // translation files have not been installed _bundle = null; } }
/** * Gets the resource bundle for the specified language. * @param languageCode lowercase two-letter ISO-639 code. * @return the resource bundle for the specified language. */ public static ResourceBundle getMessages(String languageCode) { if (languageCode.length() > 3) { throw new RuntimeException("Use a character code (ISO-639 code), not a full language name: " + languageCode); } ResourceBundle messages = ResourceBundle.getBundle( JLanguageTool.MESSAGE_BUNDLE, new Locale(languageCode)); return messages; }
Locale locale = Locale.getDefault(); String suffix = getResourceSuffix(locale); return (XSLTErrorResources) ResourceBundle.getBundle(className + suffix, locale); return (XSLTErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles.", className, "");