Skip to content

Commit

Permalink
handle several resource on Transifex
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Dec 30, 2019
1 parent 8e582e1 commit 7c41d5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions qgispluginci/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Parameters:
The organization name in Transifex
Defaults to: `organization`
transifex_resource: str
The resource name in transifex
Defaults to: the project slug
translation_source_language:
The source language for translations.
Defaults to: 'en'
Expand Down Expand Up @@ -61,6 +65,7 @@ def __init__(self, definition: dict):
self.transifex_organization = definition.get('transifex_organization', self.github_organization_slug)
self.translation_source_language = definition.get('translation_source_language', 'en')
self.translation_languages = definition.get('translation_languages', {})
self.transifex_resource = definition.get('transifex_resource', self.project_slug)
self.create_date = datetime.datetime.strptime(str(definition.get('create_date', datetime.date.today())), '%Y-%m-%d')
self.lrelease_path = definition.get('lrelease_path', 'lrelease')
self.pylupdate5_path = definition.get('pylupdate5_path', 'pylupdate5')
Expand Down
10 changes: 7 additions & 3 deletions qgispluginci/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def __get_resource(self) -> dict:
if len(resources) == 0:
raise TransifexNoResource("project '{}' has no resource on Transifex".format(self.parameters.project_slug))
if len(resources) > 1:
raise TransifexManyResources("project '{p}' has several resources on Transifex. Will use first one ({r})"
.format(p=self.parameters.project_slug,
r=resources[0]['slug']))
for resource in resources:
if resource.name == self.parameters.transifex_resource:
return resource
raise TransifexManyResources("project '{p}' has several resources on Transifex "
"and none is named as the project slug."
"Specify one in the parameters with transifex_resource"
.format(p=self.parameters.project_slug))
return resources[0]

0 comments on commit 7c41d5f

Please sign in to comment.