Scribus
Open source desktop publishing at your fingertips
langmgr.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  begin : Jan 2005
9  copyright : (C) 2005 by Craig Bradney
10  email : cbradney@zip.com.au
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef LANGMANAGER_H
23 #define LANGMANAGER_H
24 
25 #include <QMap>
26 #include <utility>
27 
28 #include <QString>
29 #include <QStringList>
30 #include "langdef.h"
31 #include "scribusapi.h"
32 
33 typedef std::pair<QString, QString> langPair;
34 
35 class SCRIBUS_API LanguageManager
36 {
37  LanguageManager() {};
38  ~LanguageManager();
39 
40  void init(bool generateInstalledList = true);
41 
42 public:
43  static LanguageManager* instance();
44  static void deleteInstance();
45 
46  void languageChange();
47  QStringList languageList(bool getTranslated=true);
48 
49  const QString getLangFromAbbrev(QString, bool getTranslated=true);
50  const QString getAbbrevFromLang(QString, bool getFromTranslated=true, bool useInstalled=true);
51  const QString getLangFromTransLang(QString transLang);
52  const QString getTransLangFromLang(QString lang);
53  const QString getShortAbbrevFromAbbrev(QString langAbbrev);
54  const QString getAlternativeAbbrevfromAbbrev(QString langAbbrev);
55  void fillInstalledStringList(QStringList *stringListToFill, bool addDefaults);
56  void fillInstalledGUIStringList(QStringList *stringListToFill, bool addDefaults);
57  void fillInstalledHyphStringList(QStringList *stringListToFill);
58  void printInstalledList();
59  QString numericSequence(QString seq);
60  bool findSpellingDictionaries(QStringList& sl);
61  void findSpellingDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
62  bool findHyphDictionaries(QStringList& sl);
63  void findHyphDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
64 
65  const QString getHyphFilename(const QString& langAbbrev);
66  int langTableIndex(const QString& abbrev);
67 
68 private:
69  static LanguageManager* m_instance;
70 
71  QList <LangDef> langTable;
72 
73  void generateLangList();
74  void generateInstalledGUILangList();
75  void generateInstalledHyphLangList();
76  void generateInstalledSpellLangList();
77 };
78 
79 #endif
80 
Definition: langmgr.h:35