File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""Other Scratch API-related functions"""
2
2
3
3
import json
4
- import warnings
5
4
6
5
from ..utils import commons
7
6
from ..utils .exceptions import BadRequest , InvalidLanguage , InvalidTTSGender
@@ -157,7 +156,10 @@ def translate(language: str | Languages, text: str = "hello"):
157
156
lang = language
158
157
159
158
if not isinstance (lang , Language ):
160
- raise InvalidLanguage (f"{ language } is not a supported translate language" )
159
+ raise InvalidLanguage (f"{ language } is not a language" )
160
+
161
+ if lang .code is None :
162
+ raise InvalidLanguage (f"{ lang } is not a valid translate language" )
161
163
162
164
response_json = requests .get (
163
165
f"https://translate-service.scratch.mit.edu/translate?language={ lang .code } &text={ text } " ).json ()
You can’t perform that action at this time.
0 commit comments