KDE 4.5 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

LanguageTag Class Reference

from PyKDE4.soprano import *

Namespace: Soprano

Detailed Description

\class LanguageTag languagetag.h Soprano/LanguageTag

A LanguageTag represents a language according to RFC 3066 and RFC 4646.

Author:
Greg Beauchesne <greg_b@vision-play.com>

Since:
2.3


Enumerations

LookupFlag { LookupFlagNone, LookupFlagNoFallback }
MatchFilter { MatchFilterBasic, MatchFilterExtended }

Methods

 __init__ (self)
 __init__ (self, Soprano.LanguageTag other)
 __init__ (self, QString tag)
 __init__ (self, QLatin1String tag)
 __init__ (self, QString tag)
 __init__ (self, QLocale locale)
 __init__ (self, QLocale.Language lang, QLocale.Country country=QLocale.AnyCountry)
bool isEmpty (self)
bool isValid (self)
bool matches (self, Soprano.LanguageTag range, Soprano.LanguageTag.MatchFilter scheme=Soprano.LanguageTag.MatchFilterBasic)
bool operator != (self, Soprano.LanguageTag other)
bool operator < (self, Soprano.LanguageTag other)
bool operator <= (self, Soprano.LanguageTag other)
bool operator == (self, Soprano.LanguageTag other)
bool operator > (self, Soprano.LanguageTag other)
bool operator >= (self, Soprano.LanguageTag other)
QStringList subTags (self)
QLocale toLocale (self)
QString toPrettyString (self)
QString toString (self)

Static Methods

int lookup ([Soprano.LanguageTag] choices, [Soprano.LanguageTag] priority, Soprano.LanguageTag.LookupFlags flags=Soprano.LanguageTag.LookupFlagNone, Soprano.LanguageTag.MatchFilter scheme=Soprano.LanguageTag.MatchFilterBasic)
int lookup ([Soprano.LanguageTag] choices, Soprano.LanguageTag priority, Soprano.LanguageTag.LookupFlags flags=Soprano.LanguageTag.LookupFlagNone, Soprano.LanguageTag.MatchFilter scheme=Soprano.LanguageTag.MatchFilterBasic)

Method Documentation

__init__ (   self )

Default constructor. Creates an empty language tag.

__init__ (  self,
Soprano.LanguageTag  other
)

Copy constructor.

Parameters:
other  The language tag from which to copy

__init__ (  self,
QString  tag
)

Creates a language tag.

Parameters:
tag  The language tag string

__init__ (  self,
QLatin1String  tag
)

Creates a language tag.

Parameters:
tag  The language tag string

__init__ (  self,
QString  tag
)

Creates a language tag.

Parameters:
tag  The language tag string

__init__ (  self,
QLocale  locale
)

Creates a language tag from a QLocale. If the language is QLocale.C, then an empty LanguageTag is produced.

Parameters:
locale  the locale

__init__ (  self,
QLocale.Language  lang,
QLocale.Country  country=QLocale.AnyCountry
)

Creates a language tag from a language and country. If lang is QLocale.C, then an empty LanguageTag is produced.

Parameters:
lang  the language code

Parameters:
country  the country code

bool isEmpty (   self )

Returns:
true if this language tag is empty.

bool isValid (   self )

Determines if this language tag is valid. A valid language tag is divided into subtags that are divided by "-". The tag must adhere the following rules: - Each subtag is composed only of characters in the ASCII range [a-zA-Z0-9] (letters and digits), with the exception of the first subtag, which must be composed of letters only - No subtags are empty - No subtags are longer than 8 characters - Single-character subtags cannot end the tag unless after a private use ("x") subtag (e.g. "en-x-i" and "en-x-abcd-i" are legal; "en-x", "en-i", and "en-i-abcd-g" are illegal)

Returns:
true if this language tag is valid

bool matches (  self,
Soprano.LanguageTag  range,
Soprano.LanguageTag.MatchFilter  scheme=Soprano.LanguageTag.MatchFilterBasic
)

Match this language tag against range using the specified filtering scheme.

