Skip to content

Commit

Permalink
Force utf-8 encoding writing files (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja authored Jun 10, 2022
1 parent ce75f0f commit 84a946b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.26
current_version = 0.0.27

[bumpversion:file:mkdocs_mdpo_plugin/__init__.py]

Expand Down
2 changes: 1 addition & 1 deletion mkdocs_mdpo_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""mkdocs-mdpo-plugin package"""

__version__ = '0.0.26'
__version__ = '0.0.27'
4 changes: 2 additions & 2 deletions mkdocs_mdpo_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def on_page_markdown(self, markdown, page, config, files):
][language]
temp_abs_dirpath = os.path.dirname(temp_abs_path)
os.makedirs(temp_abs_dirpath, exist_ok=True)
with open(temp_abs_path, 'w') as f:
with open(temp_abs_path, 'w', encoding='utf-8') as f:
f.write(content)

new_file = mkdocs.structure.files.File(
Expand Down Expand Up @@ -732,7 +732,7 @@ def on_post_page(self, output, page, config):
) + '/'
self.translations.locations[location] = page.file._mdpo_language

with open(render_path, 'w') as f:
with open(render_path, 'w', encoding='utf-8') as f:
f.write(output)
return output

Expand Down
16 changes: 8 additions & 8 deletions mkdocs_mdpo_plugin/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _material_patch_worker_js_files(files, language):
'/search/search_index.json',
f'/search/search_index_{language}.json',
)
with open(new_path, 'w') as f:
with open(new_path, 'w', encoding='utf-8') as f:
f.write(new_content)


Expand All @@ -100,7 +100,7 @@ def _mkdocs_patch_worker_js_files(files, language):
'search_index.json',
f'search_index_{language}.json',
)
with open(new_worker_js_path, 'w') as f:
with open(new_worker_js_path, 'w', encoding='utf-8') as f:
f.write(new_worker_js_content)

new_main_js_path = _language_extension_path(
Expand All @@ -112,7 +112,7 @@ def _mkdocs_patch_worker_js_files(files, language):
'worker.js',
f'worker_{language}.js',
)
with open(new_main_js_path, 'w') as f:
with open(new_main_js_path, 'w', encoding='utf-8') as f:
f.write(new_main_js_content)


Expand Down Expand Up @@ -142,7 +142,7 @@ def _material_patch_html_file(fpath, language, worker_files):
f'{worker_js_fname}',
f'{worker_js_fname_lang}',
)
with open(fpath, 'w') as f:
with open(fpath, 'w', encoding='utf-8') as f:
f.write(new_content)


Expand All @@ -154,7 +154,7 @@ def _mkdocs_patch_html_file(fpath, language, *args):
'search/main.js',
f'search/main_{language}.js',
)
with open(fpath, 'w') as f:
with open(fpath, 'w', encoding='utf-8') as f:
f.write(new_content)


Expand Down Expand Up @@ -206,7 +206,7 @@ def _reathedocs_patch_search_files(
f'search/main_{default_language}.js',
f'search/main_{language}.js',
)
with open(lang_search_path, 'w') as f:
with open(lang_search_path, 'w', encoding='utf-8') as f:
f.write(lang_search_path_content)

# patch search file URL in language file
Expand All @@ -216,7 +216,7 @@ def _reathedocs_patch_search_files(
'search.html',
f'search_{language}.html',
)
with open(fpath, 'w') as f:
with open(fpath, 'w', encoding='utf-8') as f:
f.write(new_content)


Expand Down Expand Up @@ -369,7 +369,7 @@ def _create_lang_search_index_json(self, language, records):
language,
)
with open(new_path, 'w') as f:
f.write(json.dumps(search_index))
json.dump(search_index, f)

def _get_html_files_by_language(self):
language_files = {language: [] for language in self.languages}
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = mkdocs_mdpo_plugin
version = 0.0.26
version = 0.0.27
description = Mkdocs plugin for translations using PO files.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit 84a946b

Please sign in to comment.