r17798 by craig - Migrate to using language codes instead of names. Reimplement language table. Rewrite language functions. Modify spelling, hyphenation and style code appropriately
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 13 18:03:21 UTC 2012
Author: craig
Date: Sat Oct 13 18:03:21 2012
New Revision: 17798
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17798
Log:
Migrate to using language codes instead of names. Reimplement language table. Rewrite language functions. Modify spelling, hyphenation and style code appropriately
Modified:
trunk/Scribus/scribus/CMakeLists.txt
trunk/Scribus/scribus/hyphenator.cpp
trunk/Scribus/scribus/hyphenator.h
trunk/Scribus/scribus/langmgr.cpp
trunk/Scribus/scribus/langmgr.h
trunk/Scribus/scribus/observable.h
trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
trunk/Scribus/scribus/plugins/short-words/parse.cpp
trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
trunk/Scribus/scribus/ui/prefs_spelling.cpp
trunk/Scribus/scribus/ui/prefs_userinterface.cpp
trunk/Scribus/scribus/ui/sctreewidget.h
trunk/Scribus/scribus/ui/smcstylewidget.cpp
trunk/Scribus/scribus/ui/smcstylewidget.h
trunk/Scribus/scribus/ui/smtextstyles.cpp
Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Sat Oct 13 18:03:21 2012
@@ -554,6 +554,7 @@
hyphenator.cpp
ioapi.c
KarbonCurveFit.cpp
+ langdef.cpp
langmgr.cpp
latexhelpers.cpp
loadsaveplugin.cpp
Modified: trunk/Scribus/scribus/hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/hyphenator.cpp (original)
+++ trunk/Scribus/scribus/hyphenator.cpp Sat Oct 13 18:03:21 2012
@@ -45,7 +45,7 @@
Hyphenator::Hyphenator(QWidget* parent, ScribusDoc *dok) : QObject( parent ),
doc(dok),
hdict(0),
- useAble(false),
+ usable(false),
codec(0),
MinWordLen(doc->hyphMinimumWordLength()),
HyCount(doc->hyphConsecutiveLines()),
@@ -53,17 +53,15 @@
AutoCheck(doc->hyphAutoCheck())
{
//FIXME:av pick up language from charstyle
- QString pfad(ScPaths::instance().dictDir());
LanguageManager * lmgr(LanguageManager::instance());
- if (!lmgr->getHyphFilename(doc->hyphLanguage(), false).isEmpty() )
+ if (!lmgr->getHyphFilename(doc->hyphLanguage()).isEmpty() )
Language = doc->hyphLanguage();
else
{
Language = PrefsManager::instance()->appPrefs.hyphPrefs.Language;
doc->setHyphLanguage(Language);
}
-// pfad += ScCore->primaryMainWindow()->Sprachen[Language];
- pfad += lmgr->getHyphFilename( doc->hyphLanguage(), true );
+ QString pfad = lmgr->getHyphFilename(doc->hyphLanguage());
QFile f(pfad);
if (f.open(QIODevice::ReadOnly))
{
@@ -75,14 +73,14 @@
}
else
{
- useAble = false;
+ usable = false;
hdict = NULL;
return;
}
QByteArray fn = pfad.toLocal8Bit();
const char * filename = fn.data();
hdict = hnj_hyphen_load(filename);
- useAble = hdict == NULL ? false : true;
+ usable = hdict == NULL ? false : true;
rememberedWords.clear();
/* Add reading these special lists from prefs or doc here */
ignoredWords.clear();
@@ -99,7 +97,7 @@
{
// if (!ScCore->primaryMainWindow()->Sprachen.contains(name))
// return;
- if( LanguageManager::instance()->getHyphFilename(name, false).isEmpty() )
+ if( LanguageManager::instance()->getHyphFilename(name).isEmpty() )
return;
if (Language != name)
@@ -112,7 +110,7 @@
if (hdict != NULL)
hnj_hyphen_free(hdict);
- pfad += LanguageManager::instance()->getHyphFilename(Language, false) ;
+ pfad += LanguageManager::instance()->getHyphFilename(Language) ;
QFile f(pfad);
if (f.open(QIODevice::ReadOnly))
{
@@ -124,14 +122,14 @@
}
else
{
- useAble = false;
+ usable = false;
hdict = NULL;
return;
}
QByteArray fn = pfad.toLocal8Bit();
filename = fn.data();
hdict = hnj_hyphen_load(filename);
- useAble = hdict == NULL ? false : true;
+ usable = hdict == NULL ? false : true;
}
}
@@ -149,7 +147,7 @@
void Hyphenator::slotHyphenateWord(PageItem* it, const QString& text, int firstC)
{
- if ((!useAble))//FIXME:av || (!ScMW->Sprachen.contains(it->Language)))
+ if ((!usable))//FIXME:av || (!ScMW->Sprachen.contains(it->Language)))
return;
const char *word;
char *buffer;
@@ -181,9 +179,8 @@
void Hyphenator::slotHyphenate(PageItem* it)
{
- if ((!useAble) || !(it->asTextFrame()) || (it->itemText.length() == 0))
- return;
-
+ if ((!usable) || !(it->asTextFrame()) || (it->itemText.length() == 0))
+ return;
doc->DoDrawing = false;
const char *word;
@@ -202,7 +199,6 @@
else {
text = it->itemText.text(0, it->itemText.length());
}
-
int firstC = 0;
int lastC = 0;
int Ccount = 0;
Modified: trunk/Scribus/scribus/hyphenator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/hyphenator.h
==============================================================================
--- trunk/Scribus/scribus/hyphenator.h (original)
+++ trunk/Scribus/scribus/hyphenator.h Sat Oct 13 18:03:21 2012
@@ -51,7 +51,7 @@
HyphenDict *hdict;
/*! Flag - if is the dictionary without errors etc. If is it 'false'
hyphen aborted. */
- bool useAble;
+ bool usable;
/*! Qt text codec which handles local characters. */
QTextCodec *codec;
Modified: trunk/Scribus/scribus/langmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/langmgr.cpp
==============================================================================
--- trunk/Scribus/scribus/langmgr.cpp (original)
+++ trunk/Scribus/scribus/langmgr.cpp Sat Oct 13 18:03:21 2012
@@ -43,18 +43,28 @@
return m_instance;
}
+void LanguageManager::languageChange()
+{
+ //TODO
+}
+
void LanguageManager::init(bool generateInstalledList)
{
//generateUntranslatedLangList();
generateLangList();
if (generateInstalledList)
- generateInstalledLangList();
+ {
+ generateInstalledGUILangList();
+ generateInstalledSpellLangList();
+ generateInstalledHyphLangList();
+ }
}
void LanguageManager::generateLangList()
{
// TODO get rid of the redundant key, the english name.
// So internally language would always be manipulated as a code and otherwise presented translated.
+/*
langList.insert("af", langPair("Afrikaans", QObject::tr( "Afrikaans" )) );
langList.insert("af_ZA", langPair("Afrikaans", QObject::tr( "Afrikaans" )) );
langList.insert("an_ES", langPair("Aragonese", QObject::tr( "Aragonese" )) );
@@ -140,10 +150,78 @@
langList.insert("vi", langPair("Vietnamese", QObject::tr( "Vietnamese" )) );
langList.insert("zh", langPair("Chinese", QObject::tr( "Chinese" )) );
langList.insert("zh_TW", langPair("Chinese (Trad.)", QObject::tr( "Chinese (Trad.)" )) );
-
-}
-
-void LanguageManager::generateInstalledLangList()
+*/
+ //Build table;
+ langTable.append(LangDef("af", "af_ZA", "Afrikaans", QObject::tr( "Afrikaans" )));
+ langTable.append(LangDef("an_ES", "", "Aragonese", QObject::tr( "Aragonese" )) );
+ langTable.append(LangDef("ar", "", "Arabic", QObject::tr( "Arabic" )) );
+ langTable.append(LangDef("be_BY", "", "Belarusian", QObject::tr( "Belarusian" )) );
+ langTable.append(LangDef("bg", "bg_BG", "Bulgarian", QObject::tr( "Bulgarian" )) );
+ langTable.append(LangDef("bn", "", "Bengali", QObject::tr( "Bengali" )) );
+ langTable.append(LangDef("br", "", "Breton", QObject::tr( "Breton" )) );
+ langTable.append(LangDef("ca", "", "Catalan", QObject::tr( "Catalan" )) );
+ langTable.append(LangDef("cs", "cs_CZ", "Czech", QObject::tr( "Czech" )) );
+ langTable.append(LangDef("cy", "", "Welsh", QObject::tr( "Welsh" )) );
+ langTable.append(LangDef("da", "da_DK", "Danish", QObject::tr( "Danish" )) );
+ langTable.append(LangDef("de", "de_DE", "German", QObject::tr( "German" )) );
+ langTable.append(LangDef("de_1901","", "German (Trad.)", QObject::tr( "German (Trad.)" )) );
+ langTable.append(LangDef("de_CH", "", "German (Swiss)", QObject::tr( "German (Swiss)" )) );
+ langTable.append(LangDef("dz", "", "Dzongkha", QObject::tr( "Dzongkha" )) );
+ langTable.append(LangDef("el", "", "Greek", QObject::tr( "Greek" )) );
+ langTable.append(LangDef("en_GB", "en", "English (UK)", QObject::tr( "English (UK)" )) );
+ langTable.append(LangDef("en_AU", "", "English (Australia)", QObject::tr( "English (Australia)" )) );
+ langTable.append(LangDef("en_CA", "", "English (Canada)", QObject::tr( "English (Canada)" )) );
+ langTable.append(LangDef("en_NZ", "", "English (New Zealand)", QObject::tr( "English (New Zealand)" )) );
+ langTable.append(LangDef("en_US", "", "English (US)", QObject::tr( "English (US)" )) );
+ langTable.append(LangDef("en_ZA", "", "English (South Africa)", QObject::tr( "English (South Africa)" )) );
+ langTable.append(LangDef("eo", "", "Esperanto", QObject::tr( "Esperanto" )) );
+ langTable.append(LangDef("es", "es_ES", "Spanish", QObject::tr( "Spanish" )) );
+ langTable.append(LangDef("es_AR", "", "Spanish (Argentina)", QObject::tr( "Spanish (Argentina)" )) );
+ langTable.append(LangDef("es_LA", "", "Spanish (Latin)", QObject::tr( "Spanish (Latin)" )) );
+ langTable.append(LangDef("et", "", "Estonian", QObject::tr( "Estonian" )) );
+ langTable.append(LangDef("eu", "", "Basque", QObject::tr( "Basque" )) );
+ langTable.append(LangDef("fi", "", "Finnish", QObject::tr( "Finnish" )) );
+ langTable.append(LangDef("fr", "fr_FR", "French", QObject::tr( "French" )) );
+ langTable.append(LangDef("gl", "", "Galician", QObject::tr( "Galician" )) );
+ langTable.append(LangDef("he", "", "Hebrew", QObject::tr( "Hebrew" )) );
+ langTable.append(LangDef("hr", "", "Croatian", QObject::tr( "Croatian" )) );
+ langTable.append(LangDef("hu", "", "Hungarian", QObject::tr( "Hungarian" )) );
+ langTable.append(LangDef("ia", "", "Latin", QObject::tr( "Latin" )) );
+ langTable.append(LangDef("id", "", "Indonesian", QObject::tr( "Indonesian" )) );
+ langTable.append(LangDef("is", "", "Icelandic", QObject::tr( "Icelandic" )) );
+ langTable.append(LangDef("it", "it_IT", "Italian", QObject::tr( "Italian" )) );
+ langTable.append(LangDef("ja", "", "Japanese", QObject::tr( "Japanese" )) );
+ langTable.append(LangDef("km", "", "Khmer", QObject::tr( "Khmer" )) );
+ langTable.append(LangDef("ko", "", "Korean", QObject::tr( "Korean" )) );
+ langTable.append(LangDef("ku", "", "Kurdish", QObject::tr( "Kurdish" )) );
+ langTable.append(LangDef("la", "", "Latin", QObject::tr( "Latin" )) );
+ langTable.append(LangDef("lb", "", "Luxembourgish", QObject::tr( "Luxembourgish" )) );
+ langTable.append(LangDef("lo", "", "Lao", QObject::tr( "Lao" )) );
+ langTable.append(LangDef("lt", "lt_LT", "Lithuanian", QObject::tr( "Lithuanian" )) );
+ langTable.append(LangDef("nb", "nb_NO", "Norwegian (Bokmål)", QObject::trUtf8( "Norwegian (Bokm\303\245l)" )) );
+ langTable.append(LangDef("nl", "", "Dutch", QObject::tr( "Dutch" )) );
+ langTable.append(LangDef("nn", "nn_NO", "Norwegian (Nnyorsk)", QObject::tr( "Norwegian (Nnyorsk)" )) );
+ langTable.append(LangDef("no", "no_NO", "Norwegian", QObject::tr( "Norwegian" )) );
+ langTable.append(LangDef("pl", "pl_PL", "Polish", QObject::tr( "Polish" )) );
+ langTable.append(LangDef("pt", "", "Portuguese", QObject::tr( "Portuguese" )) );
+ langTable.append(LangDef("pt_BR", "", "Portuguese (BR)", QObject::tr( "Portuguese (BR)" )) );
+ langTable.append(LangDef("ro", "", "Romanian", QObject::tr( "Romanian" )) );
+ langTable.append(LangDef("ru", "", "Russian", QObject::tr( "Russian" )) );
+ langTable.append(LangDef("sa", "", "Sanskrit", QObject::tr( "Sanskrit" )) );
+ langTable.append(LangDef("sk", "sk_SK", "Slovak", QObject::tr( "Slovak" )) );
+ langTable.append(LangDef("sl", "", "Slovenian", QObject::tr( "Slovenian" )) );
+ langTable.append(LangDef("sq", "", "Albanian", QObject::tr( "Albanian" )) );
+ langTable.append(LangDef("sr", "", "Serbian", QObject::tr( "Serbian" )) );
+ langTable.append(LangDef("sv", "", "Swedish", QObject::tr( "Swedish" )) );
+ langTable.append(LangDef("th", "th_TH", "Thai", QObject::tr( "Thai" )) );
+ langTable.append(LangDef("tr", "tr_TR", "Turkish", QObject::tr( "Turkish" )) );
+ langTable.append(LangDef("uk", "uk_UA", "Ukranian", QObject::tr( "Ukranian" )) );
+ langTable.append(LangDef("vi", "", "Vietnamese", QObject::tr( "Vietnamese" )) );
+ langTable.append(LangDef("zh", "", "Chinese", QObject::tr( "Chinese" )) );
+ langTable.append(LangDef("zh_TW", "", "Chinese (Trad.)", QObject::tr( "Chinese (Trad.)" )) );
+}
+
+void LanguageManager::generateInstalledGUILangList()
{
QString path = ScPaths::instance().translationDir();
QString langAbbrev;
@@ -157,25 +235,112 @@
if (file.suffix().toLower() == "qm")
{
langAbbrev = file.completeSuffix().remove(".qm");
- if ((it=langList.find(langAbbrev))!=langList.end())
- installedLangList.insert(it.key(), it.value().second);
+ int j=langTableIndex(langAbbrev);
+ if (j!=-1)
+ {
+ langTable[j].m_transAvailable=true;
+ langTable[j].m_transFile=file.absoluteFilePath();
+ //qDebug()<<"Found installed GUI translation file:"<<langAbbrev<<" : "<<langTable[j].m_transFile<<langTable[j].m_transName;
+ }
}
}
}
}
+void LanguageManager::generateInstalledHyphLangList()
+{
+ //Build our list of hyphenation dictionaries we have in the install dir
+ //Grab the language abbreviation from it, get the full language text
+ //Insert the name as key and a new string list into the map
+ QString hyphDirName = QDir::toNativeSeparators(ScPaths::instance().dictDir());
+ QDir hyphDir(hyphDirName, "hyph*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
+ if (!hyphDir.exists() || hyphDir.count() == 0)
+ {
+ qDebug()<<"No preinstalled hyphenation dictonaries or paths found";
+ return;
+ }
+
+ //QString languageOfHyphFile;
+// qDebug()<<"Installed Hyphenation Dictonaries:";
+ for (uint i = 0; i < hyphDir.count(); ++i)
+ {
+ QFileInfo file(hyphDir[i]);
+ QString langAbbrev=file.baseName().section('_', 1);
+ int j=langTableIndex(langAbbrev);
+ if (j!=-1)
+ {
+ langTable[j].m_hyphAvailable=true;
+ langTable[j].m_hyphFile=hyphDirName+hyphDir[i];
+ //qDebug()<<"Found installed hyphenation dictionary:"<<langAbbrev<<" : "<<hyphDirName+hyphDir[i];
+ }
+ }
+}
+
+void LanguageManager::generateInstalledSpellLangList()
+{
+ QStringList dictionaryPaths;
+ bool dictPathFound=findSpellingDictionaries(dictionaryPaths);
+ if (!dictPathFound)
+ {
+ qDebug()<<"No preinstalled spelling dictonaries or paths found";
+ return;
+ }
+ QMap<QString, QString> dictionaryMap;
+ findSpellingDictionarySets(dictionaryPaths, dictionaryMap);
+ if (dictionaryMap.count()==0)
+ return;
+
+ QMap<QString, QString>::iterator it = dictionaryMap.begin();
+// qDebug()<<"Installed Spelling Dictonaries:";
+ while (it != dictionaryMap.end())
+ {
+ int j=langTableIndex(it.key());
+ if (j!=-1)
+ {
+ langTable[j].m_spellAvailable=true;
+ langTable[j].m_spellFile=it.value();
+// qDebug()<<"Found installed spelling dictionary:"<<it.key()<<" : "<<it.value();
+ }
+ ++it;
+ }
+}
+
+
+
+int LanguageManager::langTableIndex(const QString &abbrev)
+{
+// qDebug()<<"langTableIndex: Trying to find:"<<abbrev;
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+// qDebug()<<abbrev<<langTable[i].m_priAbbrev<<langTable[i].m_altAbbrev;
+ if (langTable[i].m_priAbbrev==abbrev || langTable[i].m_altAbbrev==abbrev)
+ return i;
+ }
+ return -1;
+}
+
const QString LanguageManager::getLangFromAbbrev(QString langAbbrev, bool getTranslated)
{
- QMap<QString, langPair>::Iterator it;
- if ((it=langList.find(langAbbrev))!=langList.end())
+// qDebug()<<"Trying to find:"<<langAbbrev;
+ int i=langTableIndex(langAbbrev);
+// qDebug()<<"Index of"<<langAbbrev<<":"<<i;
+ if (i==-1)
+ {
+ if (langAbbrev.length()>5)
+ {
+ langAbbrev.truncate(5);
+ i=langTableIndex(langAbbrev);
+ }
+ }
+ if (i!=-1)
{
if (getTranslated)
- return it.value().second;
+ return langTable[i].m_transName;
else
- return it.value().first;
- }
- else
- return "";
+ return langTable[i].m_name;
+ }
+ //qDebug()<<langAbbrev<<"not found";
+ return "";
}
const QString LanguageManager::getAbbrevFromLang(QString lang, bool getFromTranslated, bool useInstalled)
@@ -183,59 +348,72 @@
QMap<QString, langPair>::Iterator it;
if (lang == "English" || lang == QObject::tr( "English"))
useInstalled = false;
- if (useInstalled)
- {
- for (it=langList.begin();it!=langList.end();++it)
- {
- if (installedLangList.find(it.key()) != installedLangList.end())
- {
- if (getFromTranslated && it.value().second==lang)
- return it.key();
- if (!getFromTranslated && it.value().first==lang)
- return it.key();
- }
- }
- }
- else
- {
- for (it=langList.begin();it!=langList.end();++it)
- {
-// if (installedLangList.find(it.key()) != installedLangList.end())
-// {
- if (getFromTranslated && it.value().second==lang)
- return it.key();
- if (!getFromTranslated && it.value().first==lang)
- return it.key();
-// }
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ if (useInstalled)
+ {
+ if (langTable[i].m_transAvailable && (langTable[i].m_name==lang || langTable[i].m_transName==lang))
+ return langTable[i].m_priAbbrev;
+ }
+ else
+ {
+ //qDebug()<<lang<<langTable[i].m_priAbbrev<<langTable[i].m_name<<langTable[i].m_transName;
+ if (langTable[i].m_name==lang || langTable[i].m_transName==lang)
+ return langTable[i].m_priAbbrev;
}
}
return "";
}
-const QString LanguageManager::getLangFromTransLang(QString lang)
-{
- QMap<QString, langPair>::Iterator it;
- for (it=langList.begin();it!=langList.end();++it)
- {
- if (it.value().second==lang)
- return it.value().first;
+const QString LanguageManager::getLangFromTransLang(QString transLang)
+{
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ if (langTable[i].m_transName==transLang)
+ return langTable[i].m_name;
}
return "";
}
const QString LanguageManager::getTransLangFromLang(QString lang)
{
- QMap<QString, langPair>::Iterator it;
// Seems something is missing here!
QString enLang(QObject::tr( "English"));
if ((lang == "English") || (lang == enLang))
return enLang;
- for (it=langList.begin();it!=langList.end();++it)
- {
- if (it.value().first==lang)
- return it.value().second;
- }
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ if (langTable[i].m_name==lang)
+ return langTable[i].m_transName;
+ }
+ return "";
+}
+
+const QString LanguageManager::getShortAbbrevFromAbbrev(QString langAbbrev)
+{
+ // qDebug()<<"Trying to find:"<<langAbbrev;
+ int i=langTableIndex(langAbbrev);
+ // qDebug()<<"Index of"<<langAbbrev<<":"<<i;
+ if (i==-1)
+ {
+ if (langAbbrev.length()>5)
+ {
+ langAbbrev.truncate(5);
+ i=langTableIndex(langAbbrev);
+ }
+ }
+ if (i!=-1)
+ return langTable[i].m_priAbbrev;
+ //qDebug()<<langAbbrev<<"not found";
+ return "";
+}
+
+const QString LanguageManager::getAlternativeAbbrevfromAbbrev(QString langAbbrev)
+{
+ int i=langTableIndex(langAbbrev);
+ if (i!=-1)
+ return langTable[i].m_altAbbrev;
return "";
}
@@ -251,17 +429,63 @@
stringListToFill->append( QObject::tr( "English" ));
}
- for (it=installedLangList.begin();it!=installedLangList.end();++it)
- stringListToFill->append(it.value());
- }
+ for (int i = 0; i < langTable.size(); ++i)
+ stringListToFill->append(langTable[i].m_transName);
+ }
+}
+
+void LanguageManager::fillInstalledGUIStringList(QStringList *stringListToFill, bool addDefaults)
+{
+ if (stringListToFill)
+ {
+ if (addDefaults)
+ {
+ stringListToFill->append("");
+ stringListToFill->append( QObject::tr( "English" ));
+ }
+
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ //qDebug()<<langTable[i].m_transName<<langTable[i].m_transAvailable;
+ if (langTable[i].m_transAvailable)
+ stringListToFill->append(langTable[i].m_transName);
+ }
+ }
+ stringListToFill->sort();
+}
+
+void LanguageManager::fillInstalledHyphStringList(QStringList *stringListToFill)
+{
+ if (stringListToFill)
+ {
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ //qDebug()<<langTable[i].m_transName<<langTable[i].m_hyphAvailable;
+ if (langTable[i].m_hyphAvailable)
+ stringListToFill->append(langTable[i].m_transName);
+ }
+ }
+ stringListToFill->sort();
+}
+
+QStringList LanguageManager::languageList(bool getTranslated)
+{
+ QStringList sl;
+ for (int i = 0; i < langTable.size(); ++i)
+ {
+ if (getTranslated)
+ sl<<langTable[i].m_transName;
+ else
+ sl<<langTable[i].m_name;
+ }
+ sl.sort();
+ return sl;
}
void LanguageManager::printInstalledList()
{
- QMap<QString, QString>::Iterator it;
-
- for (it=installedLangList.begin();it!=installedLangList.end();++it)
- std::cout << it.key().leftJustified(6).toStdString() << ": " << it.value().toStdString() << std::endl;
+ for (int i = 0; i < langTable.size(); ++i)
+ qDebug() << langTable[i].m_priAbbrev.leftJustified(6) << ": " << langTable[i].m_name;
}
QString LanguageManager::numericSequence(QString seq)
@@ -310,7 +534,7 @@
return retSeq;
}
-bool LanguageManager::findDictionaries(QStringList &sl)
+bool LanguageManager::findSpellingDictionaries(QStringList &sl)
{
sl=ScPaths::instance().spellDirs();
if (sl.count()==0)
@@ -318,7 +542,7 @@
return true;
}
-void LanguageManager::findDictionarySets(QStringList &dictionaryPaths, QMap<QString, QString> &dictionaryMap)
+void LanguageManager::findSpellingDictionarySets(QStringList &dictionaryPaths, QMap<QString, QString> &dictionaryMap)
{
for (int i=0; i<dictionaryPaths.count(); ++i)
{
@@ -337,20 +561,77 @@
else
{
if (!dictionaryMap.contains(dictName))
- dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+ {
+ if (dictName.length()<=5)
+ {
+ //QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
+ //qDebug()<<"findSpellingDictionarySets"<<dictName<<shortAbbrev;
+ dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+ //dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
+ }
+ //qDebug()<<"Spell Finder:"<<dictName<<dictionaryPaths.at(i)+dictName;
+ if (dictName.length()>5)
+ {
+ QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(dictName));
+ //qDebug()<<shortAbbrev;
+ dictionaryMap.insert(shortAbbrev, dictionaryPaths.at(i)+dictName);
+ }
+ }
}
}
// qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
}
+ //Now rescan dictionary map for any extra languages we can support with the files we have
+ QMap<QString, QString>::iterator it = dictionaryMap.begin();
+ while (it != dictionaryMap.end())
+ {
+ QString lang(it.key());
+ if (lang.length()==5)
+ {
+ QString shortAbbrev(LanguageManager::getShortAbbrevFromAbbrev(lang));
+ if (!dictionaryMap.contains(shortAbbrev))
+ {
+ //qDebug()<<"Adding extra spelling definitions for:"<<lang<<":"<<shortAbbrev;
+ dictionaryMap.insert(shortAbbrev, it.value());
+ }
+ //else
+ //qDebug()<<"Short abbreviation:"<<shortAbbrev<<"already exists for:"<<lang;
+ }
+ if (lang.length()==2)
+ {
+ QString altAbbrev(LanguageManager::getAlternativeAbbrevfromAbbrev(lang));
+ if (!dictionaryMap.contains(altAbbrev))
+ {
+ //qDebug()<<"Adding extra spelling definitions for:"<<lang<<":"<<altAbbrev;
+ dictionaryMap.insert(altAbbrev, it.value());
+ }
+ //else
+ //qDebug()<<"Alt. abbreviation:"<<altAbbrev<<"already exists for:"<<lang;
+ }
+ ++it;
+ }
}
LanguageManager::~LanguageManager()
{
- langList.clear();
- installedLangList.clear();
- hyphLangList.clear();
-}
-
+ langTable.clear();
+// langList.clear();
+// installedLangList.clear();
+// hyphLangList.clear();
+}
+
+const QString LanguageManager::getHyphFilename(const QString & langAbbrev)
+{
+ int j=langTableIndex(langAbbrev);
+ if (j!=-1 && langTable[j].m_hyphAvailable)
+ {
+// qDebug()<<"Found requested hyphenation dictionary:"<<langAbbrev<<" : "<<langTable[j].m_hyphFile;
+ return langTable[j].m_hyphFile;
+ }
+ return QString();
+}
+
+/*
void LanguageManager::addHyphLang(const QString & lang, const QString & filename)
{
hyphLangList[lang] = filename;
@@ -367,8 +648,7 @@
{
return hyphLangList.keys();
}
-
-
-
-
-
+*/
+
+
+
Modified: trunk/Scribus/scribus/langmgr.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/langmgr.h
==============================================================================
--- trunk/Scribus/scribus/langmgr.h (original)
+++ trunk/Scribus/scribus/langmgr.h Sat Oct 13 18:03:21 2012
@@ -27,6 +27,7 @@
#include <QString>
#include <QStringList>
+#include "langdef.h"
#include "scribusapi.h"
typedef std::pair<QString, QString> langPair;
@@ -42,29 +43,33 @@
public:
static LanguageManager* instance();
+ void languageChange();
+ QStringList languageList(bool getTranslated=true);
const QString getLangFromAbbrev(QString, bool getTranslated=true);
const QString getAbbrevFromLang(QString, bool getFromTranslated=true, bool useInstalled=true);
- const QString getLangFromTransLang(QString lang);
+ const QString getLangFromTransLang(QString transLang);
const QString getTransLangFromLang(QString lang);
+ const QString getShortAbbrevFromAbbrev(QString langAbbrev);
+ const QString getAlternativeAbbrevfromAbbrev(QString langAbbrev);
void fillInstalledStringList(QStringList *stringListToFill, bool addDefaults);
+ void fillInstalledGUIStringList(QStringList *stringListToFill, bool addDefaults);
+ void fillInstalledHyphStringList(QStringList *stringListToFill);
void printInstalledList();
QString numericSequence(QString seq);
- bool findDictionaries(QStringList& sl);
- void findDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
+ bool findSpellingDictionaries(QStringList& sl);
+ void findSpellingDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
- void addHyphLang(const QString& lang, const QString& filename);
- const QString getHyphFilename(const QString& lang, bool langIsAbbreviated = true);
- const QStringList hyphLangs();
+ const QString getHyphFilename(const QString& langAbbrev);
+ int langTableIndex(const QString& abbrev);
-private:
- QMap<QString, langPair > langList;
- QMap<QString, QString> installedLangList;
- QMap<QString, QString> hyphLangList; // <lang abbreviated, dict filename>
+ private:
+ QList <LangDef> langTable;
void generateLangList();
- void generateInstalledLangList();
-
+ void generateInstalledGUILangList();
+ void generateInstalledHyphLangList();
+ void generateInstalledSpellLangList();
};
#endif
Modified: trunk/Scribus/scribus/observable.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/observable.h
==============================================================================
--- trunk/Scribus/scribus/observable.h (original)
+++ trunk/Scribus/scribus/observable.h Sat Oct 13 18:03:21 2012
@@ -213,6 +213,8 @@
{
MassObservable<OBSERVED*>::update(dynamic_cast<OBSERVED*>(this));
}
+private:
+ using MassObservable<OBSERVED*>::update;
};
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp Sat Oct 13 18:03:21 2012
@@ -9,6 +9,7 @@
#include "../../formatidlist.h"
#include "commonstrings.h"
+#include "langmgr.h"
#include "ui/missing.h"
#include "prefsmanager.h"
#include "pageitem_latexframe.h"
@@ -858,7 +859,18 @@
m_Doc->cmsSettings().DefaultIntentColors = (eRenderIntent) dc.attribute("DISc", "1").toInt();
m_Doc->cmsSettings().DefaultIntentImages = (eRenderIntent) dc.attribute("DIIm", "0").toInt();
activeLayer = dc.attribute("ALAYER", "0").toInt();
- m_Doc->setHyphLanguage(dc.attribute("LANGUAGE", ""));
+ //m_Doc->setHyphLanguage(dc.attribute("LANGUAGE", ""));
+ static const QString LANGUAGE("LANGUAGE");
+ QString l(dc.attribute(LANGUAGE, "en"));
+ if (LanguageManager::instance()->langTableIndex(l)!=-1)
+ m_Doc->setHyphLanguage(l); //new style storage
+ else
+ { //old style storage
+ QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false);
+ if (lnew.isEmpty())
+ lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false);
+ m_Doc->setHyphLanguage(lnew);
+ }
m_Doc->setHyphMinimumWordLength(dc.attribute("MINWORDLEN", "3").toInt());
m_Doc->setHyphConsecutiveLines(dc.attribute("HYCOUNT", "2").toInt());
m_Doc->setHyphAutomatic(static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()));
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Sat Oct 13 18:03:21 2012
@@ -9,6 +9,7 @@
#include "../../formatidlist.h"
#include "commonstrings.h"
+#include "langmgr.h"
#include "ui/missing.h"
#include "hyphenator.h"
#include "pageitem_latexframe.h"
@@ -1215,7 +1216,18 @@
static const QString LANGUAGE("LANGUAGE");
if (attrs.hasAttribute(LANGUAGE))
- newStyle.setLanguage(attrs.valueAsString(LANGUAGE));
+ {
+ QString l(attrs.valueAsString(LANGUAGE));
+ if (LanguageManager::instance()->langTableIndex(l)!=-1)
+ newStyle.setLanguage(l); //new style storage
+ else
+ { //old style storage
+ QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false);
+ if (lnew.isEmpty())
+ lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false);
+ newStyle.setLanguage(lnew);
+ }
+ }
static const QString SHORTCUT("SHORTCUT");
if (attrs.hasAttribute(SHORTCUT))
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Sat Oct 13 18:03:21 2012
@@ -9,6 +9,7 @@
#include "../../formatidlist.h"
#include "commonstrings.h"
+#include "langmgr.h"
#include "ui/missing.h"
#include "pageitem_group.h"
#include "prefsmanager.h"
@@ -319,7 +320,19 @@
m_Doc->cmsSettings().DefaultIntentColors = (eRenderIntent) dc.attribute("DISc", "1").toInt();
m_Doc->cmsSettings().DefaultIntentImages = (eRenderIntent) dc.attribute("DIIm", "0").toInt();
layerToSetActive=dc.attribute("ALAYER", "0").toInt();
- m_Doc->setHyphLanguage(dc.attribute("LANGUAGE", ""));
+ //m_Doc->setHyphLanguage(dc.attribute("LANGUAGE", ""));
+ static const QString LANGUAGE("LANGUAGE");
+ QString l(dc.attribute(LANGUAGE, "en"));
+ if (LanguageManager::instance()->langTableIndex(l)!=-1)
+ m_Doc->setHyphLanguage(l); //new style storage
+ else
+ { //old style storage
+ QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false);
+ if (lnew.isEmpty())
+ lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false);
+ m_Doc->setHyphLanguage(lnew);
+ }
+
m_Doc->setHyphMinimumWordLength(dc.attribute("MINWORDLEN", "3").toInt());
m_Doc->setHyphConsecutiveLines(dc.attribute("HYCOUNT", "2").toInt());
if (dc.hasAttribute("PAGEWIDTH"))
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sat Oct 13 18:03:21 2012
@@ -11,6 +11,7 @@
#include "commonstrings.h"
#include "ui/missing.h"
#include "hyphenator.h"
+#include "langmgr.h"
#include "pageitem_latexframe.h"
#include "prefsmanager.h"
#include "scclocale.h"
@@ -1926,7 +1927,24 @@
m_Doc->PageSpa = attrs.valueAsDouble("ABSTSPALTEN");
m_Doc->setUnitIndex( attrs.valueAsInt("UNITS", 0) );
- m_Doc->setHyphLanguage(attrs.valueAsString("LANGUAGE", "en_US"));
+ //m_Doc->setHyphLanguage(attrs.valueAsString("LANGUAGE", "en_US"));
+ static const QString LANGUAGE("LANGUAGE");
+ if (attrs.hasAttribute(LANGUAGE))
+ {
+ QString l(attrs.valueAsString(LANGUAGE));
+ if (LanguageManager::instance()->langTableIndex(l)!=-1)
+ m_Doc->setHyphLanguage(l); //new style storage
+ else
+ { //old style storage
+ QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false);
+ if (lnew.isEmpty())
+ lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false);
+ m_Doc->setHyphLanguage(lnew);
+ }
+ }
+
+
+
m_Doc->setHyphMinimumWordLength(attrs.valueAsInt("MINWORDLEN", 3));
m_Doc->setHyphConsecutiveLines(attrs.valueAsInt("HYCOUNT", 2));
@@ -2366,7 +2384,18 @@
static const QString LANGUAGE("LANGUAGE");
if (attrs.hasAttribute(LANGUAGE))
- newStyle.setLanguage(attrs.valueAsString(LANGUAGE));
+ {
+ QString l(attrs.valueAsString(LANGUAGE));
+ if (LanguageManager::instance()->langTableIndex(l)!=-1)
+ newStyle.setLanguage(l); //new style storage
+ else
+ { //old style storage
+ QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false);
+ if (lnew.isEmpty())
+ lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false);
+ newStyle.setLanguage(lnew);
+ }
+ }
static const QString SHORTCUT("SHORTCUT");
Modified: trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp Sat Oct 13 18:03:21 2012
@@ -2073,7 +2073,7 @@
while (bytesRead < paramLen)
{
posA = ts.device()->pos();
- ScColor cc = getBinaryDirectColor(ts);
+ //ScColor cc = getBinaryDirectColor(ts);
ColorTableMap.insert(c, tmpName);
c++;
posN = ts.device()->pos();
Modified: trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp Sat Oct 13 18:03:21 2012
@@ -1268,7 +1268,7 @@
QTransform mat;
QLineF sLin, eLin;
FPoint wh;
- QPointF position = getCoordinate(ds);
+// QPointF position = getCoordinate(ds);
double boundingBoxX = getValue(ds);
double boundingBoxY = getValue(ds);
double boundingBoxW = getValue(ds);
Modified: trunk/Scribus/scribus/plugins/short-words/parse.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/short-words/parse.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/short-words/parse.cpp (original)
+++ trunk/Scribus/scribus/plugins/short-words/parse.cpp Sat Oct 13 18:03:21 2012
@@ -61,13 +61,13 @@
if (lang.isNull() || lang.isEmpty())
qDebug("SWParse::parseItem - variable lang is still empty. No changes are made.");
}
-
+/* IL
QString langCode;
// if (aFrame->doc()->scMW()->Sprachen.contains(lang))
langCode = cfg->getLangCodeFromHyph(LanguageManager::instance()->getHyphFilename(lang,false));
-
+*/
// apply spaces after shorts
- shorts = cfg->getShortWords(langCode);
+ shorts = cfg->getShortWords(lang);
if (shorts.count()==0)
return; // no changes
Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp Sat Oct 13 18:03:21 2012
@@ -38,12 +38,15 @@
bool b=languagesComboBox->blockSignals(true);
languagesComboBox->clear();
QMap<QString, QString>::iterator it = m_dictionaryMap->begin();
+ QStringList langsToAdd;
while (it != dictionaryMap->end())
{
QString lang=LanguageManager::instance()->getLangFromAbbrev(it.key(), true);
- languagesComboBox->addItem(!lang.isEmpty() ? lang : it.key());
+ if (!langsToAdd.contains(lang))
+ langsToAdd<<(!lang.isEmpty() ? lang : it.key());
++it;
}
+ languagesComboBox->addItems(langsToAdd);
languagesComboBox->setCurrentIndex(0);
m_primaryLangIndex=0;
languagesComboBox->blockSignals(b);
@@ -149,10 +152,14 @@
QString wordLang=LanguageManager::instance()->getAbbrevFromLang(newLanguage, true, false);
if (!m_hspellerMap->contains(wordLang) )
{
- qDebug()<<"hspeller"<<wordLang<<"does not exist";
+ //qDebug()<<"hspeller"<<wordLang<<"does not exist";
return;
}
-
+ //qDebug()<<wordLang<<newLanguage;
+ if (m_wfList->count()==0)
+ return;
+ if (wfListIndex>=m_wfList->count())
+ wfListIndex=0;
QString word=m_wfList->at(wfListIndex).w;
if ((*m_hspellerMap)[wordLang]->spell(word.toUtf8().constData())==0)
{
Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp Sat Oct 13 18:03:21 2012
@@ -64,14 +64,14 @@
bool HunspellPluginImpl::initHunspell()
{
- bool dictPathFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
+ bool dictPathFound=LanguageManager::instance()->findSpellingDictionaries(dictionaryPaths);
if (!dictPathFound)
{
qDebug()<<"No preinstalled dictonary paths found";
return false;
}
dictionaryMap.clear();
- LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+ LanguageManager::instance()->findSpellingDictionarySets(dictionaryPaths, dictionaryMap);
// numDicts=dictionaryMap.count();
if (dictionaryMap.count()==0)
return false;
@@ -80,6 +80,7 @@
QMap<QString, QString>::iterator it = dictionaryMap.begin();
while (it != dictionaryMap.end())
{
+ //qDebug()<<"hunspell init:"<<it.key()<<it.value();
hspellerMap.insert(it.key(), new Hunspell((it.value()+".aff").toLocal8Bit().constData(),
(it.value()+".dic").toLocal8Bit().constData()));
++it;
@@ -122,15 +123,38 @@
currPos=wordStart;
QString word=iText->text(wordStart,wordEnd-wordStart);
QString wordLang=iText->charStyle(wordStart).language();
- wordLang=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false);
+
+ if (wordLang.isEmpty())
+ {
+ const StyleSet<CharStyle> &tmp(m_doc->charStyles());
+ for (int i = 0; i < tmp.count(); ++i)
+ if(tmp[i].isDefaultStyle())
+ {
+ //check out why we are getting "German" back here next
+ wordLang=tmp[i].language();
+ //qDebug()<<"Default char style lang"<<tmp[i].language();
+ }
+ }
+ //we now use the abbreviation
+ //wordLang=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false);
//A little hack as for some reason our en dictionary from the aspell plugin was not called en_GB or en_US but en, content was en_GB though. Meh.
if (wordLang=="en")
wordLang="en_GB";
int spellerIndex=0;
+ //qDebug()<<"Word:"<<word<<wordLang;
if (!dictionaryMap.contains(wordLang))
- qDebug()<<"Spelling language to match style language not installed ("<<wordLang<<")";
+ {
+ //qDebug()<<"Spelling language to match style language NOT installed ("<<wordLang<<")";
+ QString altLang=LanguageManager::instance()->getAlternativeAbbrevfromAbbrev(wordLang);
+ if (altLang!="")
+ {
+ //qDebug()<<"altLang"<<altLang<<dictionaryMap.contains(altLang);
+ wordLang=altLang;
+ }
+ }
else
{
+ //qDebug()<<"Spelling language to match style language IS installed ("<<wordLang<<")";
int i=0;
QMap<QString, QString>::iterator it = dictionaryMap.begin();
while (it != dictionaryMap.end())
@@ -142,8 +166,11 @@
}
spellerIndex=i;
}
+
if (hspellerMap.contains(wordLang) && hspellerMap[wordLang]->spell(word.toUtf8().constData())==0)
{
+ //qDebug()<<"hspellerMap.contains(wordLang)"<<hspellerMap.contains(wordLang)<< "hspellerMap[wordLang]->spell(word.toUtf8().constData())"<<hspellerMap[wordLang]->spell(word.toUtf8().constData());
+
struct WordsFound wf;
wf.start=currPos;
wf.end=wordEnd;
@@ -155,8 +182,12 @@
wf.replacements.clear();
char **sugglist = NULL;
int suggCount=hspellerMap[wordLang]->suggest(&sugglist, word.toUtf8().constData());
+ //qDebug()<<"suggestion count";
for (int j=0; j < suggCount; ++j)
+ {
wf.replacements << QString::fromUtf8(sugglist[j]);
+ //qDebug()<<QString::fromUtf8(sugglist[j]);
+ }
hspellerMap[wordLang]->free_list(&sugglist, suggCount);
wordsToCorrect.append(wf);
}
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Oct 13 18:03:21 2012
@@ -380,10 +380,12 @@
DocDir = prefsManager->documentDir();
if (primaryMainWindow)
- ScCore->setSplashStatus( tr("Initializing Hyphenator") );
+ ScCore->setSplashStatus( tr("Initializing Languages") );
+ LanguageManager::instance();
+
QString preLang(prefsManager->appPrefs.hyphPrefs.Language);
initHyphenator();
- if (!LanguageManager::instance()->getHyphFilename( preLang, true ).isEmpty() )
+ if (!LanguageManager::instance()->getHyphFilename( preLang ).isEmpty() )
prefsManager->appPrefs.hyphPrefs.Language = preLang;
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Reading Scrapbook") );
@@ -1042,7 +1044,6 @@
scrMenuMgr->addMenuItem(scrActions["extrasHyphenateText"], "Extras", false);
scrMenuMgr->addMenuItem(scrActions["extrasDeHyphenateText"], "Extras", false);
scrMenuMgr->addMenuItem(scrActions["extrasGenerateTableOfContents"], "Extras", false);
- scrMenuMgr->setMenuEnabled("Extras", false);
connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
//Window menu
@@ -1077,7 +1078,7 @@
scrMenuMgr->addMenuToMenuBar("Page");
scrMenuMgr->addMenuToMenuBar("View");
scrMenuMgr->addMenuToMenuBar("Extras");
- scrMenuMgr->setMenuEnabled("Extras", false);
+ //scrMenuMgr->setMenuEnabled("Extras", false);
scrMenuMgr->addMenuToMenuBar("Windows");
menuBar()->addSeparator();
scrMenuMgr->addMenuToMenuBar("Help");
@@ -2493,7 +2494,7 @@
scrActions["insertFrame"]->setEnabled(true);
//scrMenuMgr->setMenuEnabled("Windows", true);
// scrMenuMgr->setMenuEnabled("Page", true);
- scrMenuMgr->setMenuEnabled("Extras", true);
+ //scrMenuMgr->setMenuEnabled("Extras", true);
scrActions["toolsSelect"]->setEnabled(true);
scrActions["toolsZoom"]->setEnabled(true);
@@ -4124,7 +4125,7 @@
else
doc->setName(FName);
doc->setMasterPageMode(false);
- doc->setHyphLanguage(GetLang(doc->hyphLanguage()));
+ //IL doc->setHyphLanguage(GetLang(doc->hyphLanguage()));
HaveNewDoc();
// propertiesPalette->Cpal->displayGradient(0);
// propertiesPalette->updateCList();
@@ -4745,7 +4746,7 @@
scrMenuMgr->setMenuEnabled("Insert", false);
scrActions["insertFrame"]->setEnabled(false);
- scrMenuMgr->setMenuEnabled("Extras", false);
+ //scrMenuMgr->setMenuEnabled("Extras", false);
// scrMenuMgr->setMenuEnabled("Item", false);
scrActions["itemDuplicate"]->setEnabled(false);
scrActions["itemMulDuplicate"]->setEnabled(false);
@@ -9352,28 +9353,28 @@
void ScribusMainWindow::initHyphenator()
{
- InstLang.clear();
+//IL InstLang.clear();
//Build our list of hyphenation dictionaries we have in the install dir
//Grab the language abbreviation from it, get the full language text
//Insert the name as key and a new string list into the map
QString hyphDirName = QDir::toNativeSeparators(ScPaths::instance().dictDir());
QDir hyphDir(hyphDirName, "hyph*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
- if ((hyphDir.exists()) && (hyphDir.count() != 0))
- {
+//IL if ((hyphDir.exists()) && (hyphDir.count() != 0))
+//IL {
// LanguageManager langmgr;
// langmgr.init(false);
- QString languageOfHyphFile;
- for (uint dc = 0; dc < hyphDir.count(); ++dc)
- {
- QFileInfo fi(hyphDir[dc]);
- QString fileLangAbbrev=fi.baseName().section('_', 1);
- InstLang.insert(fileLangAbbrev, QStringList());
+//IL QString languageOfHyphFile;
+//IL for (uint dc = 0; dc < hyphDir.count(); ++dc)
+//IL {
+//IL QFileInfo fi(hyphDir[dc]);
+//IL QString fileLangAbbrev=fi.baseName().section('_', 1);
+//IL InstLang.insert(fileLangAbbrev, QStringList());
//<<hunspell
// languageOfHyphFile = LanguageManager::instance()->getLangFromAbbrev(fileLangAbbrev, false);
// InstLang.insert(languageOfHyphFile, QStringList());
//>>hunspell
- }
- }
+//IL }
+//IL }
//For each qm file existing, load the file and find the translations of the names
QString pfad = ScPaths::instance().translationDir();
@@ -9386,25 +9387,29 @@
QString ext = fi.suffix().toLower();
if (ext == "qm")
{
- QTranslator *trans = new QTranslator(0);
- trans->load(pfad + d2[dc]);
-
- QString translatedLang;
- for (QMap<QString, QStringList>::Iterator it=InstLang.begin(); it!=InstLang.end(); ++it)
- {
- translatedLang="";
- translatedLang = trans->translate("QObject", LanguageManager::instance()->getLangFromAbbrev(it.key(), false).toLocal8Bit().data(), "");
- if (!translatedLang.isEmpty())
- it.value().append(translatedLang);
- }
- delete trans;
+ //IL QTranslator *trans = new QTranslator(0);
+//IL trans->load(pfad + d2[dc]);
+
+//IL QString translatedLang;
+//IL for (QMap<QString, QStringList>::Iterator it=InstLang.begin(); it!=InstLang.end(); ++it)
+//IL {
+//IL translatedLang="";
+//IL translatedLang = trans->translate("QObject", LanguageManager::instance()->getLangFromAbbrev(it.key(), false).toLocal8Bit().data(), "");
+//IL if (!translatedLang.isEmpty())
+//IL it.value().append(translatedLang);
+//IL }
+//IL delete trans;
}
}
}
//For each hyphenation file, grab the strings and the hyphenation data.
QString lang = QString(QLocale::system().name()).left(2);
- LangTransl.clear();
+//IL LangTransl.clear();
prefsManager->appPrefs.hyphPrefs.Language = "en_GB";
+ if (!LanguageManager::instance()->getHyphFilename(lang).isEmpty() )
+ prefsManager->appPrefs.hyphPrefs.Language = lang;
+
+/*
if ((hyphDir.exists()) && (hyphDir.count() != 0))
{
LanguageManager *langmgr(LanguageManager::instance());
@@ -9415,7 +9420,7 @@
QFileInfo fi(hyphDir[dc]);
QString fileLangAbbrev = fi.baseName().section('_', 1);
tLang = langmgr->getLangFromAbbrev(fileLangAbbrev);
- LangTransl.insert(fileLangAbbrev, tLang);
+//IL LangTransl.insert(fileLangAbbrev, tLang);
langmgr->addHyphLang(fileLangAbbrev, hyphDir[dc]);
if (fileLangAbbrev == lang)
prefsManager->appPrefs.hyphPrefs.Language = fileLangAbbrev;
@@ -9423,17 +9428,7 @@
if (tLang.isEmpty())
prefsManager->appPrefs.hyphPrefs.Language = "en_GB";
}
-}
-
-QString ScribusMainWindow::GetLang(QString inLang)
-{
- QMap<QString, QStringList>::Iterator itlend=InstLang.end();
- for (QMap<QString, QStringList>::Iterator itl = InstLang.begin(); itl != itlend; ++itl)
- {
- if (itl.value().contains(inLang))
- return LanguageManager::instance()->getLangFromAbbrev(itl.key(), false);
- }
- return inLang;
+ */
}
void ScribusMainWindow::ImageEffects()
@@ -9760,6 +9755,7 @@
//before changing the tr_NoneColor to the new value. See #9267, #5529
prefsManager->languageChange();
CommonStrings::languageChange();
+ LanguageManager::instance()->languageChange();
//Update actions
if (actionManager!=NULL)
{
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sat Oct 13 18:03:21 2012
@@ -150,7 +150,6 @@
void applyNewMaster(QString name);
void updateRecent(QString fn);
void doPasteRecent(QString data);
- QString GetLang(QString inLang);
bool getPDFDriver(const QString & fn, const QString & nam,
int Components, const std::vector<int> & pageNs,
const QMap<int,QPixmap> & thumbs, QString& error,
@@ -227,8 +226,8 @@
ScribusWin* ActWin;
QClipboard *ClipB;
QString LoadEnc;
- QMap<QString, QStringList> InstLang;
- QMap<QString,QString> LangTransl;
+ //QMap<QString, QStringList> InstLang;
+ //QMap<QString,QString> LangTransl;
QProcess *ExternalApp;
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Oct 13 18:03:21 2012
@@ -9034,7 +9034,7 @@
ss->set("IS_CONTOUR", true);
undoManager->action(currItem, ss, Um::IBorder);
}
- FPoint tp2(getMinClipF(&currItem->ContourLine));
+ //FPoint tp2(getMinClipF(&currItem->ContourLine));
FPoint tp(getMaxClipF(&currItem->ContourLine));
ma.translate(qRound(tp.x()), 0);
ma.scale(-1, 1);
Modified: trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_hyphenator.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_hyphenator.cpp Sat Oct 13 18:03:21 2012
@@ -11,9 +11,9 @@
#include "prefs_hyphenator.h"
#include "langmgr.h"
#include "prefsstructs.h"
-#include "scribuscore.h" //FIXME: for the ScCore call (remove this call)
+//#include "scribuscore.h" //FIXME: for the ScCore call (remove this call)
#include "scribusdoc.h"
-#include "scribus.h" //FIXME: for the ScCore call (remove this call)
+//#include "scribus.h" //FIXME: for the ScCore call (remove this call)
#include "util_icon.h"
#include "util.h"
@@ -21,12 +21,17 @@
: Prefs_Pane(parent)
{
setupUi(this);
- LanguageManager *lmg(LanguageManager::instance());
- hyphLanguageComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
- foreach(QString hlang, lmg->hyphLangs())
- {
- hyphLanguageComboBox->addItem( lmg->getLangFromAbbrev(hlang), lmg->getLangFromAbbrev(hlang,false) );
- }
+// LanguageManager *lmg(LanguageManager::instance());
+// hyphLanguageComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
+// foreach(QString hlang, lmg->hyphLangs())
+// {
+// hyphLanguageComboBox->addItem( lmg->getLangFromAbbrev(hlang), lmg->getLangFromAbbrev(hlang,false) );
+// }
+
+ QStringList languageList;
+ LanguageManager::instance()->fillInstalledHyphStringList(&languageList);
+ languageList.sort();
+ hyphLanguageComboBox->addItems( languageList );
exceptionAddButton->setIcon(QIcon(loadIcon("16/list-add.png")));
exceptionEditButton->setEnabled(false);
@@ -70,9 +75,7 @@
void Prefs_Hyphenator::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
{
prefsData->hyphPrefs.MinWordLen = smallestWordSpinBox->value();
- //FIXME: remove this ScCore call
- QString langFromCombo(ScCore->primaryMainWindow()->GetLang(hyphLanguageComboBox->itemData(hyphLanguageComboBox->currentIndex()).toString()));
- prefsData->hyphPrefs.Language = LanguageManager::instance()->getAbbrevFromLang(langFromCombo, true, false);
+ prefsData->hyphPrefs.Language = LanguageManager::instance()->getAbbrevFromLang(hyphLanguageComboBox->currentText(), true, false);
prefsData->hyphPrefs.Automatic = !hyphSuggestionsCheckBox->isChecked();
prefsData->hyphPrefs.AutoCheck = hyphAutoCheckBox->isChecked();
prefsData->hyphPrefs.HyCount = maxConsecutiveCountSpinBox->value();
Modified: trunk/Scribus/scribus/ui/prefs_spelling.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/prefs_spelling.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_spelling.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_spelling.cpp Sat Oct 13 18:03:21 2012
@@ -105,11 +105,11 @@
void Prefs_Spelling::updateDictList()
{
- bool dictsFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
+ bool dictsFound=LanguageManager::instance()->findSpellingDictionaries(dictionaryPaths);
if (!dictsFound)
return;
dictionaryMap.clear();
- LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+ LanguageManager::instance()->findSpellingDictionarySets(dictionaryPaths, dictionaryMap);
dictTableWidget->clear();
dictTableWidget->setRowCount(dictionaryMap.count());
@@ -120,7 +120,7 @@
{
i.next();
int column=0;
- qDebug()<<i.key()<<i.value();
+ qDebug()<<i.key()<<i.value()<<LanguageManager::instance()->getLangFromAbbrev(i.key(), false);
QTableWidgetItem *newItem1 = new QTableWidgetItem(LanguageManager::instance()->getLangFromAbbrev(i.key()));
newItem1->setFlags(newItem1->flags() & ~Qt::ItemIsEditable);
dictTableWidget->setItem(row, column++, newItem1);
@@ -232,8 +232,8 @@
QUrl url(d.url);
if (url.isValid() && !url.isEmpty() && !url.host().isEmpty())
dictList.append(d);
- else
- qDebug()<<"hysettings : availDicts : invalid URL"<<d.url;
+ //else
+ // qDebug()<<"hysettings : availDicts : invalid URL"<<d.url;
}
}
}
Modified: trunk/Scribus/scribus/ui/prefs_userinterface.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/prefs_userinterface.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_userinterface.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_userinterface.cpp Sat Oct 13 18:03:21 2012
@@ -24,8 +24,7 @@
languageChange();
QStringList languageList;
- LanguageManager::instance()->fillInstalledStringList(&languageList, true);
- languageList.sort();
+ LanguageManager::instance()->fillInstalledGUIStringList(&languageList, true);
languageComboBox->addItems( languageList );
// qt styles
Modified: trunk/Scribus/scribus/ui/sctreewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/sctreewidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/sctreewidget.h (original)
+++ trunk/Scribus/scribus/ui/sctreewidget.h Sat Oct 13 18:03:21 2012
@@ -60,13 +60,17 @@
void setCurrentIndex(int index);
int currentIndex();
void setItemText(int index, QString text);
+
private slots:
void handleMousePress(QTreeWidgetItem *item);
+
signals:
void currentChanged(int);
+
private:
bool m_toolbox_mode;
QHash<int, QTreeWidgetItem*> keySList;
+
protected:
bool event(QEvent *e);
};
Modified: trunk/Scribus/scribus/ui/smcstylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/smcstylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smcstylewidget.cpp (original)
+++ trunk/Scribus/scribus/ui/smcstylewidget.cpp Sat Oct 13 18:03:21 2012
@@ -138,6 +138,17 @@
tmpView->setMinimumWidth(tmpWidth + 24);
}
+void SMCStyleWidget::fillLangComboFromList(QStringList langList)
+{
+ language_->clear();
+ language_->addItems(langList);
+
+ QListView *tmpView = dynamic_cast<QListView*>(language_->view()); Q_ASSERT(tmpView);
+ int tmpWidth = tmpView->sizeHintForColumn(0);
+ if (tmpWidth > 0)
+ tmpView->setMinimumWidth(tmpWidth + 24);
+}
+
void SMCStyleWidget::fillColorCombo(ColorList &colors)
{
fillColor_->clear();
@@ -254,6 +265,7 @@
QString clang = cstyle->language().isNull() || cstyle->language().isEmpty() ?
defLang : cstyle->language();
+ //qDebug()<<"style lang"<<cstyle->language()<<clang;
QString plang(QString::null);
if (hasParent)
plang = parent->language().isNull() || parent->language().isEmpty() ?
@@ -265,21 +277,23 @@
QString tl;
for (int i = 0; i < language_->count(); ++i)
{
- if (language_->itemText(i) == langMap_[clang])
+ QString ltAbbrev=LanguageManager::instance()->getAbbrevFromLang(language_->itemText(i), true, false);
+ //qDebug()<<"ltabbrev"<<ltAbbrev<<language_->itemText(i);
+ if (ltAbbrev == clang)
ci = i;
- if (hasParent && language_->itemText(i) == langMap_[plang])
+ if (hasParent && ltAbbrev == plang)
pi = i;
- tl=LanguageManager::instance()->getTransLangFromLang(defLang);
-// qDebug() << i << language_->itemText(i) << defLang << langMap_[defLang] << tl;
- if (language_->itemText(i) == defLang || language_->itemText(i) == langMap_[defLang] || language_->itemText(i) == tl)
+ tl=defLang;
+ //qDebug() << i << language_->itemText(i) << defLang << langMap_[defLang] << tl;
+ if (ltAbbrev == defLang || ltAbbrev == tl)
// {
di = i;
-// qDebug() << "match on:" << di;
+ //qDebug() << "match on:" << di;
// }
}
-// qDebug() << QString("SMCStyleWidget::show(): deflan='%1'->'%2'").arg(defLang).arg(langMap_[defLang]);
+ //qDebug() << QString("SMCStyleWidget::show(): deflan='%1'->'%2'").arg(defLang).arg(langMap_[defLang]);
Q_ASSERT(di != -1);
if (hasParent)
Modified: trunk/Scribus/scribus/ui/smcstylewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/smcstylewidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/smcstylewidget.h (original)
+++ trunk/Scribus/scribus/ui/smcstylewidget.h Sat Oct 13 18:03:21 2012
@@ -27,6 +27,7 @@
void show(CharStyle *cstyle, QList<CharStyle> &cstyles, const QString &defLang, int unitIndex);
void show(QList<CharStyle*> &cstyles, QList<CharStyle> &cstylesAll, const QString &defLang, int unitIndex);
void fillLangCombo(QMap<QString,QString> langMap);
+ void fillLangComboFromList(QStringList langList);
void fillColorCombo(ColorList &colors);
void languageChange();
void clearAll();
Modified: trunk/Scribus/scribus/ui/smtextstyles.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17798&path=/trunk/Scribus/scribus/ui/smtextstyles.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smtextstyles.cpp (original)
+++ trunk/Scribus/scribus/ui/smtextstyles.cpp Sat Oct 13 18:03:21 2012
@@ -13,6 +13,7 @@
#include "colorcombo.h"
#include "commonstrings.h"
#include "fontcombo.h"
+#include "langmgr.h"
#include "ui/scmwmenumanager.h"
#include "prefsmanager.h"
#include "propertiespalette.h"
@@ -70,7 +71,9 @@
{
if (pwidget_)
{
- pwidget_->cpage->fillLangCombo(doc_->scMW()->LangTransl);
+ QStringList languageList;
+ LanguageManager::instance()->fillInstalledHyphStringList(&languageList);
+ pwidget_->cpage->fillLangComboFromList(languageList);
pwidget_->cpage->fillColorCombo(doc_->PageColors);
pwidget_->cpage->fontFace_->RebuildList(doc_);
if (unitRatio_ != doc_->unitRatio())
@@ -291,7 +294,6 @@
{
if (!doc_)
return;
-
QMap<QString, QString> replacement;
for (int i = 0; i < deleted_.count(); ++i)
{
@@ -299,7 +301,6 @@
continue;
replacement[deleted_[i].first] = deleted_[i].second;
}
-
doc_->redefineStyles(tmpStyles_, false);
doc_->replaceStyles(replacement);
@@ -1308,18 +1309,15 @@
QString language = doc_->paragraphStyle("").charStyle().language();
if (pwidget_->cpage->language_->useParentValue())
+ {
for (int i = 0; i < selection_.count(); ++i)
selection_[i]->charStyle().resetLanguage();
- else
- {
- for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
- {
- if (it.value() == pwidget_->cpage->language_->currentText())
- {
- language = it.key();
- break;
- }
- }
+ }
+ else
+ {
+ QString la=LanguageManager::instance()->getAbbrevFromLang(pwidget_->cpage->language_->currentText(), true, false);
+ if (!la.isEmpty())
+ language=la;
for (int i = 0; i < selection_.count(); ++i)
selection_[i]->charStyle().setLanguage(language);
}
@@ -1567,7 +1565,9 @@
{
if (page_)
{
- page_->fillLangCombo(doc_->scMW()->LangTransl);
+ QStringList languageList;
+ LanguageManager::instance()->fillInstalledHyphStringList(&languageList);
+ page_->fillLangComboFromList(languageList);
page_->fillColorCombo(doc_->PageColors);
page_->fontFace_->RebuildList(doc_);
}
@@ -2234,14 +2234,9 @@
selection_[i]->resetLanguage();
else
{
- for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
- {
- if (it.value() == page_->language_->currentText())
- {
- language = it.key();
- break;
- }
- }
+ QString tl(LanguageManager::instance()->getAbbrevFromLang(page_->language_->currentText(), true));
+ if (!tl.isEmpty())
+ language=tl;
for (int i = 0; i < selection_.count(); ++i)
selection_[i]->setLanguage(language);
}
More information about the scribus-commit
mailing list