=
commited on
Commit
·
fb27b03
1
Parent(s):
c52836e
[TRAN]En documentations traslate to Ja.
Browse files- ja/README.rst +97 -113
- ja/index.rst +20 -0
- ja/installation.rst +50 -0
- ja/usage.rst +75 -0
ja/README.rst
CHANGED
@@ -33,86 +33,80 @@ deep_translator
|
|
33 |
|
34 |
|
35 |
=======================
|
36 |
-
|
37 |
=======================
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
*
|
43 |
-
* Documentation: https://deep-translator.readthedocs.io.
|
44 |
|
45 |
==========
|
46 |
-
|
47 |
==========
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
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 |
-
|
61 |
======================
|
62 |
|
63 |
-
-
|
64 |
-
-
|
65 |
-
-
|
66 |
-
-
|
67 |
-
-
|
68 |
-
-
|
69 |
|
70 |
======================
|
71 |
-
|
72 |
======================
|
73 |
|
74 |
-
-
|
75 |
-
-
|
76 |
-
-
|
77 |
-
-
|
78 |
-
-
|
79 |
-
-
|
80 |
|
81 |
========
|
82 |
-
|
83 |
========
|
84 |
|
85 |
-
*
|
86 |
-
*
|
87 |
-
*
|
88 |
-
*
|
89 |
-
*
|
90 |
-
*
|
91 |
-
*
|
92 |
-
*
|
93 |
-
*
|
94 |
|
95 |
=============
|
96 |
-
|
97 |
=============
|
98 |
|
99 |
-
|
100 |
|
101 |
.. code-block:: console
|
102 |
|
103 |
$ pip install -U deep_translator
|
104 |
|
105 |
-
|
106 |
|
107 |
=====
|
108 |
-
|
109 |
=====
|
110 |
|
111 |
-
|
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 |
-
|
116 |
========
|
117 |
|
118 |
.. code-block:: python
|
@@ -124,30 +118,27 @@ Imports
|
|
124 |
detect_language)
|
125 |
|
126 |
|
127 |
-
|
128 |
==========================
|
129 |
|
130 |
-
..
|
131 |
|
132 |
-
|
133 |
-
get_supported_languages function as a static method.
|
134 |
|
135 |
.. code-block:: python
|
136 |
|
137 |
-
#
|
138 |
langs_list = GoogleTranslator.get_supported_languages() # output: [arabic, french, english etc...]
|
139 |
|
140 |
-
#
|
141 |
langs_dict = GoogleTranslator.get_supported_languages(as_dict=True) # output: {arabic: ar, french: fr, english:en etc...}
|
142 |
|
143 |
-
|
144 |
===================
|
145 |
|
146 |
-
..
|
147 |
|
148 |
-
|
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 |
|
@@ -155,77 +146,76 @@ Language Detection
|
|
155 |
print(lang) # output: fr
|
156 |
|
157 |
|
158 |
-
Google
|
159 |
=================
|
160 |
|
161 |
.. code-block:: python
|
162 |
|
163 |
text = 'happy coding'
|
164 |
|
165 |
-
-
|
166 |
|
167 |
.. code-block:: python
|
168 |
|
169 |
translated = GoogleTranslator(source='auto', target='german').translate(text=text)
|
170 |
|
171 |
-
-
|
172 |
|
173 |
.. code-block:: python
|
174 |
|
175 |
translated = GoogleTranslator(source='english', target='german').translate(text=text)
|
176 |
|
177 |
-
-
|
178 |
|
179 |
.. code-block:: python
|
180 |
|
181 |
translated = GoogleTranslator(source='en', target='de').translate(text=text)
|
182 |
|
183 |
-
-
|
184 |
|
185 |
.. code-block:: python
|
186 |
|
187 |
translated = GoogleTranslator(source='auto', target='german').translate_file('path/to/file')
|
188 |
|
189 |
-
-
|
190 |
|
191 |
.. code-block:: python
|
192 |
|
193 |
-
|
194 |
translated = GoogleTranslator(source='auto', target='de').translate_sentences([your_list_of_sentences])
|
195 |
|
196 |
|
197 |
|
198 |
-
PONS
|
199 |
===============
|
200 |
|
201 |
-
..
|
202 |
|
203 |
-
|
204 |
-
previous examples using GoogleTranslate
|
205 |
|
206 |
.. code-block:: python
|
207 |
|
208 |
word = 'awesome'
|
209 |
|
210 |
-
-
|
211 |
|
212 |
.. code-block:: python
|
213 |
|
214 |
translated_word = PonsTranslator(source='english', target='french').translate(word)
|
215 |
|
216 |
-
#
|
217 |
translated_word = PonsTranslator(source='en', target='fr').translate(word)
|
218 |
|
219 |
-
-
|
220 |
|
221 |
.. code-block:: python
|
222 |
|
223 |
-
|
224 |
translated_word = PonsTranslator(source='english', target='french').translate(word, return_all=True)
|
225 |
|
226 |
|
227 |
|
228 |
-
Linguee
|
229 |
===================
|
230 |
|
231 |
|
@@ -233,30 +223,28 @@ Linguee Translator
|
|
233 |
|
234 |
word = 'good'
|
235 |
|
236 |
-
-
|
237 |
|
238 |
.. code-block:: python
|
239 |
|
240 |
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
241 |
|
242 |
-
#
|
243 |
translated_word = LingueeTranslator(source='en', target='fr').translate(word)
|
244 |
|
245 |
-
-
|
246 |
-
|
247 |
.. code-block:: python
|
248 |
|
249 |
-
#
|
250 |
translated_word = LingueeTranslator(source='english', target='french').translate(word, return_all=True)
|
251 |
|
252 |
|
253 |
-
Mymemory
|
254 |
====================
|
255 |
|
256 |
-
..
|
257 |
|
258 |
-
|
259 |
-
"auto" as a value for the source language
|
260 |
|
261 |
.. code-block:: python
|
262 |
|
@@ -264,47 +252,46 @@ Mymemory Translator
|
|
264 |
|
265 |
translated = MyMemoryTranslator(source='auto', target='french').translate(text)
|
266 |
|
267 |
-
|
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 |
-
|
275 |
-
|
276 |
-
|
277 |
|
278 |
.. code-block:: console
|
279 |
|
280 |
$ deep_translator --translator "google" --source "english" --target "german" --text "happy coding"
|
281 |
|
282 |
-
|
283 |
|
284 |
.. code-block:: console
|
285 |
|
286 |
$ deep_translator -trans "google" -src "english" -tg "german" -txt "happy coding"
|
287 |
|
288 |
-
|
|
|
289 |
|
290 |
.. code-block:: console
|
291 |
|
292 |
$ deep_translator -trans "google" -src "en" -tg "de" -txt "happy coding"
|
293 |
|
294 |
-
|
|
|
295 |
==========
|
296 |
|
297 |
-
|
298 |
-
the pons and linguee translators are good choices if you want to translate words.
|
299 |
|
300 |
========
|
301 |
-
|
302 |
========
|
303 |
-
|
|
|
304 |
https://medium.com/@nidhalbacc/how-to-translate-text-with-python-9d203139dcf5
|
305 |
|
306 |
===========================
|
307 |
-
|
308 |
===========================
|
309 |
|
310 |
.. image:: assets/app-icon.png
|
@@ -312,24 +299,20 @@ The Translator++ mobile app
|
|
312 |
:alt: Icon of the app
|
313 |
|
314 |
|
315 |
-
|
316 |
-
|
317 |
-
translators are integrated?
|
318 |
|
319 |
-
|
320 |
-
|
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 |
-
..
|
325 |
-
|
326 |
-
of the deep_translator package ;)
|
327 |
|
328 |
-
|
329 |
|
330 |
-
|
331 |
|
332 |
-
-
|
333 |
|
334 |
.. image:: assets/translator1.jpg
|
335 |
:width: 30%
|
@@ -344,7 +327,7 @@ Here are some screenshots:
|
|
344 |
:height: 200
|
345 |
:alt: spinner
|
346 |
|
347 |
-
-
|
348 |
|
349 |
.. image:: assets/hz_view.png
|
350 |
:width: 100%
|
@@ -352,8 +335,9 @@ Here are some screenshots:
|
|
352 |
:alt: screenshot3
|
353 |
|
354 |
==========
|
355 |
-
|
356 |
==========
|
357 |
|
358 |
-
|
359 |
-
|
|
|
|
33 |
|
34 |
|
35 |
=======================
|
36 |
+
自然言語の翻訳ツール
|
37 |
=======================
|
38 |
|
39 |
+
複数の翻訳サービスを使って、簡単な方法で異なる言語間で柔軟に翻訳を **無料** かつ **無制限**に行えるツールです
|
40 |
|
41 |
+
* フリーソフトウェア: MIT ライセンス
|
42 |
+
* ドキュメント: https://deep-translator.readthedocs.io.
|
|
|
43 |
|
44 |
==========
|
45 |
+
開発の動機
|
46 |
==========
|
47 |
|
48 |
+
Pythonを使用してテキストを別の言語に翻訳するタスクがありました。しかし、それを行う簡単な方法を見つけるのは困難でした。なぜなら、このタスクに適用できるライブラリはいくつか存在しますが、それらのほとんどはバグが多いか、無料ではないか、何らかの制約があるか、全ての言語をサポートしていないか、使用するのが簡単ではありませんでした。
|
49 |
+
|
50 |
+
そこで、このタスクを簡単に行えるツールを作成することにしました。100%無料で無制限で使いやすく、すべての言語をサポートしています。
|
51 |
|
52 |
+
このツールの目的は、複数の有名な翻訳サービスをこのツールに統合することにあります。
|
|
|
53 |
|
|
|
|
|
54 |
|
55 |
======================
|
56 |
+
使用例
|
57 |
======================
|
58 |
|
59 |
+
- Pythonを使用してテキストを翻訳したい場合
|
60 |
+
- ファイルのテキストを翻訳したい場合
|
61 |
+
- 1つだけでなく、多くのソースから翻訳結果を取得したい場合
|
62 |
+
- 翻訳を自動化したい場合
|
63 |
+
- 異なる翻訳結果を比較したい場合
|
64 |
+
- 言語を自動検出したい場合
|
65 |
|
66 |
======================
|
67 |
+
このツールの強み
|
68 |
======================
|
69 |
|
70 |
+
- 高度な抽象化が施されている
|
71 |
+
- 言語を自動で検出する
|
72 |
+
- 拡張と使用が簡単である
|
73 |
+
- 多くの翻訳サービスを統合して扱える唯一のpythonツールである
|
74 |
+
- 安定している
|
75 |
+
- 有名な翻訳サービスをサポートしている
|
76 |
|
77 |
========
|
78 |
+
機能
|
79 |
========
|
80 |
|
81 |
+
* google翻訳のサポート
|
82 |
+
* Pons (pons.com)のサポート
|
83 |
+
* Linguee のサポート
|
84 |
+
* Mymemory のサポート
|
85 |
+
* 自動言語検出
|
86 |
+
* テキストファイルから直接翻訳する
|
87 |
+
* 単語の複数の翻訳結果を取得する
|
88 |
+
* 異なる言語の異なる段落の翻訳を自動化する
|
89 |
+
* コマンドラインから直接翻訳する(バージョン1.1.0以上)
|
90 |
|
91 |
=============
|
92 |
+
インストール方法
|
93 |
=============
|
94 |
|
95 |
+
ツールの安定版をインストールする方法です:
|
96 |
|
97 |
.. code-block:: console
|
98 |
|
99 |
$ pip install -U deep_translator
|
100 |
|
101 |
+
ソースからインストールを行いたい場合、ドキュメントを参照してください。
|
102 |
|
103 |
=====
|
104 |
+
使い方
|
105 |
=====
|
106 |
|
107 |
+
このセクションでは、このツールで様々な統合トランスレータを利用するデモを行います。このデモでは、google、pons、linguee、mymemoryの翻訳サービスを扱います(現時点)。将来的には、より多くの翻訳サービスを統合する予定です。
|
|
|
|
|
108 |
|
109 |
+
インポート
|
110 |
========
|
111 |
|
112 |
.. code-block:: python
|
|
|
118 |
detect_language)
|
119 |
|
120 |
|
121 |
+
サポートされている言語を確認する
|
122 |
==========================
|
123 |
|
124 |
+
.. ポイント::
|
125 |
|
126 |
+
関数get_supported_languagesを静的メソッドとして呼び出すことにより、各翻訳サービスでサポートしている言語を確認できます。
|
|
|
127 |
|
128 |
.. code-block:: python
|
129 |
|
130 |
+
# デフォルトではリストを返します
|
131 |
langs_list = GoogleTranslator.get_supported_languages() # output: [arabic, french, english etc...]
|
132 |
|
133 |
+
# 言語の省略形を辞書型にまとめて返すことも出来ます
|
134 |
langs_dict = GoogleTranslator.get_supported_languages(as_dict=True) # output: {arabic: ar, french: fr, english:en etc...}
|
135 |
|
136 |
+
言語検出
|
137 |
===================
|
138 |
|
139 |
+
.. ポイント::
|
140 |
|
141 |
+
言語を自動的に検出することもできます。当然、このパッケージは無料です。言語検出機能を無料で使用する場合は、個人でapi_keyを取得する必要があります。ここで無料で入手することができます:https://detectlanguage.com/documentation
|
|
|
|
|
142 |
|
143 |
.. code-block:: python
|
144 |
|
|
|
146 |
print(lang) # output: fr
|
147 |
|
148 |
|
149 |
+
Google 翻訳
|
150 |
=================
|
151 |
|
152 |
.. code-block:: python
|
153 |
|
154 |
text = 'happy coding'
|
155 |
|
156 |
+
- ソースの言語に自動検出を使用できます:
|
157 |
|
158 |
.. code-block:: python
|
159 |
|
160 |
translated = GoogleTranslator(source='auto', target='german').translate(text=text)
|
161 |
|
162 |
+
- ソースの言語の種類を指定することも出来ます:
|
163 |
|
164 |
.. code-block:: python
|
165 |
|
166 |
translated = GoogleTranslator(source='english', target='german').translate(text=text)
|
167 |
|
168 |
+
- 言語名は省略形で指定することも可能です:
|
169 |
|
170 |
.. code-block:: python
|
171 |
|
172 |
translated = GoogleTranslator(source='en', target='de').translate(text=text)
|
173 |
|
174 |
+
- ファイルから翻訳を行うことも出来ます:
|
175 |
|
176 |
.. code-block:: python
|
177 |
|
178 |
translated = GoogleTranslator(source='auto', target='german').translate_file('path/to/file')
|
179 |
|
180 |
+
- ソースの言語を検出し、望んだ言語に自動翻訳することが出来ます。
|
181 |
|
182 |
.. code-block:: python
|
183 |
|
184 |
+
# または、異なる言語の文章の翻訳を自動化したい時にも利用できます。
|
185 |
translated = GoogleTranslator(source='auto', target='de').translate_sentences([your_list_of_sentences])
|
186 |
|
187 |
|
188 |
|
189 |
+
PONS
|
190 |
===============
|
191 |
|
192 |
+
.. ポイント::
|
193 |
|
194 |
+
Google翻訳同様に言語の名前を指定して翻訳することが出来ます。省略形で指定することも可能です。
|
|
|
195 |
|
196 |
.. code-block:: python
|
197 |
|
198 |
word = 'awesome'
|
199 |
|
200 |
+
- 簡単な翻訳方法
|
201 |
|
202 |
.. code-block:: python
|
203 |
|
204 |
translated_word = PonsTranslator(source='english', target='french').translate(word)
|
205 |
|
206 |
+
# 言語の省略形を指定する
|
207 |
translated_word = PonsTranslator(source='en', target='fr').translate(word)
|
208 |
|
209 |
+
- 全ての同義語か一致する単語を返す
|
210 |
|
211 |
.. code-block:: python
|
212 |
|
213 |
+
# 翻訳結果の全ての同義語を取得したい場合、引数にreturn_allにTrueを指定してください
|
214 |
translated_word = PonsTranslator(source='english', target='french').translate(word, return_all=True)
|
215 |
|
216 |
|
217 |
|
218 |
+
Linguee
|
219 |
===================
|
220 |
|
221 |
|
|
|
223 |
|
224 |
word = 'good'
|
225 |
|
226 |
+
- 簡単な翻訳方法
|
227 |
|
228 |
.. code-block:: python
|
229 |
|
230 |
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
231 |
|
232 |
+
# 言語の省略形を指定する
|
233 |
translated_word = LingueeTranslator(source='en', target='fr').translate(word)
|
234 |
|
235 |
+
- 全ての同義語か一致する単語を返す
|
|
|
236 |
.. code-block:: python
|
237 |
|
238 |
+
# 翻訳結果の全ての同義語を取得したい場合、引数にreturn_allにTrueを指定してください
|
239 |
translated_word = LingueeTranslator(source='english', target='french').translate(word, return_all=True)
|
240 |
|
241 |
|
242 |
+
Mymemory
|
243 |
====================
|
244 |
|
245 |
+
.. ポイント::
|
246 |
|
247 |
+
sourceに"auto"を渡すことでmymemoryの自動言語検出を使用できます。
|
|
|
248 |
|
249 |
.. code-block:: python
|
250 |
|
|
|
252 |
|
253 |
translated = MyMemoryTranslator(source='auto', target='french').translate(text)
|
254 |
|
255 |
+
ターミナルでの使用方法
|
256 |
====================
|
257 |
|
|
|
|
|
|
|
258 |
|
259 |
+
ターミナルからdeep_translatorをすぐに使用できます。使用するには、使用する翻訳サービス、翻訳元の言語、翻訳先の言語、翻訳するテキストなどを引数に指定する必要があります。
|
260 |
+
たとえば、Google翻訳を使用するには、引数として「google」を指定します。引数を変更することで、サポートされている他の翻訳サービスに切り替えることも可能です。ドキュメントを読んで、このツールでサポートされている翻訳サービスを確認してください。
|
261 |
+
|
262 |
|
263 |
.. code-block:: console
|
264 |
|
265 |
$ deep_translator --translator "google" --source "english" --target "german" --text "happy coding"
|
266 |
|
267 |
+
以下のように短く記述することもできます:
|
268 |
|
269 |
.. code-block:: console
|
270 |
|
271 |
$ deep_translator -trans "google" -src "english" -tg "german" -txt "happy coding"
|
272 |
|
273 |
+
|
274 |
+
翻訳元と翻訳先の言語を省略形で引数に指定することも出来ます。
|
275 |
|
276 |
.. code-block:: console
|
277 |
|
278 |
$ deep_translator -trans "google" -src "en" -tg "de" -txt "happy coding"
|
279 |
|
280 |
+
|
281 |
+
ヒント
|
282 |
==========
|
283 |
|
284 |
+
一般的に、google翻訳とmymemoryは文章に翻訳に適していますが、ponsとlingueeは単語の翻訳に適しています。
|
|
|
285 |
|
286 |
========
|
287 |
+
リンク
|
288 |
========
|
289 |
+
|
290 |
+
deep_translatorの使用目的やpythonで翻訳をする方法を確認するために以下のmediumの記事を確認してください。
|
291 |
https://medium.com/@nidhalbacc/how-to-translate-text-with-python-9d203139dcf5
|
292 |
|
293 |
===========================
|
294 |
+
スマートフォンアプリ Translator++
|
295 |
===========================
|
296 |
|
297 |
.. image:: assets/app-icon.png
|
|
|
299 |
:alt: Icon of the app
|
300 |
|
301 |
|
302 |
+
deep_translatorを開発しみて、スマートフォンのアプリとして使用できれば便利なのではないかと思い立ちました。
|
303 |
+
google翻訳やpons、lingueeの個々のアプリは存在しますが、これらを統合して使用できるアプリを作れば便利ではないでしょうか。
|
|
|
304 |
|
305 |
+
それを出発点として、アプリの開発を開始しました。Pythonで作成しつつ、クロスプラットフォームのアプリを開発したかったので、kivyフレームワーク<https://kivy.org/#home/>を使用することにしました。
|
306 |
+
Translator ++もgithubでオープンソースとして公開しています。自由に編集やプルリクエストを行ってください;��
|
|
|
|
|
307 |
|
308 |
+
.. ポイント::
|
309 |
+
Translator++はdeep_translatorパッケージがベースになっています。このアプリはパッケージの機能を試すために開発されています;)
|
|
|
310 |
|
311 |
+
02-08-2020にGoogle Playで初公開されました。
|
312 |
|
313 |
+
スクリーンショット:
|
314 |
|
315 |
+
- スマートフォン
|
316 |
|
317 |
.. image:: assets/translator1.jpg
|
318 |
:width: 30%
|
|
|
327 |
:height: 200
|
328 |
:alt: spinner
|
329 |
|
330 |
+
- タブレット:
|
331 |
|
332 |
.. image:: assets/hz_view.png
|
333 |
:width: 100%
|
|
|
335 |
:alt: screenshot3
|
336 |
|
337 |
==========
|
338 |
+
次のステップ
|
339 |
==========
|
340 |
|
341 |
+
|
342 |
+
詳細は examples フォルダを確認してください :)
|
343 |
+
コントリビュートはいつでも歓迎しています。このパッケージが便利だと感じた方や使っている方がいたら、遠慮なくプルリクエストをしてフィードバックをください :)
|
ja/index.rst
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
deep_translatorのドキュメントへようこそ!
|
2 |
+
======================================
|
3 |
+
|
4 |
+
.. toctree::
|
5 |
+
:maxdepth: 2
|
6 |
+
:caption: Contents:
|
7 |
+
|
8 |
+
readme
|
9 |
+
installation
|
10 |
+
usage
|
11 |
+
modules
|
12 |
+
contributing
|
13 |
+
authors
|
14 |
+
history
|
15 |
+
|
16 |
+
目次と表
|
17 |
+
==================
|
18 |
+
* :ref:`genindex`
|
19 |
+
* :ref:`modindex`
|
20 |
+
* :ref:`search`
|
ja/installation.rst
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. highlight:: shell
|
2 |
+
|
3 |
+
============
|
4 |
+
インストール方法
|
5 |
+
============
|
6 |
+
|
7 |
+
|
8 |
+
安定版
|
9 |
+
--------------
|
10 |
+
|
11 |
+
deep_translatorをインストールしたい場合、以下のコマンドをターミナルで入力してください:
|
12 |
+
|
13 |
+
.. code-block:: console
|
14 |
+
|
15 |
+
$ pip install deep_translator
|
16 |
+
|
17 |
+
常に最新の安定版をインストールできるため、deep_translatorはこの方法でインストールすることを推奨します。
|
18 |
+
|
19 |
+
pipがインストールされていない場合は、以下のPythonインストールガイドを参照してください。
|
20 |
+
|
21 |
+
.. _pip: https://pip.pypa.io
|
22 |
+
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
|
23 |
+
|
24 |
+
|
25 |
+
From sources
|
26 |
+
------------
|
27 |
+
|
28 |
+
deep_translatorのソースはGithubからダウンロードできます.
|
29 |
+
|
30 |
+
公開されているリポジトリのクローンも可能です:
|
31 |
+
|
32 |
+
.. code-block:: console
|
33 |
+
|
34 |
+
$ git clone git://github.com/nidhaloff/deep_translator
|
35 |
+
|
36 |
+
tarballをインストールする場合は以下のようになります:
|
37 |
+
|
38 |
+
.. code-block:: console
|
39 |
+
|
40 |
+
$ curl -OJL https://github.com/nidhaloff/deep_translator/tarball/master
|
41 |
+
|
42 |
+
クローンした後に、以下のコマンドを実行することでインストールが出来ます:
|
43 |
+
|
44 |
+
.. code-block:: console
|
45 |
+
|
46 |
+
$ python setup.py install
|
47 |
+
|
48 |
+
|
49 |
+
.. _Github repo: https://github.com/nidhaloff/deep_translator
|
50 |
+
.. _tarball: https://github.com/nidhaloff/deep_translator/tarball/master
|
ja/usage.rst
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=====
|
2 |
+
使い方
|
3 |
+
=====
|
4 |
+
|
5 |
+
.. code-block:: python
|
6 |
+
|
7 |
+
from deep_translator import GoogleTranslator, PonsTranslator, LingueeTranslator, MyMemoryTranslator
|
8 |
+
|
9 |
+
english_text = 'happy coding'
|
10 |
+
|
11 |
+
result_german = GoogleTranslator(source='auto', target='de').translate(text=english_text)
|
12 |
+
|
13 |
+
# 言語を名前で指定することもできます:
|
14 |
+
translated = GoogleTranslator(source='english', target='german').translate(text=english_text)
|
15 |
+
|
16 |
+
# テキストファイルを翻訳したい場合
|
17 |
+
translated = GoogleTranslator(source='auto', target='german').translate_file('path/to/file')
|
18 |
+
|
19 |
+
# 複数の言語の文章の翻訳を自動化したい場合
|
20 |
+
translated = GoogleTranslator(source='auto', target='de').translate_sentences(your_list_of_sentences)
|
21 |
+
|
22 |
+
|
23 |
+
Ponsを利用することも出来ます: Pons.com
|
24 |
+
|
25 |
+
|
26 |
+
.. code-block:: python
|
27 |
+
|
28 |
+
word = 'good'
|
29 |
+
translated_word = PonsTranslator(source='english', target='french').translate(word)
|
30 |
+
|
31 |
+
# 翻訳する単語の同義語を全て取得したい場合は、return_allにTrueを指定してください。
|
32 |
+
translated_word = PonsTranslator(source='english', target='french').translate(word, return_all=True)
|
33 |
+
|
34 |
+
|
35 |
+
deep_translatorのバージョン1.0.0以上でLingueeをサポートしています:
|
36 |
+
|
37 |
+
|
38 |
+
.. code-block:: python
|
39 |
+
|
40 |
+
word = 'good'
|
41 |
+
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
42 |
+
|
43 |
+
# 翻訳する単語の同義語を全て取得したい場合は、return_allにTrueを指定してください。
|
44 |
+
translated_word = LingueeTranslator(source='english', target='french').translate(word, return_all=True)
|
45 |
+
|
46 |
+
|
47 |
+
Mymemoryはバージョン1.0.2以上でサポートされています:
|
48 |
+
|
49 |
+
.. code-block:: python
|
50 |
+
|
51 |
+
word = 'good'
|
52 |
+
translated_word = MyMemoryTranslator(source='english', target='french').translate(word)
|
53 |
+
|
54 |
+
|
55 |
+
ターミナルでの使用方法
|
56 |
+
====================
|
57 |
+
|
58 |
+
ターミナルからdeep_translatorをすぐに使用できます。使用するには、使用する翻訳サービス、翻訳元の言語、翻訳先の言語、翻訳するテキストなどを引数に指定する必要があります。
|
59 |
+
たとえば、Google翻訳を使用するには、引数として「google」を指定します。引数を変更することで、サポートされている他の翻訳サービスに切り替えることも可能です。ドキュメントを読んで、このツールでサポートされている翻訳サービスを確認してください。
|
60 |
+
|
61 |
+
.. code-block:: console
|
62 |
+
|
63 |
+
$ deep_translator --translator "google" --source "english" --target "german" --text "happy coding"
|
64 |
+
|
65 |
+
以下のように短く記述することもできます:
|
66 |
+
|
67 |
+
.. code-block:: console
|
68 |
+
|
69 |
+
$ deep_translator -trans "google" -src "english" -tg "german" -txt "happy coding"
|
70 |
+
|
71 |
+
翻訳元と翻訳先の言語を省略形で引数に指定することも出来ます。
|
72 |
+
|
73 |
+
.. code-block:: console
|
74 |
+
|
75 |
+
$ deep_translator -trans "google" -src "en" -tg "de" -txt "happy coding"
|