prashant commited on
Commit
4119be8
·
1 Parent(s): 0623ca9

added translation from file in README

Browse files
Files changed (1) hide show
  1. docs/README.rst +15 -3
docs/README.rst CHANGED
@@ -322,11 +322,13 @@ Google Translate
322
  # the translate_sentences function is deprecated, use the translate_batch function instead
323
  translated = GoogleTranslator('de', 'en').translate_batch(texts)
324
 
325
- - Translate from a file:
326
 
327
  .. code-block:: python
328
 
329
- translated = GoogleTranslator(source='auto', target='german').translate_file('path/to/file')
 
 
330
 
331
  Mymemory Translator
332
  --------------------
@@ -354,7 +356,7 @@ Mymemory Translator
354
  # the translate_sentences function is deprecated, use the translate_batch function instead
355
  translated = MyMemoryTranslator('de', 'en').translate_batch(texts)
356
 
357
- - Translate from file
358
 
359
  .. code-block:: python
360
 
@@ -792,6 +794,16 @@ For PDF translation:
792
 
793
  pip install deep-translator[pdf]
794
 
 
 
 
 
 
 
 
 
 
 
795
 
796
  Usage from Terminal
797
  --------------------
 
322
  # the translate_sentences function is deprecated, use the translate_batch function instead
323
  translated = GoogleTranslator('de', 'en').translate_batch(texts)
324
 
325
+ - Translate text from txt/docx/pdf:
326
 
327
  .. code-block:: python
328
 
329
+ path = "your_file.txt"
330
+
331
+ translated = GoogleTranslator(source='auto', target='german').translate_file(path)
332
 
333
  Mymemory Translator
334
  --------------------
 
356
  # the translate_sentences function is deprecated, use the translate_batch function instead
357
  translated = MyMemoryTranslator('de', 'en').translate_batch(texts)
358
 
359
+ - Translate text from txt/docx/pdf:
360
 
361
  .. code-block:: python
362
 
 
794
 
795
  pip install deep-translator[pdf]
796
 
797
+ - Translate text from txt/docx/pdf:
798
+
799
+ Here is sample code for translating text directly from files
800
+
801
+ .. code-block:: python
802
+
803
+ path = "example/test.pdf"
804
+
805
+ translated = GoogleTranslator(source='auto', target='german').translate_file(path)
806
+
807
 
808
  Usage from Terminal
809
  --------------------