We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9d7fea0 commit 2c8c165Copy full SHA for 2c8c165
googletrans/client.py
@@ -289,16 +289,17 @@ async def translate(
289
290
pron = origin
291
try:
292
- pron = data[0][1][-2]
+ # Get pronunciation from [0][1][3] which contains romanized pronunciation
293
+ if data[0][1] and len(data[0][1]) > 3:
294
+ pron = data[0][1][3]
295
+ # Fallback to previous methods if not found
296
+ elif data[0][1] and len(data[0][1]) > 2:
297
+ pron = data[0][1][2]
298
+ elif data[0][1] and len(data[0][1]) >= 2:
299
+ pron = data[0][1][-2]
300
except Exception: # pragma: nocover
301
pass
302
- if pron is None:
- try:
- pron = data[0][1][2]
- except: # pragma: nocover # noqa: E722
- pass
-
303
if dest in EXCLUDES and pron == origin:
304
pron = translated
305
0 commit comments