Code author: Sang Han <jjangsangy@gmail.com>
Returns the url encoded string that will be pushed to the translation server for parsing.
List of acceptable language codes for source and target languages can be found as a JSON file in the etc directory.
Some source languages are limited in scope of the possible target languages that are available.
>>> from translate import translator
>>> translator('en', 'zh-TW', 'Hello World!')
'你好世界!'
Parameters: |
|
---|---|
Returns: | Request Interface |
Return type: | Dictionary |
Initializes coroutine essentially priming it to the yield statement. Used as a decorator over functions that generate coroutines.
# Basic coroutine producer/consumer pattern
from translate import coroutine
@coroutine
def coroutine_foo(bar):
try:
while True:
baz = (yield)
bar.send(baz)
except GeneratorExit:
bar.close()
Parameters: | func (Function) – Unprimed Generator |
---|---|
Returns: | Initialized Coroutine |
Return type: | Function |
Decorates a function returning the url of translation API. Creates and maintains HTTP connection state
Returns a dict response object from the server containing the translated text and metadata of the request body
Parameters: | interface (Function) – Callable Request Interface |
---|
Coroutine starting point. Produces text stream and forwards to consumers
Parameters: | target (Coroutine) – Target coroutine consumer |
---|
Consumes text streams and spools them together for more io efficient processes.
Parameters: |
|
---|
Task Setter Coroutine
End point destination coroutine of a purely consumer type. Delegates Text IO to the write_stream function.
Parameters: |
|
---|---|
Type: | Bool |
Parameters: | script (Iterable) – Translated Text |
---|---|
Return None: |
Generic accumulator function.
Parameters: |
|
---|---|
Returns: | Combined Values |
Task Setter Coroutine
End point destination coroutine of a purely consumer type. Delegates Text IO to the write_stream function.
Parameters: |
|
---|---|
Type: | Bool |
Parameters: | script (Iterable) – Translated Text |
---|---|
Return None: |
Opens up file located under the etc directory containing language codes and prints them out.
Parameters: | file (str) – Path to location of json file |
---|---|
Returns: | language codes |
Return type: | dict |
Generates a formatted table of language codes