lang

Classes that represent languages and provides language-specific information.

All classes inherit from the parent class called common.

The type of data includes:

af

This module represents the Afrikaans language.

class translate.lang.af.af

This class represents Afrikaans.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Modify this for the indefinite article (‘n).

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

translate.lang.af.cyr2lat = {u'\u0401': u'Jo', u'\u0410': u'A', u'\u0411': u'B', u'\u0412': u'W', u'\u0413': u'G', u'\u0414': u'D', u'\u0414\u0416': u'Dj', u'\u0415': u'Je', u'\u0415\u0419': u'Ei', u'\u0416': u'Zj', u'\u0417': u'Z', u'\u0418': u'I', u'\u0419': u'J', u'\u041a': u'K', u'\u041b': u'L', u'\u041c': u'M', u'\u041d': u'N', u'\u041e': u'O', u'\u041f': u'P', u'\u0420': u'R', u'\u0421': u'S', u'\u0422': u'T', u'\u0423': u'Oe', u'\u0424': u'F', u'\u0425': u'Ch', u'\u0426': u'Ts', u'\u0427': u'Tj', u'\u0428': u'Sj', u'\u0429': u'Sjtsj', u'\u042a': u'', u'\u042b': u'I', u'\u042c': u'', u'\u042d': u'E', u'\u042e': u'Joe', u'\u042f': u'Ja', u'\u0430': u'a', u'\u0431': u'b', u'\u0432': u'w', u'\u0433': u'g', u'\u0434': u'd', u'\u0434\u0436': u'dj', u'\u0435': u'je', u'\u0435\u0439': u'ei', u'\u0436': u'zj', u'\u0437': u'z', u'\u0438': u'i', u'\u0439': u'j', u'\u043a': u'k', u'\u043b': u'l', u'\u043c': u'm', u'\u043d': u'n', u'\u043e': u'o', u'\u043f': u'p', u'\u0440': u'r', u'\u0441': u's', u'\u0442': u't', u'\u0443': u'oe', u'\u0444': u'f', u'\u0445': u'ch', u'\u0446': u'ts', u'\u0447': u'tj', u'\u0448': u'sj', u'\u0449': u'sjtsj', u'\u044a': u'', u'\u044b': u'i', u'\u044c': u'', u'\u044d': u'e', u'\u044e': u'joe', u'\u044f': u'ja', u'\u0451': u'jo'}

Mapping of Cyrillic to Latin letters for transliteration in Afrikaans

translate.lang.af.tranliterate_cyrillic(text)

Convert Cyrillic text to Latin according to the AWS transliteration rules.

am

This module represents the Amharic language.

class translate.lang.am.am

This class represents Amharic.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ar

This module represents the Arabic language.

class translate.lang.ar.ar

This class represents Arabic.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

bn

This module represents the Bengali language.

class translate.lang.bn.bn

This class represents Bengali.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

code_or

This module represents the Odia language.

class translate.lang.code_or.code_or

This class represents Odia.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

common

This module contains all the common features for languages.

Supported features:

  • language code (km, af)
  • language name (Khmer, Afrikaans)
  • Plurals
    • Number of plurals (nplurals)
    • Plural equation
  • pofilter tests to ignore

Segmentation:

  • characters
  • words
  • sentences

Punctuation:

  • End of sentence
  • Start of sentence
  • Middle of sentence
  • Quotes
    • single
    • double
  • Valid characters
  • Accelerator characters
  • Special characters
  • Direction (rtl or ltr)

TODOs and Ideas for possible features:

  • Language-Team information
  • Segmentation
    • phrases
class translate.lang.common.Common

This class is the common parent class for all language classes.

CJKpunc = u'\u3002\u3001\uff0c\uff1b\uff01\uff1f\u300c\u300d\u300e\u300f\u3010\u3011'

These punctuation marks are used in certain circumstances with CJK languages.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

checker = None

A language specific checker instance (see filters.checks).

This doesn’t need to be supplied, but will be used if it exists.

code = u''

The ISO 639 language code, possibly with a country specifier or other modifier.

Examples:

km
pt_BR
sr_YU@Latn
commonpunc = u'.,;:!?-@#$%^*_()[]{}/\\\'`"<>'

These punctuation marks are common in English and most languages that use latin script.

ethiopicpunc = u'\u1362\u1364\u1363'

These punctuation marks are used by several Ethiopic languages.

fullname = u''

The full (English) name of this language.

Dialect codes should have the form of:

ignoretests = {}

Dictionary of tests to ignore in some or all checkers.

Keys are checker names and values are list of names for the ignored tests in the checker. A special ‘all’ checker name can be used to tell that the tests must be ignored in all the checkers.

Listed checkers to ignore tests on must be lowercase strings for the checker name, for example “mozilla” for MozillaChecker or “libreoffice” for LibreOfficeChecker.

indicpunc = u'\u0964\u0965\u0970'

These punctuation marks are used by several Indic languages.

invertedpunc = u'\xbf\xa1'

Inverted punctuation sometimes used at the beginning of sentences in Spanish, Asturian, Galician, and Catalan.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

listseperator = u', '

This string is used to separate lists of textual elements. Most languages probably can stick with the default comma, but Arabic and some Asian languages might want to override this.

miscpunc = u'\u2026\xb1\xb0\xb9\xb2\xb3\xb7\xa9\xae\xd7\xa3\xa5\u20ac'

The middle dot (·) is used by Greek and Georgian.

mozilla_pluralequation = u'0'

This of languages that has different plural formula in Mozilla than the standard one in Gettext.

nplurals = 0

The number of plural forms of this language.

0 is not a valid value - it must be overridden. Any positive integer is valid (it should probably be between 1 and 6)

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

numbertuple = ()

A tuple of number transformation rules that can be used by numbertranslate().

classmethod numstart(text)

Determines whether the text starts with a numeric value.

pluralequation = u'0'

The plural equation for selection of plural forms.

This is used for PO files to fill into the header.

puncdict = {}

A dictionary of punctuation transformation rules that can be used by punctranslate().

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

punctuation = u'.,;:!?-@#$%^*_()[]{}/\\\'`"<>\u2018\u2019\u201b\u201c\u201d\u201e\u201f\u2032\u2033\u2034\u2035\u2036\u2037\u2039\u203a\xab\xbb\xbf\xa1\u060c\u061f\u061b\xf7\u3002\u3001\uff0c\uff1b\uff01\uff1f\u300c\u300d\u300e\u300f\u3010\u3011\u0964\u0965\u0970\u1362\u1364\u1363\u2026\xb1\xb0\xb9\xb2\xb3\xb7\xa9\xae\xd7\xa3\xa5\u20ac'

We include many types of punctuation here, simply since this is only meant to determine if something is punctuation. Hopefully we catch some languages which might not be represented with modules. Most languages won’t need to override this.

quotes = u'\u2018\u2019\u201b\u201c\u201d\u201e\u201f\u2032\u2033\u2034\u2035\u2036\u2037\u2039\u203a\xab\xbb'

These are different quotation marks used by various languages.

rtlpunc = u'\u060c\u061f\u061b\xf7'

These punctuation marks are used by Arabic and Persian, for example.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

sentenceend = u'.!?\u2026\u0589\u061f\u0964\u3002\uff01\uff1f\u1362\u06d4'

These marks can indicate a sentence end. Once again we try to account for many languages. Most langauges won’t need to override this.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

specialchars = u''

Characters used by the language that might not be easy to input with common keyboard layouts

validaccel = None

Characters that can be used as accelerators (access keys) i.e. Alt+X where X is the accelerator. These can include combining diacritics as long as they are accessible from the users keyboard in a single keystroke, but normally they would be at least precomposed characters. All characters, lower and upper, are included in the list.

validdoublewords = []

