Skip to content

Commit

Permalink
Merge pull request #4 from orsinium-labs/optional-googletrans
Browse files Browse the repository at this point in the history
Make googletrans optional
  • Loading branch information
orsinium authored Jul 25, 2023
2 parents f2a7b6d + a3f2f22 commit cd44e4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion l10n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from ._locales import Locales


__version__ = '0.1.1'
__version__ = '0.1.2'
__all__ = ['Locales', 'Locale']
7 changes: 6 additions & 1 deletion l10n/_commands/_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pathlib import Path

import polib
from googletrans import Translator

from .._project import Project, find_project_root
from ._base import Command
Expand All @@ -23,6 +22,12 @@ def init_parser(parser: ArgumentParser) -> None:
)

def run(self) -> int:
try:
from googletrans import Translator
except ImportError:
msg = 'Please, run `python3 -m pip install googletrans==4.0.0rc1`'
raise ImportError(msg)

project_root = find_project_root(self.args.path)
project = Project(project_root)
translator = Translator()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ cli = [
"mypy",
"tomli",
"polib",
"googletrans==4.0.0rc1",
]
test = [
"pytest",
"googletrans==4.0.0rc1",
"pytest-cov",
"pytest-xdist",
"pytest",
]
lint = [
"flake8-length",
Expand Down

0 comments on commit cd44e4b

Please sign in to comment.