Parameters:
range  the range against which to match

Parameters:
scheme  the filtering scheme to use

Returns:
true if this tag matches pattern, false if not.

bool operator != (  self,
Soprano.LanguageTag  other
)

Comparison operator. Language tag comparisons are case-insensitive.

Returns:
true if this tag and other differ.

bool operator < (  self,
Soprano.LanguageTag  other
)

Comparison operator.

Returns:
true if this tag is lexically less than other.

bool operator <= (  self,
Soprano.LanguageTag  other
)

Comparison operator.

Returns:
true if this tag is lexically less than or equal to other.

bool operator == (  self,
Soprano.LanguageTag  other
)

Comparison operator. Language tag comparisons are case-insensitive.

Returns:
true if this tag and other are equal.

bool operator > (  self,
Soprano.LanguageTag  other
)

Comparison operator.

Returns:
true if this tag is lexically greater than other.

bool operator >= (  self,
Soprano.LanguageTag  other
)

Comparison operator.

Returns:
true if this tag is lexically greater than or equal to other.

QStringList subTags (   self )

Returns:
the subtag parts that make up this language tag

QLocale toLocale (   self )

Converts this LanguageTag to a locale, using the primary language tag and first two-letter language subtag, if any. If the conversion could not be performed, then the "C" QLocale is returned.

Returns:
the converted locale

Note:
QLocale restricts the countries that can be paired with a particular language. If the language-country pair in this tag is not in the QLocale database, or if this language tag does not contain country information, then the most appropriate country will be used for the locale. For example, "de-US" (German as spoken in the United States) is not a valid combination, and the country would be changed to Germany.

QString toPrettyString (   self )

Converts this LanguageTag to a string formatted according to the case rules in RFC 4647 section 4.4 (page 44).

Returns:
the pretty string representation of this LanguageTag

QString toString (   self )

Converts this LanguageTag to a string.

Returns:
the string representation of this LanguageTag


Static Method Documentation

int lookup ( [Soprano.LanguageTag]  choices,
[Soprano.LanguageTag]  priority,
Soprano.LanguageTag.LookupFlags  flags=Soprano.LanguageTag.LookupFlagNone,
Soprano.LanguageTag.MatchFilter  scheme=Soprano.LanguageTag.MatchFilterBasic
)

A convenience method to select a language tag based on a single search pattern.

Parameters:
choices  the list of available language choices

Parameters:
priority  the language range against which to match

Parameters:
flags  flags for the lookup operation

Parameters:
scheme  the matching scheme to use. RFC 4647 specifies that basic (\link LanguageTag.MatchFilterBasic MatchFilterBasic\endlink) processing should be used.

Returns:
the index of the matching language tag in choices, or < 0 if no tag matched.

\sa lookup(const QList<LanguageTag> &, const QList<LanguageTag> &, LookupFlags, MatchFilter)

int lookup ( [Soprano.LanguageTag]  choices,
Soprano.LanguageTag  priority,
Soprano.LanguageTag.LookupFlags  flags=Soprano.LanguageTag.LookupFlagNone,
Soprano.LanguageTag.MatchFilter  scheme=Soprano.LanguageTag.MatchFilterBasic
)

A convenience method to select a language tag based on a single search pattern.

Parameters:
choices  the list of available language choices

Parameters:
priority  the language range against which to match

Parameters:
flags  flags for the lookup operation

Parameters:
scheme  the matching scheme to use. RFC 4647 specifies that basic (\link LanguageTag.MatchFilterBasic MatchFilterBasic\endlink) processing should be used.

Returns:
the index of the matching language tag in choices, or < 0 if no tag matched.

\sa lookup(const QList<LanguageTag> &, const QList<LanguageTag> &, LookupFlags, MatchFilter)


Enumeration Documentation

LookupFlag

Flags for performing LanguageTag lookups.

\sa lookup()

Enumerator:
LookupFlagNone = 0
LookupFlagNoFallback = 1

MatchFilter
Enumerator:
MatchFilterBasic = 0
MatchFilterExtended = 1

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal