From 466a93203ef2cccbf91316e28661aaa29f8a506e Mon Sep 17 00:00:00 2001 From: Orcan Ogetbil Date: Mon, 13 Dec 2010 11:31:53 +0000 Subject: List the available locales in the --help output --- muse2/ChangeLog | 2 ++ muse2/muse/app.cpp | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 5cf5834c..af680887 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,5 @@ +13.12.2010: + - List the available locales in the --help output. (Orcan) 12.12.2010: - Integrated the translation system into cmake. Added a -DUPDATE_TRANSLATIONS flag to cmake which will update the .ts files in the source tree with the newest strings. I used this to diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 2d19f2cc..e2748724 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -3589,6 +3589,33 @@ class MuseApplication : public QApplication { }; +//--------------------------------------------------------- +// localeList +//--------------------------------------------------------- + +static QString localeList() + { + // Find out what translations are available: + QStringList deliveredLocaleListFiltered; + QString distLocale = QString(INSTPREFIX) + "/" + SHAREINSTPREFIX + "/" + + INSTALL_NAME + "/locale"; + QFileInfo distLocaleFi(distLocale); + if (distLocaleFi.isDir()) { + QDir dir = QDir(distLocale); + QStringList deliveredLocaleList = dir.entryList(); + for(QStringList::iterator it = deliveredLocaleList.begin(); it != deliveredLocaleList.end(); ++it) { + QString item = *it; + if (item.endsWith(".qm")) { + int inipos = item.indexOf("muse_") + 5; + int finpos = item.lastIndexOf(".qm"); + deliveredLocaleListFiltered << item.mid(inipos, finpos - inipos); + } + } + return deliveredLocaleListFiltered.join(","); + } + return QString("No translations found!"); + } + //--------------------------------------------------------- // usage //--------------------------------------------------------- @@ -3621,7 +3648,7 @@ static void usage(const char* prog, const char* txt) #ifdef HAVE_LASH fprintf(stderr, " -L don't use LASH\n"); #endif - fprintf(stderr, " -l xx force locale given by language/country code (de, sv_SE, ...)"); + fprintf(stderr, " -l xx force locale to the given language/country code (xx = %s)\n", localeList().toLatin1().constData()); fprintf(stderr, "useful environment variables:\n"); fprintf(stderr, " MUSE override library and shared directories location\n"); fprintf(stderr, " MUSEHOME override user home directory (HOME/)\n"); -- cgit v1.2.3