Loads localized versions of template files. More...
#include <templateloader.h>
Public Member Functions | |
TemplateLoader (QSettings *settings, QObject *parent=0) | |
Constructor. | |
virtual | ~TemplateLoader () |
Destructor. | |
Template | getTemplate (QString templateName, QString locales=QString()) |
Get a template for a given locale. | |
Protected Member Functions | |
virtual QString | tryFile (QString localizedName) |
Try to get a file from cache or filesystem. | |
Protected Attributes | |
QString | templatePath |
Directory where the templates are searched. | |
QString | fileNameSuffix |
Suffix to the filenames. | |
QTextCodec * | textCodec |
Codec for decoding the files. | |
QMutex | mutex |
Used to synchronize threads. |
Loads localized versions of template files.
If the caller requests a file with the name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", then files are searched in the following order:
The following settings are required:
path=. suffix=.tpl encoding=UTF-8
The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory.
Definition at line 37 of file templateloader.h.
TemplateLoader::TemplateLoader | ( | QSettings * | settings, | |
QObject * | parent = 0 | |||
) |
Constructor.
settings | configurations settings | |
parent | parent object |
Definition at line 13 of file templateloader.cpp.
Template TemplateLoader::getTemplate | ( | QString | templateName, | |
QString | locales = QString() | |||
) |
Get a template for a given locale.
This method is thread safe.
templateName | base name of the template file, without suffix and without locale | |
locales | Requested locale(s), e.g. "de_DE, en_EN". Strings in the format of the HTTP header Accept-Locale may be used. Badly formatted parts in the string are silently ignored. |
Definition at line 59 of file templateloader.cpp.
QString TemplateLoader::tryFile | ( | QString | localizedName | ) | [protected, virtual] |
Try to get a file from cache or filesystem.
localizedName | Name of the template with locale to find |
Reimplemented in TemplateCache.
Definition at line 40 of file templateloader.cpp.