pango.Language

pango.Language — an object that represents a language tag.

Synopsis

class pango.Language(gobject.GBoxed):
    pango.Language(language)
def matches(range_list)
def to_string()
Functions

    def pango.pango_language_from_string(language)
def pango.pango_language_matches(language, range_list)

Description

A pango.Language object represents a language tag meeting the RFC-3066 standard. The pango.Language can be retrieved from a pango.Context by using the pango.Context.get_language() method or created using the pango.Language() constructor. Example RFC-3066 language tags include: "en-us", "fr", and "sgn-us-ma".

Constructor

    pango.Language(language>)
language :a string representing a language tag
Returns :a new pango.Language object

Note

This constructor is available in PyGTK 2.4 and above.

Creates a new pango.Language object from the RFC-3066 language tag specified by language. This constructor first canonicalizes the string in language by converting it to lowercase, mapping '_' to '-', and stripping all characters other than letters and '-'.

Methods

pango.Language.matches

    def matches(range_list)
>range_list :a list of language ranges, separated by ';' characters.
Returns :TRUE if a match was found.

Note

This method is available in PyGTK 2.4 and above.

The matches() method returns TRUE if the language matches one of the language ranges in the list specified by range_list.A language tag is considered to match a range in the list if

  • the range is '*'
  • the range is exactly the same as the tag, or
  • the range is a prefix of the tag, and the character after the matching portion of the tag is '-'

each range must either be '*', or a canonicalized RFC-3066 language range (see the pango.Language() constructor for more information).

pango.Language.matches

    def to_string()
Returns :the string representation of the language tag

Note

This method is available in PyGTK 2.4 and above.

The to_string() method returns a string representation of the canonicalized language tag. See the pango.Language() constructor for more information.

Functions

pango.pango_language_from_string

    def pango.pango_language_from_string(language)
language :a string representing a language tag
Returns :a new pango.Language object

Note

This function is deprecated in PyGTK 2.4 and above. Use the pango.Language() constructor instead.

The pango.pango_language_from_string() function takes a RFC-3066 format language tag as a string (specified by language) and converts it to a pango.Language object. This function first canonicalizes the string by converting it to lowercase, mapping '_' to '-', and stripping all characters other than letters and '-'.

pango.pango_language_matches

    def pango.pango_language_matches()
language : a language tag (see the pango.pango_language_from_string() function), None is allowed and matches nothing but '*'
range_list : a list of language ranges, separated by ';' characters. each element must either be '*', or a RFC 3066 language range canonicalized as by the pango.pango_language_from_string() function.
Returns :TRUE if a match was found.

Note

This function is deprecated in PyGTK 2.4 and above. Use the matches() method instead.

The pango.pango_language_matches() function checks if a language tag matches one of the elements in a list of language ranges. A language tag is considered to match a range in the list if the range is '*', the range is exactly the tag, or the range is a prefix of the tag, and the character after the tag is '-'.