Skip to content

Commit

Permalink
Review logging about downloading transifex files (#258)
Browse files Browse the repository at this point in the history
* Review logging about downloading transifex files

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Gustry and pre-commit-ci[bot] authored Dec 7, 2023
1 parent 90f5b5e commit 1e433d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions qgispluginci/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ def pull(self):
existing_langs.append(lang)
for lang in existing_langs:
ts_file = f"{self.parameters.plugin_path}/i18n/{self.parameters.transifex_resource}_{lang}.ts"
logger.debug(f"Downloading translation file: {ts_file}")
logger.debug(
f"Downloading translation file: {ts_file}, resource: {self.config.resource_slug}"

This comment has been minimized.

Copy link
@3nids

3nids Dec 18, 2023

Member

@Gustry this is causing an error:

Traceback (most recent call last):
  File "/home/runner/work/qgis-plugin-ci/qgis-plugin-ci/test/test_translation.py", line 68, in test_pull
    self.t.pull()
  File "/home/runner/work/qgis-plugin-ci/qgis-plugin-ci/qgispluginci/translation.py", line 142, in pull
    f"Downloading translation file: {ts_file}, resource: {self.config.resource_slug}"
AttributeError: 'Translation' object has no attribute 'config'

This comment has been minimized.

Copy link
@Gustry

Gustry Dec 18, 2023

Author Collaborator

Hum, strange, looking at this issue.
Sorry

)
self.tx_client.get_translation(
language_code=lang,
path_to_output_file=ts_file,
)

def push(self):
resource = self.tx_client.get_resource()
self.tx_client.get_resource()
logger.debug(
f"Pushing resource: {self.parameters.transifex_resource} "
f"with file {self.ts_file}"
Expand Down
8 changes: 4 additions & 4 deletions qgispluginci/translation_clients/transifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ def get_translation(
)

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.
# 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)

logger.info(
f"Translations downloaded and written to file (resource: {self.config.resource_slug})"
)
logger.info(f"Translations '{language_code}' downloaded")
return str(path_to_output_file)

0 comments on commit 1e433d2

Please sign in to comment.