KDE 4.7 PyKDE API Reference

- KDE's Python API

# KTranslatable Class Reference

`from PyKDE4.knewstuff import *`

Namespace: KNS

## Detailed Description

String class with multiple localized representations.

KTranslatable is used as a drop-in replacement for QString whenever human-visible information needs to be stored and this information depends on the current language.

Author:
  Josef Spillner (spillner@kde.org)

## Methods
| __init__ (self)
| __init__ (self, QString string)
| __init__ (self, KNS.KTranslatable a0)
| addString (self, QString lang, QString string)
bool | isEmpty (self)
bool | isTranslated (self)
QString | language (self)
QStringList | languages (self)
QString | representation (self)
{QString:QString} | stringmap (self)
QStringList | strings (self)
QString | translated (self, QString lang)

## Method Documentation

__init__ | ( |  | self ) |

Constructor.

__init__ | ( | self, |
|  | QString | string
| ) |  |  |

Constructor. Initializes the contents with a single string.

__init__ | ( | self, |
|  | KNS.KTranslatable | a0
| ) |  |  |

Constructor.

addString | ( | self, |
|  | QString | lang,
|  | QString | string
| ) |  |  |

Adds a string to the contents of this object.

Parameters:

  | lang | Language code in 'xx_XX' format
  | string | The string to be stored for this language

bool isEmpty | ( |  | self ) |

Returns whether no content is set yet

Returns:
  true if no content has been added yet, false otherwise

bool isTranslated | ( |  | self ) |

Returns whether the content provides alternative (translated) strings.

Returns:
  true if contents are translated, false otherwise

QString language | ( |  | self ) |

Returns the language which most likely resembles the current language.

Returns:
  Current language, or one close to it

QStringList languages | ( |  | self ) |

Returns the list of all languages for which strings are stored.

Returns:
  All languages the content is available for

QString representation | ( |  | self ) |

Returns the string which matches most closely the current language.

Returns:
  Contents for the current language

{QString:QString} stringmap | ( |  | self ) |

Returns a map of all languages and their strings.

Returns:
  Map of all languages as keys and all strings as values

QStringList strings | ( |  | self ) |

Returns the list of all strings stored for all languages.

Returns:
  All strings stored in this object

QString translated | ( | self, |
|  | QString | lang
| ) |  |  |

Returns the string which matches most closely the specified language.

Parameters:

  | lang | Language the contents should appear in, in 'xx_XX' format

Returns:
  Contents for the specified language