Package translate :: Package lang :: Module data |
[hide private]
[frames] | no frames]

# Module data

source code

This module stores information and functionality that relates to plurals.

Functions | [hide private]
simplercode(code) This attempts to simplify the given language code by ignoring country codes, for example. | source code
languagematch(languagecode, otherlanguagecode) matches a languagecode to another, ignoring regions in the second | source code
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. | source code
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. | source code
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. | source code
normalize(string, normal_form=`'``NFC``'`) Return a unicode string in its normalized form | source code
Unicode |
forceunicode(string) Ensures that the string is in unicode. | source code
normalized_unicode(string) Forces the string to unicode and does normalization. | source code
normalize_code(code) | source code
simplify_to_common(language_code, languages=`{``'``af``'``:` `(``'``Afrikaans``'``,` 2`,` `'``(n != 1)``'``)``,` `'``ak``'``:` `(``'``Akan``'``,` 2`,` `'``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 | source code

Variables | [hide private]
| languages = ``{``'``af``'``:` `(``'``Afrikaans``'``,` 2`,` `'``(n != 1)``'``)``,` `'``ak``'``:` `(``'``Akan``'``...`` Dictionary of language data.
| expansion_factors = ``{``'``af``'``:` 0.1`,` `'``ar``'``:` -0.09`,` `'``es``'``:` 0.21`,` `'``fr``'``:``...`` Source to target string length expansion factors.
| iso639 = ``{``}`` ISO 639 language codes
| iso3166 = ``{``}`` ISO 3166 country codes
| langcode_re = `re.compile(r'^`[`a`-`z`]``{2,3}``(``[`_-`]``[`A`-`Z`]``{2,3}``|``)``(`@`[`a`-`zA`...``
| variant_re = `re.compile(r'^`[`_-`]``[`A`-`Z`]``{2,3}``(`@`[`a`-`zA`-`Z0`-`9`]``+``|``)`$')`
| dialect_name_re = `re.compile(r'`(`.`+``)`\s\(`(``[^`\)`]``+``)`\)$')`

Imports: unicodedata, StringElem, gettext, locale, re, os

Function Details | [hide private]

### simplercode(code) | source code
This attempts to simplify the given language code by ignoring country codes, for example. See Also: http://www.rfc-editor.org/rfc/bcp/bcp47.txt http://www.rfc-editor.org/rfc/rfc4646.txt http://www.rfc-editor.org/rfc/rfc4647.txt http://www.w3.org/International/articles/language-tags/

### normalize(string, normal_form=`'``NFC``'`) | source code
Return a unicode string in its normalized form Parameters: `string` - The string to be normalized `normal_form` - NFC (default), NFD, NFCK, NFDK Returns: Normalized string

### forceunicode(string) | source code
Ensures that the string is in unicode. Parameters: `string` (Unicode, String) - A text string Returns: Unicode String converted to Unicode and normalized as needed.

Variables Details | [hide private]

  ### languages 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, nplurals, plural equation) Value:
      {'af': ('Afrikaans', 2, '(n != 1)'),
       'ak': ('Akan', 2, 'n > 1'),
       'am': ('Amharic', 2, 'n > 1'),
       'ar': ('Arabic',
              6,
              'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 :
      n%100>=11 && n%100<=99 ? 4 : 5'),
       'arn': ('Mapudungun; Mapuche', 2, 'n > 1'),
      ...

  ### expansion_factors Source to target string length expansion factors. Value:
      {'af': 0.1, 'ar': -0.09, 'es': 0.21, 'fr': 0.28, 'it': 0.2}

  ### langcode_re Value:
      re.compile(r'^[a-z]{2,3}([_-][A-Z]{2,3}|)(@[a-zA-Z0-9]+|)$')