nidhal baccouri
commited on
Commit
·
2e421d6
1
Parent(s):
c114ee0
update usage in readme
Browse files- docs/README.rst +28 -0
docs/README.rst
CHANGED
|
@@ -256,6 +256,27 @@ Google Translate
|
|
| 256 |
# Alternatively, you can pass languages by their abbreviation:
|
| 257 |
translated = GoogleTranslator(source='en', target='de').translate(text=text)
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
- Translate batch of texts
|
| 260 |
|
| 261 |
.. code-block:: python
|
|
@@ -728,3 +749,10 @@ Here are some screenshots:
|
|
| 728 |
:width: 100%
|
| 729 |
:height: 300
|
| 730 |
:alt: screenshot3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
# Alternatively, you can pass languages by their abbreviation:
|
| 257 |
translated = GoogleTranslator(source='en', target='de').translate(text=text)
|
| 258 |
|
| 259 |
+
- You can also reuse the Translator class and change/update its properties.
|
| 260 |
+
(Notice that this is important for performance too since instantiating new objects is expensive)
|
| 261 |
+
|
| 262 |
+
.. code-block:: python
|
| 263 |
+
|
| 264 |
+
my_translator = GoogleTranslator(source='auto', target='german')
|
| 265 |
+
# let's say first you need to translate to german:
|
| 266 |
+
g_res = my_translator.translate(text=text)
|
| 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 |
+
f_res = my_translator.translate(text=text)
|
| 272 |
+
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {f_res}")
|
| 273 |
+
|
| 274 |
+
# you can also update the source language as well
|
| 275 |
+
my_translator.source = 'en' # this will override the target 'german' passed previously
|
| 276 |
+
f_res = my_translator.translate(text=text)
|
| 277 |
+
print(f"Translation using source = {my_translator.source} and target = {my_translator.target} -> {f_res}")
|
| 278 |
+
|
| 279 |
+
|
| 280 |
- Translate batch of texts
|
| 281 |
|
| 282 |
.. code-block:: python
|
|
|
|
| 749 |
:width: 100%
|
| 750 |
:height: 300
|
| 751 |
:alt: screenshot3
|
| 752 |
+
|
| 753 |
+
===========================
|
| 754 |
+
Website & Desktop app
|
| 755 |
+
===========================
|
| 756 |
+
|
| 757 |
+
Currently, there are propositions for a website and/or dekstop app based on deep-translator.
|
| 758 |
+
You can follow the issue here: https://github.com/nidhaloff/deep-translator/issues/144
|