/** * Obtain the URL to the properties file containing the localized messages given the supplied bundle name. This method is * responsible for searching to find the most appropriate localized messages given the locale, but does not need to search * using the {@link Locale#getDefault() default locale} (as that is done by the {@link I18n#text(Object...) calling} method. * * @param classLoader the classloader that should be used to load the localization bundles * @param bundleName the name of the bundle of properties; never null * @param locale the locale for which the properties file URL is desired * @return the URL to the properties file containing the localized messages for the named bundle, or null if no such bundle * could be found */ public static URL getLocalizationBundle( ClassLoader classLoader, String bundleName, Locale locale ) { CheckArg.isNotNull(classLoader, "classLoader"); URL url = null; List<String> paths = getPathsToSearchForBundle(bundleName, locale); for (String path : paths) { url = classLoader.getResource(path); if (url != null) { return url; } } return url; }
URL bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, locale); if (bundleUrl == null && i18nClass == CommonI18n.class) { throw new SystemFailureException("CommonI18n.properties file not found in classpath !"); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, locale)); bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, defaultLocale); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, defaultLocale)); LOGGER.error(CommonI18n.i18nLocalizationFileNotFound, localizationBaseName); problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
URL bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, locale); if (bundleUrl == null && i18nClass == CommonI18n.class) { throw new SystemFailureException("CommonI18n.properties file not found in classpath !"); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, locale)); bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, defaultLocale); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, defaultLocale)); LOGGER.error(CommonI18n.i18nLocalizationFileNotFound, localizationBaseName); problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
URL bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, locale); if (bundleUrl == null && i18nClass == CommonI18n.class) { throw new SystemFailureException("CommonI18n.properties file not found in classpath !"); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, locale)); bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, defaultLocale); ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, defaultLocale)); LOGGER.error(CommonI18n.i18nLocalizationFileNotFound, localizationBaseName); problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
/** * Obtain the URL to the properties file containing the localized messages given the supplied bundle name. This method is * responsible for searching to find the most appropriate localized messages given the locale, but does not need to search * using the {@link Locale#getDefault() default locale} (as that is done by the {@link I18n#text(Object...) calling} method. * * @param classLoader the classloader that should be used to load the localization bundles * @param bundleName the name of the bundle of properties; never null * @param locale the locale for which the properties file URL is desired * @return the URL to the properties file containing the localized messages for the named bundle, or null if no such bundle * could be found */ public static URL getLocalizationBundle( ClassLoader classLoader, String bundleName, Locale locale ) { CheckArg.isNotNull(classLoader, "classLoader"); URL url = null; List<String> paths = getPathsToSearchForBundle(bundleName, locale); for (String path : paths) { url = classLoader.getResource(path); if (url != null) { return url; } } return url; }
/** * Obtain the URL to the properties file containing the localized messages given the supplied bundle name. This method is * responsible for searching to find the most appropriate localized messages given the locale, but does not need to search * using the {@link Locale#getDefault() default locale} (as that is done by the {@link I18n#text(Object...) calling} method. * * @param classLoader the classloader that should be used to load the localization bundles * @param bundleName the name of the bundle of properties; never null * @param locale the locale for which the properties file URL is desired * @return the URL to the properties file containing the localized messages for the named bundle, or null if no such bundle * could be found */ public static URL getLocalizationBundle( ClassLoader classLoader, String bundleName, Locale locale ) { CheckArg.isNotNull(classLoader, "classLoader"); URL url = null; List<String> paths = getPathsToSearchForBundle(bundleName, locale); for (String path : paths) { url = classLoader.getResource(path); if (url != null) { return url; } } return url; }