Skip to content

Commit

Permalink
update usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhal baccouri committed Mar 19, 2022
1 parent c114ee0 commit 2e421d6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,27 @@ Google Translate
# Alternatively, you can pass languages by their abbreviation:
translated = GoogleTranslator(source='en', target='de').translate(text=text)
- You can also reuse the Translator class and change/update its properties.
(Notice that this is important for performance too since instantiating new objects is expensive)

.. code-block:: python
my_translator = GoogleTranslator(source='auto', target='german')
# let's say first you need to translate to german:
g_res = my_translator.translate(text=text)
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {g_res}")
# let's say later you want to reuse the class but your target is french now
my_translator.target = 'fr' # this will override the target 'german' passed previously
f_res = my_translator.translate(text=text)
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {f_res}")
# you can also update the source language as well
my_translator.source = 'en' # this will override the target 'german' passed previously
f_res = my_translator.translate(text=text)
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {f_res}")
- Translate batch of texts

.. code-block:: python
Expand Down Expand Up @@ -728,3 +749,10 @@ Here are some screenshots:
:width: 100%
:height: 300
:alt: screenshot3

===========================
Website & Desktop app
===========================

Currently, there are propositions for a website and/or dekstop app based on deep-translator.
You can follow the issue here: https://github.com/nidhaloff/deep-translator/issues/144

0 comments on commit 2e421d6

Please sign in to comment.