LangTag.Tag

Fields

None

Methods

class

convert_from_locale (error)

class

convert_from_locale_string (locale, error)

class

new ()

canonicalize (error)

canonicalize_in_extlang_form (error)

clear ()

compare (v2)

convert_to_locale (error)

copy ()

dump ()

get_extension ()

get_extlang ()

get_grandfathered ()

get_language ()

get_privateuse ()

get_region ()

get_script ()

get_string ()

get_string_with_filter (filter)

get_variants ()

lookup (pattern, error)

match (v2, error)

parse (tag_string, error)

parse_with_extra_token (tag_string, error)

ref ()

transform (error)

truncate (error)

unref ()

Details

class LangTag.Tag

All the fields in the LangTag.Tag structure are private to the LangTag.Tag implementation.

classmethod convert_from_locale(error)
Parameters:

error (LangTag.Error or None) – a LangTag.Error.

Returns:

a LangTag.Tag, None if fails.

Return type:

LangTag.Tag

Convert current locale to the language tag.

classmethod convert_from_locale_string(locale, error)
Parameters:
Returns:

a LangTag.Tag, None if fails.

Return type:

LangTag.Tag

Convert locale to the language tag.

classmethod new()
Returns:

a new instance of LangTag.Tag.

Return type:

LangTag.Tag

Create a new instance of LangTag.Tag.

canonicalize(error)
Parameters:

error (LangTag.Error or None) – a LangTag.Error or None.

Returns:

a language tag string.

Return type:

str

Canonicalize the language tag according to various information of subtags.

canonicalize_in_extlang_form(error)
Parameters:

error (LangTag.Error or None) – a LangTag.Error or None.

Returns:

a language tag string.

Return type:

str

Canonicalize the language tag in the extlang form according to various information of subtags.

clear()

(Re-)Initialize all of the subtag information stored in self.

compare(v2)
Parameters:

v2 (LangTag.Tag) – a LangTag.Tag.

Returns:

True if it’s the same, otherwise False.

Return type:

int

Compare if self and v2 is the same object or not.

convert_to_locale(error)
Parameters:

error (LangTag.Error or None) – a LangTag.Error or None.

Returns:

a locale string or None if fails

Return type:

str

Convert the language tag to the locale.

copy()
Returns:

a new instance of LangTag.Tag or None if fails.

Return type:

LangTag.Tag

Create a copy instance of self.

dump()

Dumps the container information to the standard output.

get_extension()
Returns:

a LangTag.Extension.

Return type:

LangTag.Extension

Obtain a LangTag.Extension instance in self.

get_extlang()
Returns:

a LangTag.Extlang.

Return type:

LangTag.Extlang

Obtain a LangTag.Extlang instance in self.

get_grandfathered()
Returns:

a LangTag.Grandfathered.

Return type:

LangTag.Grandfathered

Obtain a LangTag.Grandfathered instance in self.

get_language()
Returns:

a LangTag.Lang.

Return type:

LangTag.Lang

Obtain a LangTag.Lang instance in self.

get_privateuse()
Returns:

a LangTag.String.

Return type:

LangTag.String

Obtain a LangTag.String instance in self.

get_region()
Returns:

a LangTag.Region.

Return type:

LangTag.Region

Obtain a LangTag.Region instance in self.

get_script()
Returns:

a LangTag.Script.

Return type:

LangTag.Script

Obtain a LangTag.Script instance in self.

get_string()
Returns:

a language tag string.

Return type:

str

Obtains a language tag in string.

get_string_with_filter(filter)
Parameters:

filter (int) – a binary count sequence of #lt_tag_filter_t.

Returns:

a language tag string.

Return type:

str

Obtains a language tag in string against filter.

get_variants()
Returns:

a LangTag.List containing LangTag.Variant.

Return type:

LangTag.List

Obtain a list of LangTag.Variant instance in self.

lookup(pattern, error)
Parameters:
Returns:

a language tag string if any matches, otherwise None.

Return type:

str

Lookup the language tag that self meets with pattern. Any of subtags in pattern is allowed to use the wildcard according to the syntax in RFC 4647.

match(v2, error)
Parameters:
Returns:

True if it matches, otherwise False.

Return type:

int

Try matching of self and v2. any of subtags in v2 is allowed to use the wildcard according to the syntax in RFC 4647.

parse(tag_string, error)
Parameters:
Returns:

True if it’s successfully completed, otherwise False.

Return type:

int

Parse tag_string and create appropriate instances for subtags.

parse_with_extra_token(tag_string, error)
Parameters:
Returns:

True if it’s successfully completed, otherwise False.

Return type:

int

Continue to parse a language tag with tag_string. please use LangTag.Tag.parse() at first.

ref()
Returns:

the same self object.

Return type:

LangTag.Tag

Increases the reference count of self.

transform(error)
Parameters:

error (LangTag.Error) –

Return type:

str

truncate(error)
Parameters:

error (LangTag.Error) –

Return type:

int

unref()

Decreases the reference count of self. when its reference count drops to 0, the object is finalized (i.e. its memory is freed).