• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

klettres

  • sources
  • kde-4.12
  • kdeedu
  • klettres
  • src
langutils.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2007 Pino Toscano <pino@kde.org>
3  Copyright 2007-2008 Anne-Marie Mahfouf <annma@kde.org>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 //project headers
21 #include "langutils.h"
22 #include "prefs.h"
23 
24 #include <QDir>
25 
26 #include <KDebug>
27 #include <KGlobal>
28 #include <KLocale>
29 #include <KStandardDirs>
30 
31 bool LangUtils::hasSpecialChars(const QString& lang)
32 {
33  if (lang== "cs"
34  || lang== "da"
35  || lang== "sk"
36  || lang== "es"
37  || lang== "de"
38  || lang== "hu"
39  || lang== "nds"
40  || lang== "lt")
41  return true;
42  return false;
43 }
44 
45 bool LangUtils::isIndian(const QString& lang)
46 {
47  if (lang == "kn"
48  || lang == "ml"
49  || lang == "te"
50  || lang == "pa")
51  return true;
52  return false;
53 }
54 
55 QStringList LangUtils::getLanguages()
56 {
57  QStringList m_languages;
58  m_languages.clear();
59  //the program scans in klettres/data/ to see what languages data is found
60  const QStringList mdirs = KGlobal::dirs()->findDirs("data", "klettres/");
61  //if (mdirs.isEmpty()) return NULL;
62  for (QStringList::const_iterator it =mdirs.constBegin(); it !=mdirs.constEnd(); ++it ) {
63  QDir dir(*it);
64  m_languages += dir.entryList(QDir::Dirs, QDir::Name);
65  m_languages.removeAll(".");
66  m_languages.removeAll("..");
67  }
68  m_languages.removeAll("pics");
69  m_languages.removeAll("data");
70  m_languages.removeAll("icons");
71  m_languages.sort();
72 
73  //find duplicated entries in KDEDIR and KDEHOME
74  QStringList temp_languages;
75  for (int i=0; i<m_languages.count(); i++) {
76  if (m_languages.count(m_languages[i])>1) {
77  temp_languages.append(m_languages[i]);
78  m_languages.removeAll(m_languages[i]);
79  }
80  for (int i=0; i<temp_languages.count(); i++) {
81  if (i%2==0)
82  m_languages.append(temp_languages[i]);//append 1 of the 2 instances found
83  }
84  temp_languages.clear();
85  }
86  //TODO TEST in FRENCH
87  m_languages.sort();
88  kDebug() <<m_languages;
89  return m_languages;
90 }
91 
92 QStringList LangUtils::getLanguagesNames(QStringList languagesList)
93 {
94  //we look in $KDEDIR/share/locale/all_languages from /kdelibs/kdecore/all_languages
95  //to find the name of the country
96  //corresponding to the code and the language the user set
97  QStringList languagesNames;
98  KConfig entry(KStandardDirs::locate("locale", "all_languages"));
99 
100  foreach(const QString &language, languagesList) {
101  if (language == "hi-ro") {
102  languagesNames.append(i18n("Romanized Hindi"));
103  } else if (language == "lug_UG") {
104  languagesNames.append(i18n("Luganda"));
105  } else if (language == "ep") {
106  languagesNames.append(i18n("English Phonics"));
107  } else {
108  KConfigGroup group = entry.group(language);
109  QString languageName = group.readEntry("Name");
110  if (languageName.isEmpty()) {
111  languageName = i18nc("@item:inlistbox no language for that locale", "None");
112  }
113  languagesNames.append(languageName);
114  }
115  }
116  //never sort m_languageNames as it's m_languages translated
117  return languagesNames;
118 }
119 
120 void LangUtils::writeLangConfig()
121 {
122  //write the present languages in config so they cannot be downloaded
123  KConfigGroup config(KGlobal::config(), "KNewStuffStatus");
124  QStringList m_languages = getLanguages();
125  for (int i=0; i<m_languages.count(); i++) {
126  QString tmp = m_languages[i];
127  if (!config.readEntry(tmp, QString()).isEmpty()) {
128  config.writeEntry(tmp, QDate::currentDate().toString());
129  }
130  }
131  config.sync();
132 }
133 
134 
LangUtils::isIndian
static bool isIndian(const QString &lang)
Indian languages cannot have isLetter()
Definition: langutils.cpp:45
prefs.h
langutils.h
LangUtils::writeLangConfig
static void writeLangConfig()
Definition: langutils.cpp:120
LangUtils::getLanguagesNames
static QStringList getLanguagesNames(QStringList languagesList)
All available languages translated names.
Definition: langutils.cpp:92
LangUtils::hasSpecialChars
static bool hasSpecialChars(const QString &lang)
Definition: langutils.cpp:31
LangUtils::getLanguages
static QStringList getLanguages()
Available languages ISO names.
Definition: langutils.cpp:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

klettres

Skip menu "klettres"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal