locale stuff

This commit is contained in:
wmayer
2012-04-30 18:30:29 +02:00
parent 95cf62b990
commit da1a42e2ee
3 changed files with 22 additions and 23 deletions

View File

@@ -174,17 +174,17 @@ TStringList Translator::supportedLanguages() const
return languages;
}
TStringList Translator::supportedLocales() const
TStringMap Translator::supportedLocales() const
{
// List all .qm files
TStringList languages;
TStringMap languages;
QDir dir(QLatin1String(":/translations"));
for (std::map<std::string,std::string>::const_iterator it = d->mapLanguageTopLevelDomain.begin();
it != d->mapLanguageTopLevelDomain.end(); ++it) {
QString filter = QString::fromAscii("*_%1.qm").arg(QLatin1String(it->second.c_str()));
QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name);
if (!fileNames.isEmpty())
languages.push_back(it->second);
languages[it->first] = it->second;
}
return languages;

View File

@@ -34,6 +34,7 @@ class QDir;
namespace Gui {
typedef std::list<std::string> TStringList;
typedef std::map<std::string, std::string> TStringMap;
/**
* The Translator class uses Qt's QTranslator objects to change the language of the application
@@ -65,8 +66,8 @@ public:
std::string activeLanguage() const;
/** Returns a list of supported languages. */
TStringList supportedLanguages() const;
/** Returns a list of supported locales. */
TStringList supportedLocales() const;
/** Returns a map of supported languages/locales. */
TStringMap supportedLocales() const;
/** Adds a path where localization files can be found */
void addPath(const QString& path);