diff --git a/i18n-tools/scripts/common.py b/i18n-tools/scripts/common.py index cc953757..4dde1449 100644 --- a/i18n-tools/scripts/common.py +++ b/i18n-tools/scripts/common.py @@ -99,7 +99,7 @@ class TemplateFile: """ def merge_and_save(self): self.previous_catalog.merge(self.current_catalog) - self.previous_catalog.save(self.file_name) + self.previous_catalog.save(self.file_name, newline='\n') """ Wrapper class over POFile, acting as language translation file @@ -135,7 +135,7 @@ class LanguageFile: """ def merge_and_save(self, template_file): self.catalog.merge(template_file.current_catalog) - self.catalog.save(self.file_name) + self.catalog.save(self.file_name, newline='\n') """ Locates the translation files in po_dir @@ -208,9 +208,9 @@ class TranslationJob: self._close_files() def _open_files(self): - self._input_file = io.open(self._input_file_name, 'r', encoding='utf-8') + self._input_file = io.open(self._input_file_name, 'r', encoding='utf-8', newline='\n') if self._output_file_name: - self._output_file = io.open(self._output_file_name, 'w', encoding='utf-8') + self._output_file = io.open(self._output_file_name, 'w', encoding='utf-8', newline='\n') def _close_files(self): self._input_file.close() diff --git a/i18n-tools/scripts/polib.py b/i18n-tools/scripts/polib.py index 5f0f727d..094bdad3 100644 --- a/i18n-tools/scripts/polib.py +++ b/i18n-tools/scripts/polib.py @@ -405,7 +405,7 @@ class _BaseFile(list): e.flags.append('fuzzy') return e - def save(self, fpath=None, repr_method='__unicode__'): + def save(self, fpath=None, repr_method='__unicode__', newline=None): """ Saves the po file to ``fpath``. If it is an existing file and no ``fpath`` is provided, then the @@ -427,7 +427,7 @@ class _BaseFile(list): if repr_method == 'to_binary': fhandle = open(fpath, 'wb') else: - fhandle = io.open(fpath, 'w', encoding=self.encoding) + fhandle = io.open(fpath, 'w', encoding=self.encoding, newline=newline) if not isinstance(contents, text_type): contents = contents.decode(self.encoding) fhandle.write(contents)