@Override protected void handleFile(final File file, final int depth, final Collection<File> results) throws IOException { final String localeCode = LocaleResolver.resolveLocaleCode(file); propertiesToLocale.put(file, localeCode); } };
/** * Resolves the {@link Locale} object from the given locale code. If the given default locale is * not null and the locale code does resolve to no locale the default locale will be returned. * * @param localeCode * the locale code * @param defaultLocale * the default locale * @param systemsDefault * if this flag is true the systems default locale will be taken if not found * otherwise not * @return the {@link Locale} object or null if not found and flag systemsDefault is false and * defaultLocale is null. */ public static Locale resolveLocale(final String localeCode, final Locale defaultLocale, final boolean systemsDefault) { Locale current = resolveLocaleCode(localeCode); if (current == null && defaultLocale != null) { current = defaultLocale; } if (current == null && systemsDefault) { current = Locale.getDefault(); } return current; }
@Override public String getString(final BundleApplication bundleApplication, final String baseName, final String locale, final String key, final String defaultValue) { final BundleApplications owner = resourcebundlesService.find(bundleApplication.getName()); final Resourcebundles resourcebundles = resourcebundlesService.getResourcebundle(owner, baseName, LocaleResolver.resolveLocaleCode(locale), key); if (resourcebundles != null) { Resourcebundle domainObject = getMapper().toDomainObject(resourcebundles); return domainObject.getValue().getName(); } return defaultValue; }
@Override public String getString(final BundleApplication bundleApplication, final String baseName, final String locale, final String key) { final BundleApplications owner = resourcebundlesService.find(bundleApplication.getName()); final Resourcebundles resourcebundles = resourcebundlesService.getResourcebundle(owner, baseName, LocaleResolver.resolveLocaleCode(locale), key); if (resourcebundles != null) { Resourcebundle domainObject = getMapper().toDomainObject(resourcebundles); return domainObject.getValue().getName(); } return ""; }
@Override public String getString(final BundleApplication bundleApplication, final String baseName, final String locale, final String key, final Object[] parameters) { final BundleApplications owner = resourcebundlesService.find(bundleApplication.getName()); final Resourcebundles resourcebundles = resourcebundlesService.getResourcebundle(owner, baseName, LocaleResolver.resolveLocaleCode(locale), key); String value = ""; if (resourcebundles != null) { Resourcebundle domainObject = getMapper().toDomainObject(resourcebundles); value = domainObject.getValue().getName(); value = ResourceBundleExtensions.format(value, parameters); } return value; }
@Override public String getString(final BundleApplication bundleApplication, final String baseName, final String locale, final String key, final String defaultValue, final Object[] parameters) { final BundleApplications owner = resourcebundlesService.find(bundleApplication.getName()); final Resourcebundles resourcebundles = resourcebundlesService.getResourcebundle(owner, baseName, LocaleResolver.resolveLocaleCode(locale), key); String value = defaultValue; if (resourcebundles != null) { Resourcebundle domainObject = getMapper().toDomainObject(resourcebundles); value = domainObject.getValue().getName(); value = ResourceBundleExtensions.format(value, parameters); } return value; }