harry
commited on
Commit
·
6a8c939
1
Parent(s):
5d6c522
update baidu translator api
Browse files- docs/README.rst +30 -0
docs/README.rst
CHANGED
@@ -691,6 +691,36 @@ BaiduTranslator
|
|
691 |
|
692 |
- Translate from a file:
|
693 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
.. code-block:: python
|
695 |
|
696 |
translated = BaiduTranslator(appid="your-appid", appkey="your-appkey" source="en", target="zh").translate_file('path/to/file')
|
|
|
691 |
|
692 |
- Translate from a file:
|
693 |
|
694 |
+
.. code-block:: python
|
695 |
+
|
696 |
+
translated = BaiduTranslator(appid="your-appid", appkey="your-appkey" source="en", target="zh").translate_file('path/to/file')
|
697 |
+
|
698 |
+
BaiduTranslator
|
699 |
+
-----------------
|
700 |
+
|
701 |
+
.. note::
|
702 |
+
|
703 |
+
In order to use the BaiduTranslator translator, you need to generate a secret_id and a secret_key.
|
704 |
+
deep-translator supports both Pro and free APIs. Just check the examples below.
|
705 |
+
Visit http://api.fanyi.baidu.com/product/113 for more information on how to generate your Baidu appid
|
706 |
+
and appkey.
|
707 |
+
|
708 |
+
- Simple translation
|
709 |
+
|
710 |
+
.. code-block:: python
|
711 |
+
|
712 |
+
text = 'Hello world'
|
713 |
+
translated = BaiduTranslator(appid="your-appid", appkey="your-appkey" source="en", target="zh").translate(text)
|
714 |
+
|
715 |
+
- Translate batch of texts
|
716 |
+
|
717 |
+
.. code-block:: python
|
718 |
+
=
|
719 |
+
texts = ["Hello world", "How are you?"]
|
720 |
+
translated = BaiduTranslator(appid="your-appid", appkey="your-appkey" source="en", target="zh").translate_batch(texts)
|
721 |
+
|
722 |
+
- Translate from a file:
|
723 |
+
|
724 |
.. code-block:: python
|
725 |
|
726 |
translated = BaiduTranslator(appid="your-appid", appkey="your-appkey" source="en", target="zh").translate_file('path/to/file')
|