PythonQt.QtCore.QTranslator · declarations 001
Back to PythonQt.QtCore.QTranslator
destroyed
destroyed(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtCore.QTranslator.destroyed; argument details are not documented.
isEmpty
isEmpty() -> bool
X.isEmpty() -> bool
Supplemental documentation: Qt 5 reference:
[virtual] bool QTranslator::isEmpty() const
Returns true if this translator is empty, otherwise returns false. This function
works with stripped and unstripped translation files.
Upstream PySide2 reference signatures (binding differences may apply):
isEmpty(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qtranslator.html#isEmpty
load
load(locale: Any, filename: Any, prefix: Any, directory: str, suffix: Any) -> bool
X.load(locale, filename, prefix, directory, suffix) -> bool
Supplemental documentation: Qt 5 reference:
bool QTranslator::load(const QString \&filename, const QString \&directory \= QString(), const QString \&search_delimiters \= QString(), const QString \&suffix \= QString())
Loads filename + suffix (".qm" if the suffix is not specified), which may be an
absolute file name or relative to directory. Returns true if the translation is
successfully loaded; otherwise returns false.
If directory is not specified, the current directory is used (i.e., as currentPath()).
The previous contents of this translator object are discarded.
If the file name does not exist, other file names are tried in the following order:
- File name without suffix appended.
- File name with text after a character in search_delimiters stripped ("_." is the default for search_delimiters if it is an empty string) and suffix.
- File name stripped without suffix appended.
- File name stripped further, etc.
For example, an application running in the fr_CA locale (French-speaking Canada) might call load("foo.fr_ca", "/opt/foolib"). load() would then try to open the first existing readable file from this list:
/opt/foolib/foo.fr_ca.qm/opt/foolib/foo.fr_ca/opt/foolib/foo.fr.qm/opt/foolib/foo.fr/opt/foolib/foo.qm/opt/foolib/foo
Usually, it is better to use the QTranslator::load(const QLocale \&, const QString \&, const QString \&, const QString \&, const QString \&) function instead, because it uses QLocale::uiLanguages() and not simply the locale name, which refers to the formatting of dates and numbers and not necessarily the UI language.
bool QTranslator::load(const QLocale \&locale, const QString \&filename, const QString \&prefix \= QString(), const QString \&directory \= QString(), const QString \&suffix \= QString())
Loads filename + prefix + ui language
name + suffix (".qm" if
the suffix is not specified), which may be an absolute file name or relative to
directory. Returns true if the translation is successfully loaded; otherwise returns
false.
The previous contents of this translator object are discarded.
If the file name does not exist, other file names are tried in the following order:
- File name without suffix appended.
- File name with ui language part after a "_" character stripped and suffix.
- File name with ui language part stripped without suffix appended.
- File name with ui language part stripped further, etc.
For example, an application running in the locale with the following ui languages - "es", "fr-CA", "de" might call load(QLocale(), "foo", ".", "/opt/foolib", ".qm"). load() would replace '-' (dash) with '_' (underscore) in the ui language and then try to open the first existing readable file from this list:
/opt/foolib/foo.es.qm/opt/foolib/foo.es/opt/foolib/foo.fr_CA.qm/opt/foolib/foo.fr_CA/opt/foolib/foo.fr.qm/opt/foolib/foo.fr/opt/foolib/foo.de.qm/opt/foolib/foo.de/opt/foolib/foo.qm/opt/foolib/foo./opt/foolib/foo
On operating systems where file system is case sensitive, QTranslator also tries to load a lower-cased version of the locale name.
This function was introduced in Qt 4.8.
bool QTranslator::load(const uchar *data, int len, const QString \&directory \= QString())
This function overloads load().
Loads the QM file data data of length len into the translator.
The data is not copied. The caller must be able to guarantee that data will not be deleted or modified.
directory is only used to specify the base directory when loading the dependencies of a QM file. If the file does not have dependencies, this argument is ignored.
Upstream PySide2 reference signatures (binding differences may apply):
load(self, data: str, len: int, directory: str=...) -> bool
load(self, filename: str, directory: str=..., search_delimiters: str=..., suffix: str=...) -> bool
load(self, locale: PySide2.QtCore.QLocale, filename: str, prefix: str=..., directory: str=..., suffix: str=...) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qtranslator.html#load
objectNameChanged
objectNameChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtCore.QTranslator.objectNameChanged; argument details are not documented.
translate
translate(context: str, sourceText: str, disambiguation: Any, n: int) -> str
X.translate(context, sourceText, disambiguation, n) -> str
Supplemental documentation: Qt 5 reference:
[virtual] QString QTranslator::translate(const char *context, const char *sourceText, const char *disambiguation \= nullptr, int n \= -1) const
Returns the translation for the key (context, sourceText, disambiguation). If none is found, also tries (context, sourceText, ""). If that still fails, returns a null string.
Note: Incomplete translations may result in unexpected behavior: If no translation for (context, sourceText, "") is provided, the method might in this case actually return a translation for a different disambiguation.
If n is not -1, it is used to choose an appropriate form for the translation (e.g. "%n file found" vs. "%n files found").
If you need to programmatically insert translations into a QTranslator, this function can be reimplemented.
See also load().
Upstream PySide2 reference signatures (binding differences may apply):
translate(self, context: str, sourceText: str, disambiguation: typing.Optional[str]=..., n: int=...) -> str
Source: https://doc.qt.io/archives/qt-5.15/qtranslator.html#translate