Module pywikipedia.translator
This module translates a string from one language to another, using
translations given in a hard-coded dictionary. Various dictionaries exist for
different types of text; e.g. type 'geography' is for tables about places and
regions, and 'city' is for tables about cities and villages.
For each table type, there can be three lists:
* translations - direct replacements. Work in either direction, e.g. if
the bot knows that he should replace 'Location' with 'Ligging'
when translating from English to Dutch, he can also translate
it from Dutch to English.
* regexes - regular expression replacements. These are more powerful than
direct replacements as they support wildcards etc., but only
work in one direction.
* includes - one type can include all items from another type, e.g. when
translating a text of the type 'city', the bot also tries to
apply the translations and regexes given for type 'geography'
because 'city' includes 'geography'.
Function Summary |
|
print_debug(text)
|
|
translate(text,
type,
from_lang,
debug_mode,
to_lang)
|
- Imported modules:
-
re
,
string
,
pywikipedia.wikipedia
- Imported variables:
-
types