Skip to content

Commit

Permalink
Merge pull request #110 from MattFellows/master
Browse files Browse the repository at this point in the history
feat: Adds region argument to command line invocation via APIs that r…
  • Loading branch information
terryyin authored Mar 28, 2024
2 parents 2f099e1 + a504af0 commit 1e3ab22
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
---------
3.7.0
-----

* Adds region flag to CLI

3.6.1
-----
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Options
--secret_access_key TEXT Set the secret access key used to get provider
oAuth token.
-o, --output_only Set to display the translation only.
-r, --region TEXT Set to pass a region in to API calls that require it.
--help Show this message and exit.
Expand Down
7 changes: 7 additions & 0 deletions translate/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ def config_file(ctx, from_lang, to_lang, provider, secret_access_key):
help="Set to use DeepL's pro API.",
required=False,
)
@click.option(
'region', '--region', '-r',
default=get_config_info('region'),
help="Region for apis",
required=False,
)
@click.argument('text', nargs=-1, type=click.STRING, required=True)
def main(from_lang, to_lang, provider, secret_access_key, output_only, pro, text):
"""
Expand All @@ -163,6 +169,7 @@ def main(from_lang, to_lang, provider, secret_access_key, output_only, pro, text
if provider != DEFAULT_PROVIDER:
kwargs['secret_access_key'] = secret_access_key
kwargs['pro'] = pro
kwargs['region'] = region

translator = Translator(**kwargs)
translation = translator.translate(text)
Expand Down
2 changes: 1 addition & 1 deletion translate/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.6.1"
__version__ = "3.7.0"

0 comments on commit 1e3ab22

Please sign in to comment.