Some languages allow double words in certain cases. This is a dictionary of such words.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

data

This module stores information and functionality that relates to plurals.

translate.lang.data.cldr_plural_categories = [u'zero', u'one', u'two', u'few', u'many', u'other']

List of plural tags generated from CLDR 32.0.1 using https://github.com/WeblateOrg/language-data

translate.lang.data.expansion_factors = {u'af': 0.1, u'ar': -0.09, u'es': 0.21, u'fr': 0.28, u'it': 0.2}

Source to target string length expansion factors.

translate.lang.data.forceunicode(string)

Ensures that the string is in unicode.

Parameters:string (Unicode, String) – A text string
Returns:String converted to Unicode and normalized as needed.
Return type:Unicode
translate.lang.data.get_country_iso_name(country_code)

Return country ISO name.

translate.lang.data.get_language_iso_fullname(language_code)

Return language ISO fullname.

If language code is not a simple ISO 639 code, then we try to split into a two part language code (ISO 639 and ISO 3166).

translate.lang.data.get_language_iso_name(language_code)

Return language ISO name.

translate.lang.data.gettext_country(langcode=None)

Returns a gettext function to translate country names into the given language, or the system language if no language is specified.

translate.lang.data.gettext_domain(langcode, domain, localedir=None)

Returns a gettext function for given iso domain

translate.lang.data.gettext_lang(langcode=None)

Returns a gettext function to translate language names into the given language, or the system language if no language is specified.

translate.lang.data.languagematch(languagecode, otherlanguagecode)

matches a languagecode to another, ignoring regions in the second

