@Test void importPropertiesTest() throws IOException { I18nPropertiesConverter propsConverter = new I18nPropertiesConverter(); File file = new File(TEST_DIR, I18N_FILE); propsConverter.importTranslations("de", new FileReader(file)); file = new File(TEST_DIR, "i18n_messages_en.properties"); propsConverter.importTranslations("en", new FileReader(file)); Dictionary dictionary = propsConverter.getDictionary(); assertEquals(4, dictionary.getKeys().size()); assertEquals("In Blatt ''{0}'', Spalte {1}:''{2}'' und Zeile #{3}: {4}", dictionary.getTranslation("de", "merlin.excel.validation_error.display_all")); assertEquals("In sheet ''{0}'', column {1}:''{2}'' and row #{3}: {4}", dictionary.getTranslation("en", "merlin.excel.validation_error.display_all")); file = new File(OUT_DIR, I18N_FILE); try (Writer writer = new FileWriter(file)) { propsConverter.write("de", writer); } propsConverter = new I18nPropertiesConverter(); propsConverter.importTranslations("de", new FileReader(file)); dictionary = propsConverter.getDictionary(); assertEquals(4, dictionary.getKeys().size()); assertEquals("In Blatt ''{0}'', Spalte {1}:''{2}'' und Zeile #{3}: {4}", dictionary.getTranslation("de", "merlin.excel.validation_error.display_all")); assertEquals(null, dictionary.getTranslation("en", "merlin.excel.validation_error.display_all")); }
private void importProperties(String content, File file) throws IOException { I18nPropertiesConverter i18nPropertiesConverter = new I18nPropertiesConverter(dictionary); String basename = FilenameUtils.getBaseName(file.getName()); int pos = basename.indexOf('_'); String lang = pos >= 0 && pos < basename.length() - 1 ? basename.substring(pos + 1) : ""; log.info("Importing properties translations for lang '" + lang + "': " + file.getAbsolutePath()); try (Reader reader = new StringReader(content)) { i18nPropertiesConverter.importTranslations(lang, reader); } }
I18nConverter { private void importProperties(String content, File file) throws IOException { I18nPropertiesConverter i18nPropertiesConverter = new I18nPropertiesConverter(dictionary); String basename = FilenameUtils.getBaseName(file.getName()); int pos = basename.indexOf('_'); String lang = pos >= 0 && pos < basename.length() - 1 ? basename.substring(pos + 1) : ""; log.info("Importing properties translations for lang '" + lang + "': " + file.getAbsolutePath()); try (Reader reader = new StringReader(content)) { i18nPropertiesConverter.importTranslations(lang, reader); } } }
I18nConverter { private void importProperties(String content, File file) throws IOException { I18nPropertiesConverter i18nPropertiesConverter = new I18nPropertiesConverter(dictionary); String basename = FilenameUtils.getBaseName(file.getName()); int pos = basename.indexOf('_'); String lang = pos >= 0 && pos < basename.length() - 1 ? basename.substring(pos + 1) : ""; log.info("Importing properties translations for lang '" + lang + "': " + file.getAbsolutePath()); try (Reader reader = new StringReader(content)) { i18nPropertiesConverter.importTranslations(lang, reader); } } I18nConverter(Dictionary dictionary); }
I18nConverter { private void importProperties(String content, File file) throws IOException { I18nPropertiesConverter i18nPropertiesConverter = new I18nPropertiesConverter(dictionary); String basename = FilenameUtils.getBaseName(file.getName()); int pos = basename.indexOf('_'); String lang = pos >= 0 && pos < basename.length() - 1 ? basename.substring(pos + 1) : ""; log.info("Importing properties translations for lang '" + lang + "': " + file.getAbsolutePath()); try (Reader reader = new StringReader(content)) { i18nPropertiesConverter.importTranslations(lang, reader); } } I18nConverter(Dictionary dictionary); void importTranslations(File file); Dictionary getDictionary(); Map<File, File> getImportedFiles(); }
I18nConverter { private void importProperties(String content, File file) throws IOException { I18nPropertiesConverter i18nPropertiesConverter = new I18nPropertiesConverter(dictionary); String basename = FilenameUtils.getBaseName(file.getName()); int pos = basename.indexOf('_'); String lang = pos >= 0 && pos < basename.length() - 1 ? basename.substring(pos + 1) : ""; log.info("Importing properties translations for lang '" + lang + "': " + file.getAbsolutePath()); try (Reader reader = new StringReader(content)) { i18nPropertiesConverter.importTranslations(lang, reader); } } I18nConverter(Dictionary dictionary); void importTranslations(File file); Dictionary getDictionary(); Map<File, File> getImportedFiles();  }