use of org.phoenicis.configuration.localisation.PropertiesResourceBundle in project POL-POM-5 by PlayOnLinux.
the class LocalRepository method fetchInstallableApplications.
@Override
public RepositoryDTO fetchInstallableApplications() {
if (!repositoryDirectory.exists()) {
throw new RepositoryException(String.format("Repository %s directory does not exist.", repositoryDirectory));
}
final File[] typeDirectories = repositoryDirectory.listFiles();
if (typeDirectories == null) {
return new RepositoryDTO.Builder().build();
}
LOGGER.info("Reading directory : " + repositoryDirectory);
final RepositoryDTO.Builder repositoryDTOBuilder = new RepositoryDTO.Builder().withName(repositoryDirectory.getName()).withTypes(fetchTypes(typeDirectories));
final File i18nDirectory = new File(repositoryDirectory, "i18n");
if (i18nDirectory.exists()) {
final File[] translationFiles = i18nDirectory.listFiles((dir, name) -> name.endsWith(Locale.getDefault().getLanguage() + ".properties"));
Properties mergedProperties = new Properties();
for (File translationFile : translationFiles) {
try {
Properties langProperties = new Properties();
langProperties.load(new FileInputStream(translationFile));
mergedProperties.putAll(langProperties);
} catch (IOException e) {
LOGGER.error("Could not read translation properties", e);
}
}
repositoryDTOBuilder.withTranslations(new TranslationDTO.Builder().withLanguage(Locale.getDefault().getLanguage()).withProperties(mergedProperties).build());
Localisation.setAdditionalTranslations(new PropertiesResourceBundle(mergedProperties));
}
return repositoryDTOBuilder.build();
}
Aggregations