translate.lang.data.languages = {u'ach': (u'Acholi', 2, u'n > 1'), u'af': (u'Afrikaans', 2, u'(n != 1)'), u'ak': (u'Akan', 2, u'n > 1'), u'am': (u'Amharic', 2, u'n > 1'), u'an': (u'Aragonese', 2, u'(n != 1)'), u'anp': (u'Angika', 2, u'(n != 1)'), u'ar': (u'Arabic', 6, u'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5'), u'arn': (u'Mapudungun; Mapuche', 2, u'n > 1'), u'as': (u'Assamese', 2, u'(n != 1)'), u'ast': (u'Asturian; Bable; Leonese; Asturleonese', 2, u'(n != 1)'), u'ay': (u'Aymar\xe1', 1, u'0'), u'az': (u'Azerbaijani', 2, u'(n != 1)'), u'be': (u'Belarusian', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'bg': (u'Bulgarian', 2, u'(n != 1)'), u'bn': (u'Bengali', 2, u'(n != 1)'), u'bn_BD': (u'Bengali (Bangladesh)', 2, u'(n != 1)'), u'bn_IN': (u'Bengali (India)', 2, u'(n != 1)'), u'bo': (u'Tibetan', 1, u'0'), u'br': (u'Breton', 2, u'n > 1'), u'brx': (u'Bodo', 2, u'(n != 1)'), u'bs': (u'Bosnian', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'ca': (u'Catalan; Valencian', 2, u'(n != 1)'), u'ca@valencia': (u'Catalan; Valencian (Valencia)', 2, u'(n != 1)'), u'cgg': (u'Chiga', 1, u'0'), u'cs': (u'Czech', 3, u'(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'), u'csb': (u'Kashubian', 3, u'n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'cy': (u'Welsh', 2, u'(n==2) ? 1 : 0'), u'da': (u'Danish', 2, u'(n != 1)'), u'de': (u'German', 2, u'(n != 1)'), u'doi': (u'Dogri', 2, u'(n != 1)'), u'dz': (u'Dzongkha', 1, u'0'), u'el': (u'Greek, Modern (1453-)', 2, u'(n != 1)'), u'en': (u'English', 2, u'(n != 1)'), u'en_GB': (u'English (United Kingdom)', 2, u'(n != 1)'), u'en_ZA': (u'English (South Africa)', 2, u'(n != 1)'), u'eo': (u'Esperanto', 2, u'(n != 1)'), u'es': (u'Spanish; Castilian', 2, u'(n != 1)'), u'es_AR': (u'Argentinean Spanish', 2, u'(n != 1)'), u'et': (u'Estonian', 2, u'(n != 1)'), u'eu': (u'Basque', 2, u'(n != 1)'), u'fa': (u'Persian', 2, u'n > 1'), u'ff': (u'Fulah', 2, u'(n != 1)'), u'fi': (u'Finnish', 2, u'(n != 1)'), u'fil': (u'Filipino; Pilipino', 2, u'(n > 1)'), u'fo': (u'Faroese', 2, u'(n != 1)'), u'fr': (u'French', 2, u'(n > 1)'), u'fur': (u'Friulian', 2, u'(n != 1)'), u'fy': (u'Frisian', 2, u'(n != 1)'), u'ga': (u'Irish', 5, u'n==1 ? 0 : n==2 ? 1 : (n>2 && n<7) ? 2 :(n>6 && n<11) ? 3 : 4'), u'gd': (u'Gaelic; Scottish Gaelic', 4, u'(n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3'), u'gl': (u'Galician', 2, u'(n != 1)'), u'gu': (u'Gujarati', 2, u'(n != 1)'), u'gun': (u'Gun', 2, u'(n > 1)'), u'ha': (u'Hausa', 2, u'(n != 1)'), u'he': (u'Hebrew', 2, u'(n != 1)'), u'hi': (u'Hindi', 2, u'(n != 1)'), u'hne': (u'Chhattisgarhi', 2, u'(n != 1)'), u'hr': (u'Croatian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ht': (u'Haitian; Haitian Creole', 2, u'(n != 1)'), u'hu': (u'Hungarian', 2, u'(n != 1)'), u'hy': (u'Armenian', 1, u'0'), u'ia': (u'Interlingua (International Auxiliary Language Association)', 2, u'(n != 1)'), u'id': (u'Indonesian', 1, u'0'), u'is': (u'Icelandic', 2, u'(n != 1)'), u'it': (u'Italian', 2, u'(n != 1)'), u'ja': (u'Japanese', 1, u'0'), u'jbo': (u'Lojban', 1, u'0'), u'jv': (u'Javanese', 2, u'(n != 1)'), u'ka': (u'Georgian', 1, u'0'), u'kab': (u'Kabyle', 2, u'(n != 1)'), u'kk': (u'Kazakh', 2, u'n != 1'), u'kl': (u'Greenlandic', 2, u'(n != 1)'), u'km': (u'Central Khmer', 1, u'0'), u'kn': (u'Kannada', 2, u'(n != 1)'), u'ko': (u'Korean', 1, u'0'), u'kok': (u'Konkani', 2, u'(n != 1)'), u'ks': (u'Kashmiri', 2, u'(n != 1)'), u'ku': (u'Kurdish', 2, u'(n != 1)'), u'kw': (u'Cornish', 4, u'(n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3'), u'ky': (u'Kirghiz; Kyrgyz', 2, u'n != 1'), u'lb': (u'Luxembourgish; Letzeburgesch', 2, u'(n != 1)'), u'ln': (u'Lingala', 2, u'(n > 1)'), u'lo': (u'Lao', 1, u'0'), u'lt': (u'Lithuanian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'lv': (u'Latvian', 3, u'(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2)'), u'mai': (u'Maithili', 2, u'(n != 1)'), u'me': (u'Montenegrin', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'mfe': (u'Morisyen', 2, u'(n > 1)'), u'mg': (u'Malagasy', 2, u'(n > 1)'), u'mi': (u'Maori', 2, u'(n > 1)'), u'mk': (u'Macedonian', 2, u'(n==1 || n%10==1 ? 0 : 1)'), u'ml': (u'Malayalam', 2, u'(n != 1)'), u'mn': (u'Mongolian', 2, u'(n != 1)'), u'mni': (u'Meithei (Manipuri)', 2, u'(n != 1)'), u'mnk': (u'Mandinka', 3, u'(n==0 ? 0 : n==1 ? 1 : 2)'), u'mr': (u'Marathi', 2, u'(n != 1)'), u'ms': (u'Malay', 1, u'0'), u'mt': (u'Maltese', 4, u'(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'), u'my': (u'Burmese', 1, u'0'), u'nah': (u'Nahuatl languages', 2, u'(n != 1)'), u'nap': (u'Neapolitan', 2, u'(n != 1)'), u'nb': (u'Bokm\xe5l, Norwegian; Norwegian Bokm\xe5l', 2, u'(n != 1)'), u'ne': (u'Nepali', 2, u'(n != 1)'), u'nl': (u'Dutch; Flemish', 2, u'(n != 1)'), u'nn': (u'Norwegian Nynorsk; Nynorsk, Norwegian', 2, u'(n != 1)'), u'nqo': (u"N'Ko", 2, u'(n > 1)'), u'nso': (u'Pedi; Sepedi; Northern Sotho', 2, u'(n != 1)'), u'oc': (u'Occitan (post 1500)', 2, u'(n > 1)'), u'or': (u'Odia', 2, u'(n != 1)'), u'pa': (u'Panjabi; Punjabi', 2, u'(n != 1)'), u'pap': (u'Papiamento', 2, u'(n != 1)'), u'pl': (u'Polish', 3, u'(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'pms': (u'Piemontese', 2, u'(n != 1)'), u'ps': (u'Pushto; Pashto', 2, u'(n != 1)'), u'pt': (u'Portuguese', 2, u'(n != 1)'), u'pt_BR': (u'Portuguese (Brazil)', 2, u'(n > 1)'), u'rm': (u'Romansh', 2, u'(n != 1)'), u'ro': (u'Romanian', 3, u'(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2)'), u'ru': (u'Russian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'rw': (u'Kinyarwanda', 2, u'(n != 1)'), u'sa': (u'Sanskrit', 3, u'(n==1 ? 0 : n==2 ? 1 : 2)'), u'sah': (u'Yakut', 1, u'0'), u'sat': (u'Santali', 2, u'(n != 1)'), u'sco': (u'Scots', 2, u'(n != 1)'), u'sd': (u'Sindhi', 2, u'(n != 1)'), u'se': (u'Northern Sami', 2, u'(n != 1)'), u'si': (u'Sinhala; Sinhalese', 2, u'(n != 1)'), u'sk': (u'Slovak', 3, u'(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'), u'sl': (u'Slovenian', 4, u'(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)'), u'so': (u'Somali', 2, u'(n != 1)'), u'son': (u'Songhai languages', 1, u'0'), u'sq': (u'Albanian', 2, u'(n != 1)'), u'sr': (u'Serbian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'st': (u'Sotho, Southern', 2, u'(n != 1)'), u'su': (u'Sundanese', 1, u'0'), u'sv': (u'Swedish', 2, u'(n != 1)'), u'sw': (u'Swahili', 2, u'(n != 1)'), u'szl': (u'Silesian', 3, u'(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ta': (u'Tamil', 2, u'(n != 1)'), u'te': (u'Telugu', 2, u'(n != 1)'), u'tg': (u'Tajik', 1, u'0'), u'th': (u'Thai', 1, u'0'), u'ti': (u'Tigrinya', 2, u'(n > 1)'), u'tk': (u'Turkmen', 2, u'(n != 1)'), u'tr': (u'Turkish', 2, u'(n != 1)'), u'tt': (u'Tatar', 1, u'0'), u'ug': (u'Uighur; Uyghur', 1, u'0'), u'uk': (u'Ukrainian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ur': (u'Urdu', 2, u'(n != 1)'), u'uz': (u'Uzbek', 2, u'(n > 1)'), u've': (u'Venda', 2, u'(n != 1)'), u'vi': (u'Vietnamese', 1, u'0'), u'wa': (u'Walloon', 2, u'(n > 1)'), u'wo': (u'Wolof', 2, u'(n != 1)'), u'yo': (u'Yoruba', 2, u'(n != 1)'), u'yue': (u'Yue', 1, u'0'), u'zh_CN': (u'Chinese (China)', 1, u'0'), u'zh_HK': (u'Chinese (Hong Kong)', 1, u'0'), u'zh_TW': (u'Chinese (Taiwan)', 1, u'0'), u'zu': (u'Zulu', 2, u'(n != 1)')}

Dictionary of language data. The language code is the dictionary key (which may contain country codes and modifiers). The value is a tuple: (Full name in English from iso-codes, nplurals, plural equation).

Note that the English names should not be used in user facing places - it should always be passed through the function returned from tr_lang(), or at least passed through _fix_language_name().

translate.lang.data.normalize(string, normal_form=u'NFC')

Return a unicode string in its normalized form

Parameters:
  • string – The string to be normalized
  • normal_form – NFC (default), NFD, NFKC, NFKD
Returns:

Normalized string

translate.lang.data.normalized_unicode(string)

Forces the string to unicode and does normalization.

translate.lang.data.scripts = {u'Beng': [u'bn', u'mni'], u'Deva': [u'anp', u'bho', u'brx', u'doi', u'hi', u'kfy', u'kok', u'mai', u'mr', u'sa', u'sat'], u'Gujr': [u'gu'], u'Khmr': [u'km'], u'Knda': [u'kn'], u'Laoo': [u'lo'], u'Mlym': [u'ml'], u'Mymr': [u'my', u'shn'], u'Orya': [u'or'], u'Sind': [u'sd'], u'Taml': [u'ta'], u'Tibt': [u'bo'], u'assamese': [u'as'], u'chinese': [u'yue'], u'perso-arabic': [u'ks']}

Dictionary of scripts data. The dictionary keys are ISO 15924 script codes, and script names where scripts are missing from standard. The value is a list of codes for languages using that script.

This is mainly used to alter the behavior of some checks (the accelerators one for example).

translate.lang.data.simplercode(code)

This attempts to simplify the given language code by ignoring country codes, for example.

translate.lang.data.simplify_to_common(language_code, languages={u'ach': (u'Acholi', 2, u'n > 1'), u'af': (u'Afrikaans', 2, u'(n != 1)'), u'ak': (u'Akan', 2, u'n > 1'), u'am': (u'Amharic', 2, u'n > 1'), u'an': (u'Aragonese', 2, u'(n != 1)'), u'anp': (u'Angika', 2, u'(n != 1)'), u'ar': (u'Arabic', 6, u'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5'), u'arn': (u'Mapudungun; Mapuche', 2, u'n > 1'), u'as': (u'Assamese', 2, u'(n != 1)'), u'ast': (u'Asturian; Bable; Leonese; Asturleonese', 2, u'(n != 1)'), u'ay': (u'Aymar\xe1', 1, u'0'), u'az': (u'Azerbaijani', 2, u'(n != 1)'), u'be': (u'Belarusian', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'bg': (u'Bulgarian', 2, u'(n != 1)'), u'bn': (u'Bengali', 2, u'(n != 1)'), u'bn_BD': (u'Bengali (Bangladesh)', 2, u'(n != 1)'), u'bn_IN': (u'Bengali (India)', 2, u'(n != 1)'), u'bo': (u'Tibetan', 1, u'0'), u'br': (u'Breton', 2, u'n > 1'), u'brx': (u'Bodo', 2, u'(n != 1)'), u'bs': (u'Bosnian', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'ca': (u'Catalan; Valencian', 2, u'(n != 1)'), u'ca@valencia': (u'Catalan; Valencian (Valencia)', 2, u'(n != 1)'), u'cgg': (u'Chiga', 1, u'0'), u'cs': (u'Czech', 3, u'(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'), u'csb': (u'Kashubian', 3, u'n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'cy': (u'Welsh', 2, u'(n==2) ? 1 : 0'), u'da': (u'Danish', 2, u'(n != 1)'), u'de': (u'German', 2, u'(n != 1)'), u'doi': (u'Dogri', 2, u'(n != 1)'), u'dz': (u'Dzongkha', 1, u'0'), u'el': (u'Greek, Modern (1453-)', 2, u'(n != 1)'), u'en': (u'English', 2, u'(n != 1)'), u'en_GB': (u'English (United Kingdom)', 2, u'(n != 1)'), u'en_ZA': (u'English (South Africa)', 2, u'(n != 1)'), u'eo': (u'Esperanto', 2, u'(n != 1)'), u'es': (u'Spanish; Castilian', 2, u'(n != 1)'), u'es_AR': (u'Argentinean Spanish', 2, u'(n != 1)'), u'et': (u'Estonian', 2, u'(n != 1)'), u'eu': (u'Basque', 2, u'(n != 1)'), u'fa': (u'Persian', 2, u'n > 1'), u'ff': (u'Fulah', 2, u'(n != 1)'), u'fi': (u'Finnish', 2, u'(n != 1)'), u'fil': (u'Filipino; Pilipino', 2, u'(n > 1)'), u'fo': (u'Faroese', 2, u'(n != 1)'), u'fr': (u'French', 2, u'(n > 1)'), u'fur': (u'Friulian', 2, u'(n != 1)'), u'fy': (u'Frisian', 2, u'(n != 1)'), u'ga': (u'Irish', 5, u'n==1 ? 0 : n==2 ? 1 : (n>2 && n<7) ? 2 :(n>6 && n<11) ? 3 : 4'), u'gd': (u'Gaelic; Scottish Gaelic', 4, u'(n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3'), u'gl': (u'Galician', 2, u'(n != 1)'), u'gu': (u'Gujarati', 2, u'(n != 1)'), u'gun': (u'Gun', 2, u'(n > 1)'), u'ha': (u'Hausa', 2, u'(n != 1)'), u'he': (u'Hebrew', 2, u'(n != 1)'), u'hi': (u'Hindi', 2, u'(n != 1)'), u'hne': (u'Chhattisgarhi', 2, u'(n != 1)'), u'hr': (u'Croatian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ht': (u'Haitian; Haitian Creole', 2, u'(n != 1)'), u'hu': (u'Hungarian', 2, u'(n != 1)'), u'hy': (u'Armenian', 1, u'0'), u'ia': (u'Interlingua (International Auxiliary Language Association)', 2, u'(n != 1)'), u'id': (u'Indonesian', 1, u'0'), u'is': (u'Icelandic', 2, u'(n != 1)'), u'it': (u'Italian', 2, u'(n != 1)'), u'ja': (u'Japanese', 1, u'0'), u'jbo': (u'Lojban', 1, u'0'), u'jv': (u'Javanese', 2, u'(n != 1)'), u'ka': (u'Georgian', 1, u'0'), u'kab': (u'Kabyle', 2, u'(n != 1)'), u'kk': (u'Kazakh', 2, u'n != 1'), u'kl': (u'Greenlandic', 2, u'(n != 1)'), u'km': (u'Central Khmer', 1, u'0'), u'kn': (u'Kannada', 2, u'(n != 1)'), u'ko': (u'Korean', 1, u'0'), u'kok': (u'Konkani', 2, u'(n != 1)'), u'ks': (u'Kashmiri', 2, u'(n != 1)'), u'ku': (u'Kurdish', 2, u'(n != 1)'), u'kw': (u'Cornish', 4, u'(n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3'), u'ky': (u'Kirghiz; Kyrgyz', 2, u'n != 1'), u'lb': (u'Luxembourgish; Letzeburgesch', 2, u'(n != 1)'), u'ln': (u'Lingala', 2, u'(n > 1)'), u'lo': (u'Lao', 1, u'0'), u'lt': (u'Lithuanian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'lv': (u'Latvian', 3, u'(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2)'), u'mai': (u'Maithili', 2, u'(n != 1)'), u'me': (u'Montenegrin', 3, u'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'), u'mfe': (u'Morisyen', 2, u'(n > 1)'), u'mg': (u'Malagasy', 2, u'(n > 1)'), u'mi': (u'Maori', 2, u'(n > 1)'), u'mk': (u'Macedonian', 2, u'(n==1 || n%10==1 ? 0 : 1)'), u'ml': (u'Malayalam', 2, u'(n != 1)'), u'mn': (u'Mongolian', 2, u'(n != 1)'), u'mni': (u'Meithei (Manipuri)', 2, u'(n != 1)'), u'mnk': (u'Mandinka', 3, u'(n==0 ? 0 : n==1 ? 1 : 2)'), u'mr': (u'Marathi', 2, u'(n != 1)'), u'ms': (u'Malay', 1, u'0'), u'mt': (u'Maltese', 4, u'(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'), u'my': (u'Burmese', 1, u'0'), u'nah': (u'Nahuatl languages', 2, u'(n != 1)'), u'nap': (u'Neapolitan', 2, u'(n != 1)'), u'nb': (u'Bokm\xe5l, Norwegian; Norwegian Bokm\xe5l', 2, u'(n != 1)'), u'ne': (u'Nepali', 2, u'(n != 1)'), u'nl': (u'Dutch; Flemish', 2, u'(n != 1)'), u'nn': (u'Norwegian Nynorsk; Nynorsk, Norwegian', 2, u'(n != 1)'), u'nqo': (u"N'Ko", 2, u'(n > 1)'), u'nso': (u'Pedi; Sepedi; Northern Sotho', 2, u'(n != 1)'), u'oc': (u'Occitan (post 1500)', 2, u'(n > 1)'), u'or': (u'Odia', 2, u'(n != 1)'), u'pa': (u'Panjabi; Punjabi', 2, u'(n != 1)'), u'pap': (u'Papiamento', 2, u'(n != 1)'), u'pl': (u'Polish', 3, u'(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'pms': (u'Piemontese', 2, u'(n != 1)'), u'ps': (u'Pushto; Pashto', 2, u'(n != 1)'), u'pt': (u'Portuguese', 2, u'(n != 1)'), u'pt_BR': (u'Portuguese (Brazil)', 2, u'(n > 1)'), u'rm': (u'Romansh', 2, u'(n != 1)'), u'ro': (u'Romanian', 3, u'(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2)'), u'ru': (u'Russian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'rw': (u'Kinyarwanda', 2, u'(n != 1)'), u'sa': (u'Sanskrit', 3, u'(n==1 ? 0 : n==2 ? 1 : 2)'), u'sah': (u'Yakut', 1, u'0'), u'sat': (u'Santali', 2, u'(n != 1)'), u'sco': (u'Scots', 2, u'(n != 1)'), u'sd': (u'Sindhi', 2, u'(n != 1)'), u'se': (u'Northern Sami', 2, u'(n != 1)'), u'si': (u'Sinhala; Sinhalese', 2, u'(n != 1)'), u'sk': (u'Slovak', 3, u'(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'), u'sl': (u'Slovenian', 4, u'(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)'), u'so': (u'Somali', 2, u'(n != 1)'), u'son': (u'Songhai languages', 1, u'0'), u'sq': (u'Albanian', 2, u'(n != 1)'), u'sr': (u'Serbian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'st': (u'Sotho, Southern', 2, u'(n != 1)'), u'su': (u'Sundanese', 1, u'0'), u'sv': (u'Swedish', 2, u'(n != 1)'), u'sw': (u'Swahili', 2, u'(n != 1)'), u'szl': (u'Silesian', 3, u'(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ta': (u'Tamil', 2, u'(n != 1)'), u'te': (u'Telugu', 2, u'(n != 1)'), u'tg': (u'Tajik', 1, u'0'), u'th': (u'Thai', 1, u'0'), u'ti': (u'Tigrinya', 2, u'(n > 1)'), u'tk': (u'Turkmen', 2, u'(n != 1)'), u'tr': (u'Turkish', 2, u'(n != 1)'), u'tt': (u'Tatar', 1, u'0'), u'ug': (u'Uighur; Uyghur', 1, u'0'), u'uk': (u'Ukrainian', 3, u'(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), u'ur': (u'Urdu', 2, u'(n != 1)'), u'uz': (u'Uzbek', 2, u'(n > 1)'), u've': (u'Venda', 2, u'(n != 1)'), u'vi': (u'Vietnamese', 1, u'0'), u'wa': (u'Walloon', 2, u'(n > 1)'), u'wo': (u'Wolof', 2, u'(n != 1)'), u'yo': (u'Yoruba', 2, u'(n != 1)'), u'yue': (u'Yue', 1, u'0'), u'zh_CN': (u'Chinese (China)', 1, u'0'), u'zh_HK': (u'Chinese (Hong Kong)', 1, u'0'), u'zh_TW': (u'Chinese (Taiwan)', 1, u'0'), u'zu': (u'Zulu', 2, u'(n != 1)')})

Simplify language code to the most commonly used form for the language, stripping country information for languages that tend not to be localized differently for different countries

translate.lang.data.tr_lang(langcode=None)

Gives a function that can translate a language name, even in the form "language (country)", into the language with iso code langcode, or the system language if no language is specified.

de

This module represents the German language.

class translate.lang.de.de

This class represents German.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

el

This module represents the Greek language.

class translate.lang.el.el

This class represents Greek.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

es

This module represents the Spanish language.

Note

As it only has special case code for initial inverted punctuation, it could also be used for Asturian, Galician, or Catalan.

class translate.lang.es.es

This class represents Spanish.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Implement some extra features for inverted punctuation.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

factory

This module provides a factory to instantiate language classes.

translate.lang.factory.get_all_languages()

Return all language classes.

translate.lang.factory.getlanguage(code)

This returns a language class.

Parameters:code – The ISO 639 language code

fa

This module represents the Persian language.

class translate.lang.fa.fa

This class represents Persian.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Implement “French” quotation marks.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

fi

This module represents the Finnish language.

class translate.lang.fi.fi

This class represents Finnish.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

fr

This module represents the French language.

class translate.lang.fr.fr

This class represents French.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Implement some extra features for quotation marks.

Known shortcomings:
  • % and $ are not touched yet for fear of variables
  • Double spaces might be introduced
classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

gu

This module represents the Gujarati language.

class translate.lang.gu.gu

This class represents Gujarati.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

he

This module represents the Hebrew language.

class translate.lang.he.he

This class represents Hebrew.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

hi

This module represents the Hindi language.

class translate.lang.hi.hi

This class represents Hindi.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

hy

This module represents the Armenian language.

class translate.lang.hy.hy

This class represents Armenian.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

identify

This module contains functions for identifying languages based on language models.

ja

This module represents the Japanese language.

class translate.lang.ja.ja

This class represents Japanese.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

km

This module represents the Khmer language.

class translate.lang.km.km

This class represents Khmer.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

khmerpunc = u'\u17d4\u17d5\u17d6\u17d8'

These marks are only used for Khmer.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

kn

This module represents the Kannada language.

class translate.lang.kn.kn

This class represents Kannada.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ko

This module represents the Korean language.

class translate.lang.ko.ko

This class represents Korean.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ml

This module represents the Malayalam language.

class translate.lang.ml.ml

This class represents Malayalam.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

mr

This module represents the Marathi language.

class translate.lang.mr.mr

This class represents Marathi.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ne

This module represents the Nepali language.

class translate.lang.ne.ne

This class represents Nepali.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ngram

Ngram models for language guessing.

pa

This module represents the Punjabi language.

class translate.lang.pa.pa

This class represents Punjabi.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

poedit

Functions to manage Poedit’s language features.

Note

The ISO 639 maps are from Poedit’s isocode.cpp (v1.4.2) to ensure that we match currently released versions of Poedit.

translate.lang.poedit.dialects = {u'Chinese': {u'TAIWAN': u'zh_TW', u'CHINA': u'zh_CN', u'None': u'zh_CN'}, u'English': {u'UNITED KINGDOM': u'en_GB', u'None': u'en', u'SOUTH AFRICA': u'en_ZA'}, u'Portuguese': {u'BRAZIL': u'pt_BR', u'None': u'pt', u'PORTUGAL': u'pt'}}

Language dialects based on ISO 3166 country names, ‘None’ is the default fallback

translate.lang.poedit.isocode(language, country=None)

Returns a language code for the given Poedit language name.

Poedit uses language and country names in the PO header entries:

  • X-Poedit-Language
  • X-Poedit-Country

This function converts the supplied language name into the required ISO 639 code. If needed, in the case of dialects, the country name is used to create an xx_YY style dialect code.

Parameters:
  • language (String) – Language name
  • country (String) – Country name
Returns:

ISO 639 language code

Return type:

String

translate.lang.poedit.lang_codes = {u'aa': u'Afar', u'ab': u'Abkhazian', u'ae': u'Avestan', u'af': u'Afrikaans', u'am': u'Amharic', u'ar': u'Arabic', u'as': u'Assamese', u'ay': u'Aymara', u'az': u'Azerbaijani', u'ba': u'Bashkir', u'be': u'Belarusian', u'bg': u'Bulgarian', u'bh': u'Bihari', u'bi': u'Bislama', u'bn': u'Bengali', u'bo': u'Tibetan', u'br': u'Breton', u'bs': u'Bosnian', u'ca': u'Catalan', u'ce': u'Chechen', u'ch': u'Chamorro', u'co': u'Corsican', u'cs': u'Czech', u'cu': u'Church Slavic', u'cv': u'Chuvash', u'cy': u'Welsh', u'da': u'Danish', u'de': u'German', u'dz': u'Dzongkha', u'el': u'Greek', u'en': u'English', u'eo': u'Esperanto', u'es': u'Spanish', u'et': u'Estonian', u'eu': u'Basque', u'fa': u'Persian', u'fi': u'Finnish', u'fj': u'Fijian', u'fo': u'Faroese', u'fr': u'French', u'fur': u'Friulian', u'fy': u'Frisian', u'ga': u'Irish', u'gd': u'Gaelic', u'gl': u'Galician', u'gn': u'Guarani', u'gu': u'Gujarati', u'ha': u'Hausa', u'he': u'Hebrew', u'hi': u'Hindi', u'ho': u'Hiri Motu', u'hr': u'Croatian', u'hu': u'Hungarian', u'hy': u'Armenian', u'hz': u'Herero', u'ia': u'Interlingua', u'id': u'Indonesian', u'ie': u'Interlingue', u'ik': u'Inupiaq', u'is': u'Icelandic', u'it': u'Italian', u'iu': u'Inuktitut', u'ja': u'Japanese', u'jw': u'Javanese', u'ka': u'Georgian', u'ki': u'Kikuyu', u'kj': u'Kuanyama', u'kk': u'Kazakh', u'kl': u'Kalaallisut', u'km': u'Khmer', u'kn': u'Kannada', u'ko': u'Korean', u'ks': u'Kashmiri', u'ku': u'Kurdish', u'kv': u'Komi', u'kw': u'Cornish', u'ky': u'Kyrgyz', u'la': u'Latin', u'lb': u'Letzeburgesch', u'ln': u'Lingala', u'lo': u'Lao', u'lt': u'Lithuanian', u'lv': u'Latvian', u'mg': u'Malagasy', u'mh': u'Marshall', u'mi': u'Maori', u'mk': u'Macedonian', u'ml': u'Malayalam', u'mn': u'Mongolian', u'mo': u'Moldavian', u'mr': u'Marathi', u'ms': u'Malay', u'mt': u'Maltese', u'my': u'Burmese', u'na': u'Nauru', u'nb': u'Norwegian Bokmal', u'ne': u'Nepali', u'ng': u'Ndonga', u'nl': u'Dutch', u'nn': u'Norwegian Nynorsk', u'nr': u'Ndebele, South', u'nv': u'Navajo', u'ny': u'Chichewa; Nyanja', u'oc': u'Occitan', u'om': u'(Afan) Oromo', u'or': u'Oriya', u'os': u'Ossetian; Ossetic', u'pa': u'Panjabi', u'pi': u'Pali', u'pl': u'Polish', u'ps': u'Pashto, Pushto', u'pt': u'Portuguese', u'qu': u'Quechua', u'rm': u'Rhaeto-Romance', u'rn': u'Rundi', u'ro': u'Romanian', u'ru': u'Russian', u'rw': u'Kinyarwanda', u'sa': u'Sanskrit', u'sc': u'Sardinian', u'sd': u'Sindhi', u'se': u'Northern Sami', u'sg': u'Sangro', u'sh': u'Serbo-Croatian', u'si': u'Sinhalese', u'sk': u'Slovak', u'sl': u'Slovenian', u'sm': u'Samoan', u'sn': u'Shona', u'so': u'Somali', u'sq': u'Albanian', u'sr': u'Serbian', u'ss': u'Siswati', u'st': u'Sesotho', u'su': u'Sundanese', u'sv': u'Swedish', u'sw': u'Swahili', u'ta': u'Tamil', u'te': u'Telugu', u'tg': u'Tajik', u'th': u'Thai', u'ti': u'Tigrinya', u'tk': u'Turkmen', u'tl': u'Tagalog', u'tn': u'Setswana', u'to': u'Tonga', u'tr': u'Turkish', u'ts': u'Tsonga', u'tt': u'Tatar', u'tw': u'Twi', u'ty': u'Tahitian', u'ug': u'Uighur', u'uk': u'Ukrainian', u'ur': u'Urdu', u'uz': u'Uzbek', u'vi': u'Vietnamese', u'vo': u'Volapuk', u'wa': u'Walloon', u'wo': u'Wolof', u'xh': u'Xhosa', u'yi': u'Yiddish', u'yo': u'Yoruba', u'za': u'Zhuang', u'zh': u'Chinese', u'zu': u'Zulu'}

ISO369 codes and names as used by Poedit. Mostly these are identical to ISO 639, but there are some differences.

translate.lang.poedit.lang_names = {u'(Afan) Oromo': u'om', u'Abkhazian': u'ab', u'Afar': u'aa', u'Afrikaans': u'af', u'Albanian': u'sq', u'Amharic': u'am', u'Arabic': u'ar', u'Armenian': u'hy', u'Assamese': u'as', u'Avestan': u'ae', u'Aymara': u'ay', u'Azerbaijani': u'az', u'Bashkir': u'ba', u'Basque': u'eu', u'Belarusian': u'be', u'Bengali': u'bn', u'Bihari': u'bh', u'Bislama': u'bi', u'Bosnian': u'bs', u'Breton': u'br', u'Bulgarian': u'bg', u'Burmese': u'my', u'Catalan': u'ca', u'Chamorro': u'ch', u'Chechen': u'ce', u'Chichewa; Nyanja': u'ny', u'Chinese': u'zh', u'Church Slavic': u'cu', u'Chuvash': u'cv', u'Cornish': u'kw', u'Corsican': u'co', u'Croatian': u'hr', u'Czech': u'cs', u'Danish': u'da', u'Dutch': u'nl', u'Dzongkha': u'dz', u'English': u'en', u'Esperanto': u'eo', u'Estonian': u'et', u'Faroese': u'fo', u'Fijian': u'fj', u'Finnish': u'fi', u'French': u'fr', u'Frisian': u'fy', u'Friulian': u'fur', u'Gaelic': u'gd', u'Galician': u'gl', u'Georgian': u'ka', u'German': u'de', u'Greek': u'el', u'Guarani': u'gn', u'Gujarati': u'gu', u'Hausa': u'ha', u'Hebrew': u'he', u'Herero': u'hz', u'Hindi': u'hi', u'Hiri Motu': u'ho', u'Hungarian': u'hu', u'Icelandic': u'is', u'Indonesian': u'id', u'Interlingua': u'ia', u'Interlingue': u'ie', u'Inuktitut': u'iu', u'Inupiaq': u'ik', u'Irish': u'ga', u'Italian': u'it', u'Japanese': u'ja', u'Javanese': u'jw', u'Kalaallisut': u'kl', u'Kannada': u'kn', u'Kashmiri': u'ks', u'Kazakh': u'kk', u'Khmer': u'km', u'Kikuyu': u'ki', u'Kinyarwanda': u'rw', u'Komi': u'kv', u'Korean': u'ko', u'Kuanyama': u'kj', u'Kurdish': u'ku', u'Kyrgyz': u'ky', u'Lao': u'lo', u'Latin': u'la', u'Latvian': u'lv', u'Letzeburgesch': u'lb', u'Lingala': u'ln', u'Lithuanian': u'lt', u'Macedonian': u'mk', u'Malagasy': u'mg', u'Malay': u'ms', u'Malayalam': u'ml', u'Maltese': u'mt', u'Maori': u'mi', u'Marathi': u'mr', u'Marshall': u'mh', u'Moldavian': u'mo', u'Mongolian': u'mn', u'Nauru': u'na', u'Navajo': u'nv', u'Ndebele, South': u'nr', u'Ndonga': u'ng', u'Nepali': u'ne', u'Northern Sami': u'se', u'Norwegian Bokmal': u'nb', u'Norwegian Nynorsk': u'nn', u'Occitan': u'oc', u'Oriya': u'or', u'Ossetian; Ossetic': u'os', u'Pali': u'pi', u'Panjabi': u'pa', u'Pashto, Pushto': u'ps', u'Persian': u'fa', u'Polish': u'pl', u'Portuguese': u'pt', u'Quechua': u'qu', u'Rhaeto-Romance': u'rm', u'Romanian': u'ro', u'Rundi': u'rn', u'Russian': u'ru', u'Samoan': u'sm', u'Sangro': u'sg', u'Sanskrit': u'sa', u'Sardinian': u'sc', u'Serbian': u'sr', u'Serbo-Croatian': u'sh', u'Sesotho': u'st', u'Setswana': u'tn', u'Shona': u'sn', u'Sindhi': u'sd', u'Sinhalese': u'si', u'Siswati': u'ss', u'Slovak': u'sk', u'Slovenian': u'sl', u'Somali': u'so', u'Spanish': u'es', u'Sundanese': u'su', u'Swahili': u'sw', u'Swedish': u'sv', u'Tagalog': u'tl', u'Tahitian': u'ty', u'Tajik': u'tg', u'Tamil': u'ta', u'Tatar': u'tt', u'Telugu': u'te', u'Thai': u'th', u'Tibetan': u'bo', u'Tigrinya': u'ti', u'Tonga': u'to', u'Tsonga': u'ts', u'Turkish': u'tr', u'Turkmen': u'tk', u'Twi': u'tw', u'Uighur': u'ug', u'Ukrainian': u'uk', u'Urdu': u'ur', u'Uzbek': u'uz', u'Vietnamese': u'vi', u'Volapuk': u'vo', u'Walloon': u'wa', u'Welsh': u'cy', u'Wolof': u'wo', u'Xhosa': u'xh', u'Yiddish': u'yi', u'Yoruba': u'yo', u'Zhuang': u'za', u'Zulu': u'zu'}

Reversed lang_codes

si

This module represents the Sinhala language.

class translate.lang.si.si

This class represents Sinhala.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

st

This module represents the Southern Sotho language.

class translate.lang.st.st

This class represents Southern Sotho.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

sv

This module represents the the Swedish language.

class translate.lang.sv.sv

This class represents Swedish.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ta

This module represents the Tamil language.

class translate.lang.ta.ta

This class represents Tamil.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

team

Module to guess the language ISO code based on the ‘Language-Team’ entry in the header of a Gettext PO file.

translate.lang.team.LANG_TEAM_CONTACT_SNIPPETS = {u'af': (u'i18n@af.org.za', u'Petri Jooste'), u'am': (u'@geez.org',), u'ar': (u'arabeyes.org', u'Arabeyes'), u'as': (u'assam@mm.assam-glug.org',), u'ast': (u'@softastur.org', u'launchpad.net/~ubuntu-l10n-ast', u'softast-xeneral@lists.sourceforge.net', u'Softastur'), u'az': (u'linuxaz@azerimal.net', u'gnome@azitt.com', u'gnome@az\u0259tt.com'), u'az_IR': (u'az-ir@lists.sharif.edu',), u'be': (u'i18n@mova.org', u'i18n@tut.by', u'mozilla_byx@poczta.fm'), u'be@latin': (u'translation-team-be-latin@lists', u'be-latin.open-tran.eu'), u'bg': (u'dict@fsa-bg.org', u'dict@linux.zonebg.com'), u'bn': (u'gnome-translation@bengalinux.org', u'core@bengalinux.org', u'ankur-bd-l10n@googlegroups.com', u'redhat-translation@bengalinux.org'), u'bn_IN': (u'anubad@lists.ankur.org.in',), u'br': (u'drouizig@drouizig.org', u'brenux@free.fr', u'tradgnome@softcatala.net', u'fedora@softcatala.org'), u'bs': (u'lokal@linux.org.ba', u'lokal@lugbih.org'), u'ca': (u'@softcatala.org',), u'crh': (u'tilde-birlik-tercime@lists.sourceforge.net',), u'cs': (u'fedora-cs-list@redhat.com', u'cs-users@lists.fedoraproject.org', u'debian-l10n-czech@lists.debian.org', u'kde-czech-apps@lists.sourceforge.net', u'kde-czech-apps@lists.sf.net', u'translations.cs@gnupg.cz'), u'cy': (u'gnome-cy@lists.linux.org.uk', u'gnome-cy@pengwyn.linux.org.uk', u'gnome-cy@www.linux.org', u'gnome-cy@www.linux.org.uk', u'cy@pengwyn.linux.org.uk'), u'da': (u'dansk@dansk-gruppen.dk', u'dansk@klid.dk', u'sslug-locale@sslug.dk'), u'de': (u'gnome-de@gnome.org', u'debian-l10n-german@lists.debian.org'), u'dz': (u'pgeyleg@dit.gov.bt', u'pgyeleg@dit.gov.bt'), u'el': (u'debian-l10n-greek@lists.debian.org', u'i18ngr@lists.hellug.gr', u'i18n@hellug.gr', u'nls@tux.hellug.gr', u'team@gnome.gr', u'team@lists.gnome.gr', u'users@el.openoffice.org'), u'en@shaw': (u'ubuntu-l10n-en-shaw@launchpad.net', u'ubuntu-l10n-en-shaw@lists.launchpad.net'), u'en_AU': (u'trans@six-by-nine.com.au',), u'en_CA': (u'adamw@gnome.org', u'adamw@freebsd.org'), u'en_GB': (u'kde-en-gb@kde.me.uk',), u'eo': (u'eo-tradukado@lists.tuxfamily.org', u'debian-l10n-esperanto@lists.debian.org', u'ubuntu-l10n-eo@lists.launchpad.net', u'eo-tradukado.tuxfamily.org'), u'es': (u'pgsql-es-ayuda@postgresql.org', u'debian-l10n-spanish@lists.debian.org', u'gnome-es@gnome.org', u'traductores@es.gnome.org'), u'et': (u'gnome-et@linux.ee', u'kde-et@linux.ee', u'linux-ee@lists.eenet.ee', u'linux-et@lists.eenet.ee', u'et-gnome@linux.ee', u'linux-ee@eenet.ee'), u'eu': (u'debian-l10n-basque@lists.debian.org', u'debian-l10n-eu@lists.debian.org', u'itzulpena@euskalgnu.org', u'gnome@euskalgnu.org', u'librezale@librezale.org', u'linux-eu@chanae.alphanet.ch'), u'fa': (u'farsi@lists.sharif.edu', u'Farsiweb.info'), u'fi': (u'debian-l10n-finnish@lists.debian.org', u'gnome-fi-laatu@lists.sourceforge.net', u'laatu@lokalisointi.org', u'lokalisointi-laatu@linux-aktivaattori.org', u'laatu@gnome.fi', u'yast-trans-fi@kotoistaminen.novell.fi'), u'fr': (u'debian-l10n-french@lists.debian.org', u'gnomefr@traduc.org', u'kde-francophone@kde.org', u'traduc@traduc.org', u'pgsql-fr-generale@postgresql.org', u'rpm-fr@livna.org'), u'ga': (u'gaeilge-gnulinux@lists.sourceforge.net', u'gaeilge-a@listserv.heanet.ie'), u'gl': (u'trasno@ceu.fi.udc.es', u'gnome@g11n.net', u'gpul-traduccion@ceu.fi.udc.es', u'proxecto@trasno.net', u'trasno@gpul.org'), u'gu': (u'indianoss-gujarati@lists.sourceforge.net',), u'he': (u'debian-hebrew-common@lists.alioth.debian.org', u'kde-il@yahoogroups.com', u'fedora-he-list@redhat.com', u'mdk-hebrew@iglu.org.il'), u'hi': (u'indlinux-hindi-gnome@lists.sourceforge.net', u'indlinux-hindi@lists.sourceforge.net'), u'hr': (u'translator-shop.org', u'lokalizacija@linux.hr'), u'hu': (u'debian-l10n-hungarian@lists.debian.org', u'gnome@fsf.hu', u'gnome@gnome.hu', u'magyar@lists.linux.hu'), u'id': (u'@id.gnome.org', u'@gnome.linux.or.id', u'mdk-id@yahoogroups.com', u'linux.or.id', u'gnome@i15n.org'), u'io': (u'gnome-ido@lists.mterry.name',), u'is': (u'gnome@techattack.nu', u'kde-isl@mmedia.is', u'kde-isl@molar.is'), u'it': (u'debian-l10n-italian@lists.debian.org', u'traduzioni@itpug.org', u'fedora-trans-it@redhat.com', u'tp@lists.linux.it'), u'ja': (u'debian-doc@debian.or.jp', u'debian-japanese@lists.debian.org', u'gnome-translation@gnome.gr.jp', u'translation@gnome.gr.jp', u'jpug-doc@ml.postgresql.jp'), u'ka': (u'geognome@googlegroups.com', u'Ubuntu-Georgian-Translators@googlegroups.com'), u'kk': (u'kk_KZ@googlegroups.com',), u'km': (u'@khmeros.info',), u'kn': (u'debian-l10n-kannada@lists.debian.org',), u'ko': (u'gnome-kr-hackers@list.kldp.net', u'gnome-kr-hackers@lists.kldp.net', u'gnome-kr-translation@lists.kldp.net', u'pgsql-kr@postgresql.or.kr', u'hangul-hackers@lists.kldp.net', u'debian-l10n-korean@lists.debian.org', u'gnome-kr-translation@lists.sourceforge.net'), u'ks': (u'ks-gnome-trans-commits@lists.code.indlinux.net',), u'ku': (u'gnu-ku-wergerandin@lists.sourceforge.net',), u'ky': (u'i18n-team-ky-kyrgyz@lists.sourceforge.net', u'ky-li@mail.ru'), u'la': (u'gnome-latin-list@gnome.org',), u'li': (u'li@gnome.org',), u'lt': (u'gimp-lt@lists.akl.lt', u'gnome-lt@lists.akl.lt', u'gnome-lt@lists.gnome.org', u'komp_lt@konferencijos.lt'), u'lv': (u'lata-l10n@googlegroups.com', u'lata-i18n@groups.google.com', u'locale@laka.lv', u'll10nt@os.lv'), u'mai': (u'maithili.sf.net',), u'mg': (u'i18n-malagasy-gnome@gnome.org',), u'mi': (u'maori@nzlinux.org.nz',), u'mk': (u'gnomk-main@lists.sourceforge.net', u'lug@lists.linux.net.mk', u'mkde-l10n@lists.sourceforge.net', u'ossm-members@hedona.on.net.mk'), u'ml': (u'smc-discuss@googlegroups.com',), u'mn': (u'openmn-', u'openmn.org'), u'ms': (u'gabai-penyumbang@lists.sourceforge.net', u'gabai-penyumbang@lists.sf.net', u'kedidiemas@yahoogroups.com'), u'nb': (u'i18n-nb@lister.ping.uio.no',), u'nds': (u'nds-lowgerman@lists.sourceforge.net',), u'ne': (u'info@mpp.org.np',), u'nl': (u'debian-l10n-dutch@lists.debian.org', u'vertaling@nl.gnome.org', u'vertaling@vrijschrift.org', u'nl@vrijschrift.org', u'vertaling@nl.linux.org', u'vertaling@nl.li.org'), u'nn': (u'i18n-nn@lister.ping.uio.no',), u'nso': (u'sepedi@translate.org.za',), u'or': (u'oriya-group@lists.sarovar.org', u'oriya-it@googlegroups.com'), u'pa': (u'punjabi-l10n@users.sf.net', u'fedora-pa-list@redhat.com', u'punjabi-users@lists.sf.net', u'punjabi-l10n@lists.sourceforge.net', u'punlinux-i18n@lists.sourceforge.net'), u'pl': (u'gnomepl@aviary.pl', u'debian-l10n-polish@lists.debian.org', u'gnome-l10n@lists.aviary.pl', u'translators@gnomepl.org'), u'ps': (u'pathanisation@googelgroups.com',), u'pt': (u'fedora-trans-pt@redhat.org', u'gnome_pt@yahoogroups.com', u'traduz@debianpt.org', u'traduz@debian.pt'), u'pt_BR': (u'gnome-l10n-br@listas.cipsga.org.br', u'gnome-pt_br-list@gnome.org', u'fedora-docs-br@redhat.com', u'fedora-trans-pt-br@redhat.com', u'ldp-br@bazar.conectiva.com.br', u'pgbr-dev@postgresql.org.br', u'pgbr-dev@listas.postgresql.org.br', u'debian-l10n-portuguese@lists.debian.org'), u'ro': (u'fedora-ro@googlegroups.com', u'gnomero-list@lists.sourceforge.net', u'debian-l10n-romanian@lists.debian.org'), u'ru': (u'pgsql-rus@yahoogroups.com', u'debian-l10n-russian@lists.debian.org', u'gnupg-ru@gnupg.org'), u'sk': (u'sk-i18n@lists.linux.sk', u'kde-sk@linux.sk'), u'sl': (u'gnome-si@googlegroups.com',), u'sq': (u'gnome-albanian-perkthyesit@lists.sourceforge.net', u'debian-l10n-albanian@lists.debian.org'), u'sr': (u'@prevod.org', u'serbiangnome-lista@nongnu.org'), u'sv': (u'debian-l10n-swedish@lists.debian.org', u'tp-sv@listor.tp-sv.se'), u'ta': (u'gnome-tamil-translation@googlegroups.com', u'tamilinix@yahoogroups.com', u'Ubuntu-l10n-tam@lists.ubuntu.com', u'tamil-DI@yahoogroups.com'), u'te': (u'localisation@swecha.org', u'indlinux-telugu@lists.sourceforge.net'), u'th': (u'l10n@opentle.org', u'thai-l10n@googlegroup.com', u'thailang@buraphalinux.org', u'thai-l10n@googlegroups.com', u'l10n.opentle.org'), u'tk': (u'kakilikgroup@yahoo.com',), u'tl': (u'debian-tl@banwa.upm.edu.ph',), u'tr': (u'debian-l10n-turkish@lists.debian.org', u'gnome-turk@gnome.org', u'gnu-tr-u12a@lists.sourceforge.net', u'turkce@pardus.org.tr'), u'tt': (u'tatarish.l10n@gmail.com',), u'ug': (u'gnome-uighur@yahoogroups.com',), u'uk': (u'linux@linux.org.ua',), u'ur': (u'l10n@urduweb.org', u'urdu.scs.gift@gmail.com'), u've': (u'venda@translate.org.za',), u'vi': (u'gnomevi-list@lists.sourceforge.net', u'vi-VN@googlegroups.com'), u'wa': (u'linux-wa@',), u'xh': (u'xh-translate@ubuntu.com', u'xhosa@translate.org.za', u'xhosa@ubuntu.com'), u'zh_CN': (u'i18n-translation@lists.linux.net.cn', u'i18n-zh@googlegroups.com', u'translation-team-zh-cn@lists.sourceforge.net', u'i18n-zh@googlegroup.com'), u'zh_TW': (u'zh-l10n@lists.linux.org.tw', u'chinese-l10n@googlegroups.com', u'community@linuxhall.org', u'zh-l10n@linux.org.tw'), u'zu': (u'zulu@translate.org.za',)}

Language codes with snippets of contact information that can be used to uniquely identify the language

translate.lang.team.guess_language(team_string)

Gueses the language of a PO file based on the Language-Team entry

te

This module represents the Telugu language.

class translate.lang.te.te

This class represents Telugu.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

th

This module represents the Thai language.

class translate.lang.th.th

This class represents Thai.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ug

This module represents the Uyghur language.

class translate.lang.ug.ug

This class represents Uyghur.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

ur

This module represents the Urdu language.

class translate.lang.ur.ur

This class represents Urdu.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

vi

This module represents the Vietnamese language.

class translate.lang.vi.vi

This class represents Vietnamese.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod length_difference(length)

Returns an estimate to a likely change in length relative to an English string of length length.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Implement some extra features for quotation marks.

Known shortcomings:
  • % and $ are not touched yet for fear of variables
  • Double spaces might be introduced
classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.

zh

This module represents the Chinese language (Both tradisional and simplified).

class translate.lang.zh.zh

This class represents Chinese.

classmethod alter_length(text)

Converts the given string by adding or removing characters as an estimation of translation length (with English assumed as source language).

classmethod capsstart(text)

Determines whether the text starts with a capital letter.

classmethod character_iter(text)

Returns an iterator over the characters in text.

classmethod characters(text)

Returns a list of characters in text.

classmethod numbertranslate(text)

Converts the numbers in a string according to the rules of the language.

classmethod numstart(text)

Determines whether the text starts with a numeric value.

classmethod punctranslate(text)

Converts the punctuation in a string according to the rules of the language.

classmethod sentence_iter(text, strip=True)

Returns an iterator over the sentences in text.

classmethod sentences(text, strip=True)

Returns a list of sentences in text.

classmethod word_iter(text)

Returns an iterator over the words in text.

classmethod words(text)

Returns a list of words in text.