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() = default; 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 QString getLangFromAbbrev(QString, bool getTranslated=true); 50 QString getAbbrevFromLang(const QString&, bool useInstalled=true); 51 QString getLangFromTransLang(const QString& transLang); 52 QString getTransLangFromLang(const QString& lang); 53 QString getShortAbbrevFromAbbrev(QString langAbbrev); 54 QString getShortAbbrevFromAbbrevDecomposition(const QString& langAbbrev); 55 QString getAlternativeAbbrevfromAbbrev(const QString& langAbbrev); 56 QStringList getAbbrevDecomposition(const QString& langAbbrev); 57 void fillInstalledStringList(QStringList *stringListToFill); 58 void fillInstalledGUIStringList(QStringList *stringListToFill); 59 void fillInstalledHyphStringList(QStringList *stringListToFill); 60 void fillInstalledSpellStringList(QStringList *stringListToFill); 61 void printInstalledList(); 62 QString numericSequence(const QString& seq); 63 bool findSpellingDictionaries(QStringList& sl); 64 void findSpellingDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap); 65 bool findHyphDictionaries(QStringList& sl); 66 void findHyphDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap); 67 68 QString getHyphFilename(const QString& langAbbrev); 69 int langTableIndex(const QString& abbrev); 70 71 bool isAvailableTranslation(QString langAbbrev); 72 73 private: 74 static LanguageManager* m_instance; 75 76 QList <LangDef> m_langTable; 77 78 void generateLangList(); 79 void generateInstalledGUILangList(); 80 void generateInstalledHyphLangList(); 81 void generateInstalledSpellLangList(); 82 }; 83 84 #endif 85 86