Skip to content

Commit

Permalink
Set encoding of request.get result to utf-8 (#222)
Browse files Browse the repository at this point in the history
* set encoding of  result to utf-8. This fixes that the encoding of umlauts where broken in the ts files.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* comment why we set the encoding hardcoded

* check if request response encoding is None before setting it static to utf-8

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
signedav and pre-commit-ci[bot] authored Apr 19, 2023
1 parent 64a6d59 commit d3c1ec7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qgispluginci/translation_clients/transifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def get_translation(
resource=self.get_resource(), language=language
)

translated_content = requests.get(url).text
r = requests.get(url)
# transifex returns None encoding and the apparent_encoding is Windows-1254 what leads to malformed result strings. So we set the encoding hardcoded to utf-8.
if not r.encoding:
r.encoding = "utf-8"
translated_content = r.text
with open(path_to_output_file, "w") as fh:
fh.write(translated_content)

Expand Down

0 comments on commit d3c1ec7

Please sign in to comment.