@Test public void testExportXls() throws URISyntaxException, IOException { final Path propertiesRootDirectory= Paths.get(Resources.getResource("").toURI()); final Set<File> resourceBundleFiles= ImmutableSet.of( propertiesRootDirectory.resolve("i18n/messages.properties").toFile(), propertiesRootDirectory.resolve("i18n/messages_de.properties").toFile()); final FileMatcher fileMatcher= this.createFileMatcher(propertiesRootDirectory, resourceBundleFiles); final File xlsFile= this.tmpFolder.newFile("i18n.xlsx"); xlsFile.delete(); XlsImExporter.exportXls(fileMatcher, UTF_8, xlsFile); final XlsFile readXlsFile= new XlsFile(xlsFile); final Map<I18nBundleKey, Collection<Translation>> readContent= readXlsFile.getContent(); final XlsFile expectedXlsFile= new XlsFile(new File(Resources.getResource("i18n_expected.xlsx").toURI())); final Map<I18nBundleKey, Collection<Translation>> expectedContent= expectedXlsFile.getContent(); assertThat(readContent).hasSameSizeAs(expectedContent); assertThat(readContent).containsOnlyKeys(FluentIterable.from(expectedContent.keySet()).toArray(I18nBundleKey.class)); for (final I18nBundleKey bundleKey : readContent.keySet()) { assertThat(readContent.get(bundleKey)).containsOnly(FluentIterable.from(expectedContent.get(bundleKey)).toArray(Translation.class)); } assertThat(readContent).isEqualTo(expectedContent); }
public static void exportXls(final FileMatcher fileMatcher, final Charset propertyFileEncoding, final File xlsFile) { final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Exporting the following files to XLS(X): {}", propertyFiles); final ResourceBundleContentHelper fbcHelper= new ResourceBundleContentHelper(fileMatcher.getRoot()); final Map<String, Map<Language, File>> bundleNameToFilesMap= fbcHelper.toBundleNameToFilesMap(propertyFiles); final XlsFile xlsFileObject= new XlsFile(xlsFile); bundleNameToFilesMap.entrySet().forEach((entry) -> { final String bundleName= entry.getKey(); final Map<Language, File> bundleTranslations= entry.getValue(); final ResourceBundleContent resourceBundleContent= ResourceBundleContent.forName(bundleName) .fromFiles(bundleTranslations, propertyFileEncoding !=null ? propertyFileEncoding : UTF_8); resourceBundleContent.getContent().asMap().entrySet().forEach((e) -> { final String propertyKey= e.getKey(); final Collection<Translation> translations= e.getValue(); xlsFileObject.setValue(new I18nBundleKey(bundleName, propertyKey), translations); }); }); xlsFileObject.save(); }
XlsImExporter { public static void exportXls(final FileMatcher fileMatcher, final Charset propertyFileEncoding, final File xlsFile) { final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Exporting the following files to XLS(X): {}", propertyFiles); final ResourceBundleContentHelper fbcHelper= new ResourceBundleContentHelper(fileMatcher.getRoot()); final Map<String, Map<Language, File>> bundleNameToFilesMap= fbcHelper.toBundleNameToFilesMap(propertyFiles); final XlsFile xlsFileObject= new XlsFile(xlsFile); bundleNameToFilesMap.entrySet().forEach((entry) -> { final String bundleName= entry.getKey(); final Map<Language, File> bundleTranslations= entry.getValue(); final ResourceBundleContent resourceBundleContent= ResourceBundleContent.forName(bundleName) .fromFiles(bundleTranslations, propertyFileEncoding !=null ? propertyFileEncoding : UTF_8); resourceBundleContent.getContent().asMap().entrySet().forEach((e) -> { final String propertyKey= e.getKey(); final Collection<Translation> translations= e.getValue(); xlsFileObject.setValue(new I18nBundleKey(bundleName, propertyKey), translations); }); }); xlsFileObject.save(); } }
XlsImExporter { public static void exportXls(final FileMatcher fileMatcher, final Charset propertyFileEncoding, final File xlsFile) { final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Exporting the following files to XLS(X): {}", propertyFiles); final ResourceBundleContentHelper fbcHelper= new ResourceBundleContentHelper(fileMatcher.getRoot()); final Map<String, Map<Language, File>> bundleNameToFilesMap= fbcHelper.toBundleNameToFilesMap(propertyFiles); final XlsFile xlsFileObject= new XlsFile(xlsFile); bundleNameToFilesMap.entrySet().forEach((entry) -> { final String bundleName= entry.getKey(); final Map<Language, File> bundleTranslations= entry.getValue(); final ResourceBundleContent resourceBundleContent= ResourceBundleContent.forName(bundleName) .fromFiles(bundleTranslations, propertyFileEncoding !=null ? propertyFileEncoding : UTF_8); resourceBundleContent.getContent().asMap().entrySet().forEach((e) -> { final String propertyKey= e.getKey(); final Collection<Translation> translations= e.getValue(); xlsFileObject.setValue(new I18nBundleKey(bundleName, propertyKey), translations); }); }); xlsFileObject.save(); }  }
XlsImExporter { public static void exportXls(final FileMatcher fileMatcher, final Charset propertyFileEncoding, final File xlsFile) { final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Exporting the following files to XLS(X): {}", propertyFiles); final ResourceBundleContentHelper fbcHelper= new ResourceBundleContentHelper(fileMatcher.getRoot()); final Map<String, Map<Language, File>> bundleNameToFilesMap= fbcHelper.toBundleNameToFilesMap(propertyFiles); final XlsFile xlsFileObject= new XlsFile(xlsFile); bundleNameToFilesMap.entrySet().forEach((entry) -> { final String bundleName= entry.getKey(); final Map<Language, File> bundleTranslations= entry.getValue(); final ResourceBundleContent resourceBundleContent= ResourceBundleContent.forName(bundleName) .fromFiles(bundleTranslations, propertyFileEncoding !=null ? propertyFileEncoding : UTF_8); resourceBundleContent.getContent().asMap().entrySet().forEach((e) -> { final String propertyKey= e.getKey(); final Collection<Translation> translations= e.getValue(); xlsFileObject.setValue(new I18nBundleKey(bundleName, propertyKey), translations); }); }); xlsFileObject.save(); }  static void importXls(final FileMatcher fileMatcher,
                               final File xlsFile,
                               final Charset propertyFileEncoding,
                               final MissingKeyAction missingKeyAction); static void exportXls(final FileMatcher fileMatcher,
                               final Charset propertyFileEncoding,
                               final File xlsFile); }
XlsImExporter { public static void exportXls(final FileMatcher fileMatcher, final Charset propertyFileEncoding, final File xlsFile) { final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Exporting the following files to XLS(X): {}", propertyFiles); final ResourceBundleContentHelper fbcHelper= new ResourceBundleContentHelper(fileMatcher.getRoot()); final Map<String, Map<Language, File>> bundleNameToFilesMap= fbcHelper.toBundleNameToFilesMap(propertyFiles); final XlsFile xlsFileObject= new XlsFile(xlsFile); bundleNameToFilesMap.entrySet().forEach((entry) -> { final String bundleName= entry.getKey(); final Map<Language, File> bundleTranslations= entry.getValue(); final ResourceBundleContent resourceBundleContent= ResourceBundleContent.forName(bundleName) .fromFiles(bundleTranslations, propertyFileEncoding !=null ? propertyFileEncoding : UTF_8); resourceBundleContent.getContent().asMap().entrySet().forEach((e) -> { final String propertyKey= e.getKey(); final Collection<Translation> translations= e.getValue(); xlsFileObject.setValue(new I18nBundleKey(bundleName, propertyKey), translations); }); }); xlsFileObject.save(); }  static void importXls(final FileMatcher fileMatcher,
                               final File xlsFile,
                               final Charset propertyFileEncoding,
                               final MissingKeyAction missingKeyAction); static void exportXls(final FileMatcher fileMatcher,
                               final Charset propertyFileEncoding,
                               final File xlsFile);  }