klettres
langutils.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "langutils.h"
00022 #include "prefs.h"
00023
00024 #include <QDir>
00025
00026 #include <KDebug>
00027 #include <KGlobal>
00028 #include <KStandardDirs>
00029
00030 bool LangUtils::hasSpecialChars(const QString& lang)
00031 {
00032 if (lang== "cs"
00033 || lang== "da"
00034 || lang== "sk"
00035 || lang== "es"
00036 || lang== "de"
00037 || lang== "nds")
00038 return true;
00039 return false;
00040 }
00041
00042 QStringList LangUtils::getLanguages()
00043 {
00044 QStringList m_languages;
00045 m_languages.clear();
00046
00047 QStringList mdirs = KGlobal::dirs()->findDirs("data", "klettres/");
00048
00049 for (QStringList::Iterator it =mdirs.begin(); it !=mdirs.end(); ++it ) {
00050 QDir dir(*it);
00051 m_languages += dir.entryList(QDir::Dirs, QDir::Name);
00052 m_languages.removeAll(".");
00053 m_languages.removeAll("..");
00054 }
00055 m_languages.removeAll("pics");
00056 m_languages.removeAll("data");
00057 m_languages.removeAll("icons");
00058 m_languages.sort();
00059
00060
00061
00062
00063 QStringList temp_languages;
00064 for (int i=0; i<m_languages.count(); i++) {
00065 if (m_languages.count(m_languages[i])>1) {
00066 temp_languages.append(m_languages[i]);
00067 m_languages.removeAll(m_languages[i]);
00068 }
00069 for (int i=0; i<temp_languages.count(); i++) {
00070 if (i%2==0)
00071 m_languages.append(temp_languages[i]);
00072 }
00073 temp_languages.clear();
00074 }
00075
00076 m_languages.sort();
00077 kDebug() <<m_languages;
00078 return m_languages;
00079 }
00080
00081 void LangUtils::writeLangConfig()
00082 {
00083
00084 KConfigGroup config(KGlobal::config(), "KNewStuffStatus");
00085 QStringList m_languages = getLanguages();
00086 for (int i=0; i<m_languages.count(); i++) {
00087 QString tmp = m_languages[i];
00088 if (!config.readEntry(tmp, QString()).isEmpty())
00089 config.writeEntry(tmp, QDate::currentDate().toString());
00090 }
00091 config.sync();
00092 }
00093
00094