Skip to content

Commit cd44e4b

Browse files
authored
Merge pull request #4 from orsinium-labs/optional-googletrans
Make googletrans optional
2 parents f2a7b6d + a3f2f22 commit cd44e4b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

l10n/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
from ._locales import Locales
55

66

7-
__version__ = '0.1.1'
7+
__version__ = '0.1.2'
88
__all__ = ['Locales', 'Locale']

l10n/_commands/_translate.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pathlib import Path
33

44
import polib
5-
from googletrans import Translator
65

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

2524
def run(self) -> int:
25+
try:
26+
from googletrans import Translator
27+
except ImportError:
28+
msg = 'Please, run `python3 -m pip install googletrans==4.0.0rc1`'
29+
raise ImportError(msg)
30+
2631
project_root = find_project_root(self.args.path)
2732
project = Project(project_root)
2833
translator = Translator()

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ cli = [
3939
"mypy",
4040
"tomli",
4141
"polib",
42-
"googletrans==4.0.0rc1",
4342
]
4443
test = [
45-
"pytest",
44+
"googletrans==4.0.0rc1",
4645
"pytest-cov",
4746
"pytest-xdist",
47+
"pytest",
4848
]
4949
lint = [
5050
"flake8-length",

0 commit comments

Comments
 (0)