Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
the lazy dog -> 게으른 개
"""
dest = dest.lower().split('_', 1)[0]
src = src.lower().split('_', 1)[0]
if src != 'auto' and src not in LANGUAGES:
if src in SPECIAL_CASES:
src = SPECIAL_CASES[src]
elif src in LANGCODES:
src = LANGCODES[src]
else:
raise ValueError('invalid source language')
if dest not in LANGUAGES:
if dest in SPECIAL_CASES:
dest = SPECIAL_CASES[dest]
elif dest in LANGCODES:
dest = LANGCODES[dest]
else:
raise ValueError('invalid destination language')
if isinstance(text, list):
result = []
for item in text:
translated = self.translate(item, dest=dest, src=src)
result.append(translated)
return result
origin = text
data = self._translate(text, dest, src)
# this code will be updated when the format is changed.
jumps over -> 이상 점프
the lazy dog -> 게으른 개
"""
dest = dest.lower().split('_', 1)[0]
src = src.lower().split('_', 1)[0]
if src != 'auto' and src not in LANGUAGES:
if src in SPECIAL_CASES:
src = SPECIAL_CASES[src]
elif src in LANGCODES:
src = LANGCODES[src]
else:
raise ValueError('invalid source language')
if dest not in LANGUAGES:
if dest in SPECIAL_CASES:
dest = SPECIAL_CASES[dest]
elif dest in LANGCODES:
dest = LANGCODES[dest]
else:
raise ValueError('invalid destination language')
if isinstance(text, list):
wm = bpy.context.window_manager
current_step = 0
wm.progress_begin(current_step, len(text))
result = []
for item in text:
translated = self.translate(item, dest=dest, src=src)
result.append(translated)
current_step += 1
Advanced usage:
>>> translations = translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'], dest='ko')
>>> for translation in translations:
... print(translation.origin, ' -> ', translation.text)
The quick brown fox -> 빠른 갈색 여우
jumps over -> 이상 점프
the lazy dog -> 게으른 개
"""
dest = dest.lower().split('_', 1)[0]
src = src.lower().split('_', 1)[0]
if src != 'auto' and src not in LANGUAGES:
if src in SPECIAL_CASES:
src = SPECIAL_CASES[src]
elif src in LANGCODES:
src = LANGCODES[src]
else:
raise ValueError('invalid source language')
if dest not in LANGUAGES:
if dest in SPECIAL_CASES:
dest = SPECIAL_CASES[dest]
elif dest in LANGCODES:
dest = LANGCODES[dest]
else:
raise ValueError('invalid destination language')
if isinstance(text, list):
result = []
for item in text:
srcs not in SPECIAL_CASES) and (
srcs not in LANGCODES):
if srcs in SPECIAL_CASES:
srcs = SPECIAL_CASES[srcs]
elif srcs in LANGCODES:
srcs = LANGCODES[srcs]
else:
jarvis.say("\nInvalid source language\nEnter again")
srcs = jarvis.input().lower()
# Get destination language
jarvis.say('\nEnter destination language ')
des = jarvis.input().lower().strip()
# Check destination language
while (
des not in LANGUAGES) and (
des not in SPECIAL_CASES) and (
des not in LANGCODES):
if des in SPECIAL_CASES:
des = SPECIAL_CASES[des]
elif des in LANGCODES:
des = LANGCODES[des]
else:
jarvis.say("\nInvalid destination language\nEnter again")
des = jarvis.input().lower()
jarvis.say('\nEnter text ')
tex = jarvis.input()
performTranslation(srcs, des, tex)