=
commited on
Commit
·
1a024b8
1
Parent(s):
f39d256
[TEST]
Browse files- CONTRIBUTING.rst +1 -32
- ja/CONTRIBUTING.rst +125 -0
- ja/README.rst +359 -0
CONTRIBUTING.rst
CHANGED
|
@@ -1,71 +1,40 @@
|
|
| 1 |
.. highlight:: shell
|
| 2 |
|
| 3 |
============
|
| 4 |
-
|
| 5 |
============
|
| 6 |
|
| 7 |
-
このプロジェクトではコントリビュートを歓迎しています!どんなに小さい貢献でも、あなたのコントリビュートになります。
|
| 8 |
-
|
| 9 |
Contributions are welcome, and they are greatly appreciated! Every little bit
|
| 10 |
helps, and credit will always be given.
|
| 11 |
|
| 12 |
-
次のようないくつかの方法で貢献することができます。
|
| 13 |
-
|
| 14 |
You can contribute in many ways:
|
| 15 |
|
| 16 |
-
コントリビュートの種類
|
| 17 |
-
|
| 18 |
Types of Contributions
|
| 19 |
----------------------
|
| 20 |
|
| 21 |
-
バグの報告
|
| 22 |
-
|
| 23 |
Report Bugs
|
| 24 |
~~~~~~~~~~~
|
| 25 |
|
| 26 |
-
https://github.com/nidhaloff/deep_translator/issues
|
| 27 |
-
|
| 28 |
-
でバクを報告してください。
|
| 29 |
-
|
| 30 |
Report bugs at https://github.com/nidhaloff/deep_translator/issues.
|
| 31 |
|
| 32 |
-
バグを報告する時、以下の3項目を含めて投稿するようにしてください。
|
| 33 |
-
|
| 34 |
-
* バグの発生したOSの種類とOSバージョンの情報
|
| 35 |
-
* ソフトウェアの設定などのローカル環境の情報
|
| 36 |
-
* バグを再現するための詳細な手順
|
| 37 |
-
|
| 38 |
If you are reporting a bug, please include:
|
| 39 |
|
| 40 |
* Your operating system name and version.
|
| 41 |
* Any details about your local setup that might be helpful in troubleshooting.
|
| 42 |
* Detailed steps to reproduce the bug.
|
| 43 |
|
| 44 |
-
バグの修正
|
| 45 |
-
|
| 46 |
Fix Bugs
|
| 47 |
~~~~~~~~
|
| 48 |
|
| 49 |
-
このリポジトリのイシューを見ることで、バグの情報を確認できます。
|
| 50 |
-
"bug" と "help wanted"でタグ付けされているものは、誰でもバグの修正にコントリビュートできます。
|
| 51 |
-
|
| 52 |
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
|
| 53 |
wanted" is open to whoever wants to implement it.
|
| 54 |
|
| 55 |
-
機能の追加
|
| 56 |
-
|
| 57 |
Implement Features
|
| 58 |
~~~~~~~~~~~~~~~~~~
|
| 59 |
|
| 60 |
-
|
| 61 |
-
このリポジトリのイシューを見ることで、追加したい機能が確認できます。
|
| 62 |
-
"enhancement" と "help wanted"でタグ付けされているものは、誰でも実装にコントリビュートできます。
|
| 63 |
-
|
| 64 |
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
| 65 |
and "help wanted" is open to whoever wants to implement it.
|
| 66 |
|
| 67 |
-
ドキュメントの作成
|
| 68 |
-
|
| 69 |
Write Documentation
|
| 70 |
~~~~~~~~~~~~~~~~~~~
|
| 71 |
|
|
|
|
| 1 |
.. highlight:: shell
|
| 2 |
|
| 3 |
============
|
| 4 |
+
Contributing
|
| 5 |
============
|
| 6 |
|
|
|
|
|
|
|
| 7 |
Contributions are welcome, and they are greatly appreciated! Every little bit
|
| 8 |
helps, and credit will always be given.
|
| 9 |
|
|
|
|
|
|
|
| 10 |
You can contribute in many ways:
|
| 11 |
|
|
|
|
|
|
|
| 12 |
Types of Contributions
|
| 13 |
----------------------
|
| 14 |
|
|
|
|
|
|
|
| 15 |
Report Bugs
|
| 16 |
~~~~~~~~~~~
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
Report bugs at https://github.com/nidhaloff/deep_translator/issues.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
If you are reporting a bug, please include:
|
| 21 |
|
| 22 |
* Your operating system name and version.
|
| 23 |
* Any details about your local setup that might be helpful in troubleshooting.
|
| 24 |
* Detailed steps to reproduce the bug.
|
| 25 |
|
|
|
|
|
|
|
| 26 |
Fix Bugs
|
| 27 |
~~~~~~~~
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
|
| 30 |
wanted" is open to whoever wants to implement it.
|
| 31 |
|
|
|
|
|
|
|
| 32 |
Implement Features
|
| 33 |
~~~~~~~~~~~~~~~~~~
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
| 36 |
and "help wanted" is open to whoever wants to implement it.
|
| 37 |
|
|
|
|
|
|
|
| 38 |
Write Documentation
|
| 39 |
~~~~~~~~~~~~~~~~~~~
|
| 40 |
|
ja/CONTRIBUTING.rst
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. highlight:: shell
|
| 2 |
+
|
| 3 |
+
============
|
| 4 |
+
コントリビュートする方法
|
| 5 |
+
============
|
| 6 |
+
|
| 7 |
+
このプロジェクトではあなたのコントリビュートを歓迎します!どんなに小さい貢献でも、コントリビューターとしてプロジェクトを支援することができます。
|
| 8 |
+
|
| 9 |
+
次の方法でコントリビュートすることができます。
|
| 10 |
+
|
| 11 |
+
コントリビュートの種類
|
| 12 |
+
----------------------
|
| 13 |
+
|
| 14 |
+
バグの報告
|
| 15 |
+
~~~~~~~~~~~
|
| 16 |
+
|
| 17 |
+
もしバグを発見したらhttps://github.com/nidhaloff/deep_translator/issues でバクを報告してください。
|
| 18 |
+
|
| 19 |
+
バグを報告する際にはトラブルシューティングしやすいように、以下の項目を含めて投稿するようにしてください。
|
| 20 |
+
|
| 21 |
+
* バグの発生したOSの種類とOSバージョンの情報
|
| 22 |
+
* ソフトウェアの設定などのローカル環境の情報
|
| 23 |
+
* バグを再現するための詳細な手順
|
| 24 |
+
|
| 25 |
+
バグの修正
|
| 26 |
+
~~~~~~~~
|
| 27 |
+
|
| 28 |
+
このリポジトリのイシューを見ることで、バグの情報を確認できます。
|
| 29 |
+
"bug" と "help wanted"でタグ付けされているものは、誰でもバグを修正にしてコントリビュートすることができます。
|
| 30 |
+
|
| 31 |
+
追加機能の実装
|
| 32 |
+
~~~~~~~~~~~~~~~~~~
|
| 33 |
+
|
| 34 |
+
このリポジトリのイシューを見ることで、実装待ちの機能が確認できます。
|
| 35 |
+
"enhancement" と "help wanted"でタグ付けされているものは、誰でも実装してコントリビュートすることができます。
|
| 36 |
+
|
| 37 |
+
ドキュメントの作成
|
| 38 |
+
~~~~~~~~~~~~~~~~~~~
|
| 39 |
+
|
| 40 |
+
deep_translator は、deep_translator の公式ドキュメントの一部、docstrings、あるいはウェブ上のブログ記事や記事など、常により多くのドキュメントを求めています。
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
意見・提案
|
| 44 |
+
~~~~~~~~~~~~~~~
|
| 45 |
+
|
| 46 |
+
意見・提案をする最も適切な方法は https://github.com/nidhaloff/deep_translator/issues に投稿することです。
|
| 47 |
+
|
| 48 |
+
もし、新しい機能を提案したければ以下の項目を留意してください。:
|
| 49 |
+
|
| 50 |
+
* 新しい機能の動作をできるだけ詳しく説明してください。
|
| 51 |
+
* 実装しやすいように機能の規模は限定するようにしてください。
|
| 52 |
+
* このプロジェクトがボランティアから成り立っていることと、コントリビュートを歓迎する精神を忘れないでください。
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
開発環境の構築
|
| 56 |
+
------------
|
| 57 |
+
|
| 58 |
+
コントリビュートの準備はできましたか?ここからは`deep_translator`の開発環境を構築する方法について説明します。
|
| 59 |
+
|
| 60 |
+
1. GitHub で`deep_translator` をフォークする.
|
| 61 |
+
2. フォークしたものをローカルリポジトリとしてクローンする。::
|
| 62 |
+
|
| 63 |
+
$ git clone git@github.com:your_name_here/deep_translator.git
|
| 64 |
+
|
| 65 |
+
3. virtualenvの作成とインストールを行う。virtualenvwrapperがインストール済みとすると、以下のコマンドでローカルに開発環境を構築できる。::
|
| 66 |
+
|
| 67 |
+
$ mkvirtualenv deep_translator
|
| 68 |
+
$ cd deep_translator /
|
| 69 |
+
$ python setup.py develop
|
| 70 |
+
|
| 71 |
+
4. ローカルで開発を行うために新しいブランチを作成する。::
|
| 72 |
+
|
| 73 |
+
$ git checkout -b name-of-your-bugfix-or-feature
|
| 74 |
+
|
| 75 |
+
これでローカルリポジトリに変更を加えることができるようになります。
|
| 76 |
+
|
| 77 |
+
5. 変更が終わったらflake8のコードチェックとテストを通過するようにする。この時、toxで複数バージョンのPythonで動作することを確認する。::
|
| 78 |
+
|
| 79 |
+
$ flake8 deep_translator tests
|
| 80 |
+
$ python setup.py test or pytest
|
| 81 |
+
$ tox
|
| 82 |
+
|
| 83 |
+
flake8とtoxのインストールは、virtualenvでpip installを行うことで可能です。
|
| 84 |
+
|
| 85 |
+
6. 変更をコミットし、自分のリモートリポジトリにプッシュする。::
|
| 86 |
+
|
| 87 |
+
$ git add .
|
| 88 |
+
$ git commit -m "Your detailed description of your changes."
|
| 89 |
+
$ git push origin name-of-your-bugfix-or-feature
|
| 90 |
+
|
| 91 |
+
7. GitHub からプルリクエストを送る.
|
| 92 |
+
|
| 93 |
+
プルリクエストにあたって
|
| 94 |
+
-----------------------
|
| 95 |
+
|
| 96 |
+
プルリクエストを送る前に以下のガイドラインに従っているか確認してください。:
|
| 97 |
+
|
| 98 |
+
1. プルリクエストにテストが含まれている。
|
| 99 |
+
|
| 100 |
+
2. プルリクエストで機能が追加された場合、ドキュメントを更新する必要があります。新しい機能について関数内にdocstringで記述し、それに加えてリストREADME.rstのリストに追加してください。
|
| 101 |
+
|
| 102 |
+
3. プルリクエストはPython 3.5,3.6,3.7,3.8またはPyPyで動作することが望まれます。
|
| 103 |
+
https://travisci.com/nidhaloff/deep_translator/pull_requests を確認し、サポートされている全てのPythonバージョンでテストを通過することを確認してください。
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
ヒント
|
| 107 |
+
----
|
| 108 |
+
|
| 109 |
+
テストのサブセットを実行するには以下のコマンドが利用できます。::
|
| 110 |
+
|
| 111 |
+
$ pytest tests.test_deep_translator
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
デプロイの方法
|
| 115 |
+
---------
|
| 116 |
+
|
| 117 |
+
メンテナンス担当者のためにデ���ロイの方法を記しておきます。
|
| 118 |
+
まず、全ての変更がコミットされていることを確認してください。(HISTORY.rstのエントリを含む).
|
| 119 |
+
次に、以下のコマンドを実行します::
|
| 120 |
+
|
| 121 |
+
$ bump2version patch # possible: major / minor / patch
|
| 122 |
+
$ git push
|
| 123 |
+
$ git push --tags
|
| 124 |
+
|
| 125 |
+
Travisはテストを通過することを確認したら、PyPIにデプロイします。
|
ja/README.rst
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
****************
|
| 2 |
+
deep_translator
|
| 3 |
+
****************
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
.. image:: https://img.shields.io/pypi/v/deep_translator.svg
|
| 7 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 8 |
+
.. image:: https://img.shields.io/travis/nidhaloff/deep_translator.svg
|
| 9 |
+
:target: https://travis-ci.com/nidhaloff/deep_translator
|
| 10 |
+
.. image:: https://readthedocs.org/projects/deep-translator/badge/?version=latest
|
| 11 |
+
:target: https://deep-translator.readthedocs.io/en/latest/?badge=latest
|
| 12 |
+
:alt: Documentation Status
|
| 13 |
+
.. image:: https://img.shields.io/pypi/l/deep-translator
|
| 14 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 15 |
+
|
| 16 |
+
.. image:: https://img.shields.io/pypi/dm/deep-translator
|
| 17 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 18 |
+
.. image:: https://img.shields.io/pypi/status/deep-translator
|
| 19 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 20 |
+
.. image:: https://img.shields.io/pypi/wheel/deep-translator
|
| 21 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 22 |
+
|
| 23 |
+
.. image:: https://img.shields.io/github/last-commit/nidhaloff/gpx_converter
|
| 24 |
+
:alt: GitHub last commit
|
| 25 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
| 26 |
+
|
| 27 |
+
.. image:: https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FNidhalBaccouri
|
| 28 |
+
:alt: Twitter URL
|
| 29 |
+
:target: https://twitter.com/NidhalBaccouri
|
| 30 |
+
|
| 31 |
+
.. image:: https://img.shields.io/badge/$-buy%20me%20a%20coffee-ff69b4.svg?style=social
|
| 32 |
+
:target: https://www.buymeacoffee.com/nidhaloff?new=1
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
=======================
|
| 36 |
+
Translation for humans
|
| 37 |
+
=======================
|
| 38 |
+
|
| 39 |
+
A flexible **FREE** and **UNLIMITED** tool to translate between different languages in a simple way using multiple translators.
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
* Free software: MIT license
|
| 43 |
+
* Documentation: https://deep-translator.readthedocs.io.
|
| 44 |
+
|
| 45 |
+
==========
|
| 46 |
+
Motivation
|
| 47 |
+
==========
|
| 48 |
+
|
| 49 |
+
I needed to translate a text using python. It was hard to find a simple way to do it.
|
| 50 |
+
There are other libraries that can be used for this task, but most of them
|
| 51 |
+
are **buggy, not free, limited, not supported anymore or complex to use.**
|
| 52 |
+
|
| 53 |
+
Therefore, I decided to build this simple tool. It is 100% free, unlimited, easy to use and provide
|
| 54 |
+
support for all languages.
|
| 55 |
+
|
| 56 |
+
Basically, my goal was to integrate support for multiple famous translators
|
| 57 |
+
in this tool.
|
| 58 |
+
|
| 59 |
+
======================
|
| 60 |
+
When you should use it
|
| 61 |
+
======================
|
| 62 |
+
|
| 63 |
+
- If you want to translate text using python
|
| 64 |
+
- If you want to translate from a file
|
| 65 |
+
- If you want to get translations from many sources and not only one
|
| 66 |
+
- If you want to automate translations
|
| 67 |
+
- If you want to compare different translations
|
| 68 |
+
- If you want to detect language automatically
|
| 69 |
+
|
| 70 |
+
======================
|
| 71 |
+
Why you should use it
|
| 72 |
+
======================
|
| 73 |
+
|
| 74 |
+
- High level of abstraction
|
| 75 |
+
- Automatic language detection
|
| 76 |
+
- Easy to use and extend
|
| 77 |
+
- It's the only python tool that integrates many translators
|
| 78 |
+
- Stable
|
| 79 |
+
- Support for most famous universal translators
|
| 80 |
+
|
| 81 |
+
========
|
| 82 |
+
Features
|
| 83 |
+
========
|
| 84 |
+
|
| 85 |
+
* Support for google translate
|
| 86 |
+
* Support for Pons translator (pons.com)
|
| 87 |
+
* Support for the Linguee translator
|
| 88 |
+
* Support for the Mymemory translator
|
| 89 |
+
* Automatic language detection
|
| 90 |
+
* Translate directly from a text file
|
| 91 |
+
* Get multiple translation for a word
|
| 92 |
+
* Automate the translation of different paragraphs in different languages
|
| 93 |
+
* Translate directly from terminal (version >= 1.1.0)
|
| 94 |
+
|
| 95 |
+
=============
|
| 96 |
+
Installation
|
| 97 |
+
=============
|
| 98 |
+
|
| 99 |
+
Install the stable release:
|
| 100 |
+
|
| 101 |
+
.. code-block:: console
|
| 102 |
+
|
| 103 |
+
$ pip install -U deep_translator
|
| 104 |
+
|
| 105 |
+
take a look at the docs if you want to install from source.
|
| 106 |
+
|
| 107 |
+
=====
|
| 108 |
+
Usage
|
| 109 |
+
=====
|
| 110 |
+
|
| 111 |
+
In this section, demos on how to use all different integrated translators in this tool are provided.
|
| 112 |
+
This includes the google, pons, linguee and mymemory translator (at least for now). Perhaps more
|
| 113 |
+
translators will be integrated in the future.
|
| 114 |
+
|
| 115 |
+
Imports
|
| 116 |
+
========
|
| 117 |
+
|
| 118 |
+
.. code-block:: python
|
| 119 |
+
|
| 120 |
+
from deep_translator import (GoogleTranslator,
|
| 121 |
+
PonsTranslator,
|
| 122 |
+
LingueeTranslator,
|
| 123 |
+
MyMemoryTranslator,
|
| 124 |
+
detect_language)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
Check Supported Languages
|
| 128 |
+
==========================
|
| 129 |
+
|
| 130 |
+
.. note::
|
| 131 |
+
|
| 132 |
+
You can check the supported languages of each translator by calling the
|
| 133 |
+
get_supported_languages function as a static method.
|
| 134 |
+
|
| 135 |
+
.. code-block:: python
|
| 136 |
+
|
| 137 |
+
# default return type is a list
|
| 138 |
+
langs_list = GoogleTranslator.get_supported_languages() # output: [arabic, french, english etc...]
|
| 139 |
+
|
| 140 |
+
# alternatively, you can the dictionary containing languages mapped to their abbreviation
|
| 141 |
+
langs_dict = GoogleTranslator.get_supported_languages(as_dict=True) # output: {arabic: ar, french: fr, english:en etc...}
|
| 142 |
+
|
| 143 |
+
Language Detection
|
| 144 |
+
===================
|
| 145 |
+
|
| 146 |
+
.. note::
|
| 147 |
+
|
| 148 |
+
You can also detect language automatically. Notice that this package is free and my goal is to keep it free.
|
| 149 |
+
Therefore, you will need to get your own api_key if you want to use the language detection function.
|
| 150 |
+
I figured out you can get one for free here: https://detectlanguage.com/documentation
|
| 151 |
+
|
| 152 |
+
.. code-block:: python
|
| 153 |
+
|
| 154 |
+
lang = detect_language('bonjour la vie', api_key='your_api_key')
|
| 155 |
+
print(lang) # output: fr
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
Google Translate
|
| 159 |
+
=================
|
| 160 |
+
|
| 161 |
+
.. code-block:: python
|
| 162 |
+
|
| 163 |
+
text = 'happy coding'
|
| 164 |
+
|
| 165 |
+
- You can use automatic language detection to detect the source language:
|
| 166 |
+
|
| 167 |
+
.. code-block:: python
|
| 168 |
+
|
| 169 |
+
translated = GoogleTranslator(source='auto', target='german').translate(text=text)
|
| 170 |
+
|
| 171 |
+
- You can pass languages by name:
|
| 172 |
+
|
| 173 |
+
.. code-block:: python
|
| 174 |
+
|
| 175 |
+
translated = GoogleTranslator(source='english', target='german').translate(text=text)
|
| 176 |
+
|
| 177 |
+
- Alternatively, you can pass languages by their abbreviation:
|
| 178 |
+
|
| 179 |
+
.. code-block:: python
|
| 180 |
+
|
| 181 |
+
translated = GoogleTranslator(source='en', target='de').translate(text=text)
|
| 182 |
+
|
| 183 |
+
- Translate from a file:
|
| 184 |
+
|
| 185 |
+
.. code-block:: python
|
| 186 |
+
|
| 187 |
+
translated = GoogleTranslator(source='auto', target='german').translate_file('path/to/file')
|
| 188 |
+
|
| 189 |
+
- Automate translation by detecting the source language and translate it automatically to the desired language
|
| 190 |
+
|
| 191 |
+
.. code-block:: python
|
| 192 |
+
|
| 193 |
+
# or maybe you have many sentences in different languages and want to automate the translation process
|
| 194 |
+
translated = GoogleTranslator(source='auto', target='de').translate_sentences([your_list_of_sentences])
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
PONS Translator
|
| 199 |
+
===============
|
| 200 |
+
|
| 201 |
+
.. note::
|
| 202 |
+
|
| 203 |
+
You can pass the languages by the name or by abbreviation just like
|
| 204 |
+
previous examples using GoogleTranslate
|
| 205 |
+
|
| 206 |
+
.. code-block:: python
|
| 207 |
+
|
| 208 |
+
word = 'awesome'
|
| 209 |
+
|
| 210 |
+
- Simple Translation
|
| 211 |
+
|
| 212 |
+
.. code-block:: python
|
| 213 |
+
|
| 214 |
+
translated_word = PonsTranslator(source='english', target='french').translate(word)
|
| 215 |
+
|
| 216 |
+
# pass language by their abbreviation
|
| 217 |
+
translated_word = PonsTranslator(source='en', target='fr').translate(word)
|
| 218 |
+
|
| 219 |
+
- Return all synonyms or words that matches
|
| 220 |
+
|
| 221 |
+
.. code-block:: python
|
| 222 |
+
|
| 223 |
+
# set the argument return_all to True if you want to get all synonyms of the word to translate
|
| 224 |
+
translated_word = PonsTranslator(source='english', target='french').translate(word, return_all=True)
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
Linguee Translator
|
| 229 |
+
===================
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
.. code-block:: python
|
| 233 |
+
|
| 234 |
+
word = 'good'
|
| 235 |
+
|
| 236 |
+
- Simple Translation
|
| 237 |
+
|
| 238 |
+
.. code-block:: python
|
| 239 |
+
|
| 240 |
+
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
| 241 |
+
|
| 242 |
+
# pass language by their abbreviation
|
| 243 |
+
translated_word = LingueeTranslator(source='en', target='fr').translate(word)
|
| 244 |
+
|
| 245 |
+
- Return all synonyms or words that matches
|
| 246 |
+
|
| 247 |
+
.. code-block:: python
|
| 248 |
+
|
| 249 |
+
# set the argument return_all to True if you want to get all synonyms of the word to translate
|
| 250 |
+
translated_word = LingueeTranslator(source='english', target='french').translate(word, return_all=True)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
Mymemory Translator
|
| 254 |
+
====================
|
| 255 |
+
|
| 256 |
+
.. note::
|
| 257 |
+
|
| 258 |
+
You can use the automatic language detection with mymemory by passing
|
| 259 |
+
"auto" as a value for the source language
|
| 260 |
+
|
| 261 |
+
.. code-block:: python
|
| 262 |
+
|
| 263 |
+
text = 'Keep it up. You are awesome'
|
| 264 |
+
|
| 265 |
+
translated = MyMemoryTranslator(source='auto', target='french').translate(text)
|
| 266 |
+
|
| 267 |
+
Usage from Terminal
|
| 268 |
+
====================
|
| 269 |
+
|
| 270 |
+
For a quick access, you can use the deep_translator from terminal. For this to work, you need to provide
|
| 271 |
+
the right arguments, which are the translator you want to use, source language, target language and the text
|
| 272 |
+
you want to translate.
|
| 273 |
+
|
| 274 |
+
For example, provide "google" as an argument to use the google translator. Alternatively you can use
|
| 275 |
+
the other supported translators. Just read the documentation to have an overview about the supported
|
| 276 |
+
translators in this library.
|
| 277 |
+
|
| 278 |
+
.. code-block:: console
|
| 279 |
+
|
| 280 |
+
$ deep_translator --translator "google" --source "english" --target "german" --text "happy coding"
|
| 281 |
+
|
| 282 |
+
Or you can go for the short version:
|
| 283 |
+
|
| 284 |
+
.. code-block:: console
|
| 285 |
+
|
| 286 |
+
$ deep_translator -trans "google" -src "english" -tg "german" -txt "happy coding"
|
| 287 |
+
|
| 288 |
+
If you want, you can also pass the source and target language by their abbreviation
|
| 289 |
+
|
| 290 |
+
.. code-block:: console
|
| 291 |
+
|
| 292 |
+
$ deep_translator -trans "google" -src "en" -tg "de" -txt "happy coding"
|
| 293 |
+
|
| 294 |
+
Side Hint
|
| 295 |
+
==========
|
| 296 |
+
|
| 297 |
+
Generally, I find the google and mymemory translators suitable for translating sentences, whereas
|
| 298 |
+
the pons and linguee translators are good choices if you want to translate words.
|
| 299 |
+
|
| 300 |
+
========
|
| 301 |
+
Links
|
| 302 |
+
========
|
| 303 |
+
Check this article on medium to know why you should use the deep-translator package and how to translate text using python.
|
| 304 |
+
https://medium.com/@nidhalbacc/how-to-translate-text-with-python-9d203139dcf5
|
| 305 |
+
|
| 306 |
+
===========================
|
| 307 |
+
The Translator++ mobile app
|
| 308 |
+
===========================
|
| 309 |
+
|
| 310 |
+
.. image:: assets/app-icon.png
|
| 311 |
+
:width: 100
|
| 312 |
+
:alt: Icon of the app
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
After developing the deep_translator, I realised how cool this would be if I can use it as an app on my mobile phone.
|
| 316 |
+
Sure, there is google translate, pons and linguee apps etc.. but isn't it cooler to make an app where all these
|
| 317 |
+
translators are integrated?
|
| 318 |
+
|
| 319 |
+
Long story short, I started working on the app. I decided to use the `kivy framework <https://kivy.org/#home/>`_ since
|
| 320 |
+
I wanted to code in python and to develop a cross platform app.
|
| 321 |
+
I open sourced the `Translator++ app <https://github.com/nidhaloff/deep-translator-app/>`_ on my github too.
|
| 322 |
+
Feel free to take a look at the code or make a pull request ;)
|
| 323 |
+
|
| 324 |
+
.. note::
|
| 325 |
+
The Translator++ app is based on the deep_translator package. I just built the app to prove the capabilities
|
| 326 |
+
of the deep_translator package ;)
|
| 327 |
+
|
| 328 |
+
I published the first release on google play store on 02-08-2020
|
| 329 |
+
|
| 330 |
+
Here are some screenshots:
|
| 331 |
+
|
| 332 |
+
- Phone
|
| 333 |
+
|
| 334 |
+
.. image:: assets/translator1.jpg
|
| 335 |
+
:width: 30%
|
| 336 |
+
:height: 200
|
| 337 |
+
:alt: screenshot1
|
| 338 |
+
.. image:: assets/translator2.jpg
|
| 339 |
+
:width: 30%
|
| 340 |
+
:height: 200
|
| 341 |
+
:alt: screenshot2
|
| 342 |
+
.. image:: assets/spinner.jpg
|
| 343 |
+
:width: 30%
|
| 344 |
+
:height: 200
|
| 345 |
+
:alt: spinner
|
| 346 |
+
|
| 347 |
+
- Tablet:
|
| 348 |
+
|
| 349 |
+
.. image:: assets/hz_view.png
|
| 350 |
+
:width: 100%
|
| 351 |
+
:height: 300
|
| 352 |
+
:alt: screenshot3
|
| 353 |
+
|
| 354 |
+
==========
|
| 355 |
+
Next Steps
|
| 356 |
+
==========
|
| 357 |
+
|
| 358 |
+
Take a look in the examples folder for more :)
|
| 359 |
+
Contributions are always welcome. Feel free to make a pull request and give me a feedback if you found the package useful or you are using it :)
|