nidhal baccouri
commited on
Commit
·
7055243
1
Parent(s):
2e421d6
update readme
Browse files- docs/README.rst +10 -8
docs/README.rst
CHANGED
@@ -261,20 +261,22 @@ Google Translate
|
|
261 |
|
262 |
.. code-block:: python
|
263 |
|
|
|
264 |
my_translator = GoogleTranslator(source='auto', target='german')
|
265 |
-
|
266 |
-
|
267 |
-
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {g_res}")
|
268 |
|
269 |
# let's say later you want to reuse the class but your target is french now
|
|
|
|
|
270 |
my_translator.target = 'fr' # this will override the target 'german' passed previously
|
271 |
-
|
272 |
-
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {
|
273 |
|
274 |
# you can also update the source language as well
|
275 |
-
my_translator.source = 'en' # this will override the
|
276 |
-
|
277 |
-
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {
|
278 |
|
279 |
|
280 |
- Translate batch of texts
|
|
|
261 |
|
262 |
.. code-block:: python
|
263 |
|
264 |
+
# let's say first you need to translate from auto to german
|
265 |
my_translator = GoogleTranslator(source='auto', target='german')
|
266 |
+
result = my_translator.translate(text=text)
|
267 |
+
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {result}")
|
|
|
268 |
|
269 |
# let's say later you want to reuse the class but your target is french now
|
270 |
+
# This is the best practice and how you should use deep-translator.
|
271 |
+
# Please don't over-instantiate translator objects without a good reason, otherwise you will run into performance issues
|
272 |
my_translator.target = 'fr' # this will override the target 'german' passed previously
|
273 |
+
result = my_translator.translate(text=text)
|
274 |
+
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {result}")
|
275 |
|
276 |
# you can also update the source language as well
|
277 |
+
my_translator.source = 'en' # this will override the source 'auto' passed previously
|
278 |
+
result = my_translator.translate(text=text)
|
279 |
+
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {result}")
|
280 |
|
281 |
|
282 |
- Translate batch of texts
|