Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 22149 → Rev 22150

/trunk/Scribus/scribus/langmgr.cpp
829,6 → 829,23
return "";
}
 
const QString LanguageManager::getShortAbbrevFromAbbrevDecomposition(QString langAbbrev)
{
int tIndex = langTableIndex(langAbbrev);
if (tIndex >= 0)
return m_langTable[tIndex].m_priAbbrev;
 
QStringList abbrevs = getAbbrevDecomposition(langAbbrev);
for (int i = 1; i < abbrevs.count(); ++i)
{
tIndex = langTableIndex(abbrevs.at(i));
if (tIndex >= 0)
return m_langTable[tIndex].m_priAbbrev;
}
 
return "";
}
 
const QString LanguageManager::getAlternativeAbbrevfromAbbrev(QString langAbbrev)
{
int i=langTableIndex(langAbbrev);
837,6 → 854,33
return "";
}
 
QStringList LanguageManager::getAbbrevDecomposition(QString langAbbrev)
{
QStringList abbrevs;
abbrevs.append(langAbbrev);
 
QString curAbbrev = langAbbrev;
QString delimiters = QString::fromLatin1("_.");
 
while (true)
{
int rightMost = 0;
for (int i = 0; i < delimiters.length(); i++)
{
int k = curAbbrev.lastIndexOf(delimiters[i]);
if (k > rightMost)
rightMost = k;
}
 
if (rightMost == 0)
break;
 
curAbbrev.truncate(rightMost);
abbrevs.append(curAbbrev);
}
return abbrevs;
}
 
void LanguageManager::fillInstalledStringList(QStringList *stringListToFill)
{
if (!stringListToFill)
/trunk/Scribus/scribus/langmgr.h
51,7 → 51,9
const QString getLangFromTransLang(QString transLang);
const QString getTransLangFromLang(QString lang);
const QString getShortAbbrevFromAbbrev(QString langAbbrev);
const QString getShortAbbrevFromAbbrevDecomposition(QString langAbbrev);
const QString getAlternativeAbbrevfromAbbrev(QString langAbbrev);
QStringList getAbbrevDecomposition(QString langAbbrev);
void fillInstalledStringList(QStringList *stringListToFill);
void fillInstalledGUIStringList(QStringList *stringListToFill);
void fillInstalledHyphStringList(QStringList *stringListToFill);
/trunk/Scribus/scribus/prefsmanager.cpp
54,6 → 54,7
#include "scribusstructs.h"
#include "sctextstream.h"
#include "units.h"
#include "util.h"
#include "util_color.h"
#include "util_file.h"
#include "util_ghostscript.h"
321,7 → 322,9
appPrefs.scrapbookPrefs.writePreviews = true;
appPrefs.scrapbookPrefs.numScrapbookCopies = 10;
appPrefs.displayPrefs.marginColored = false;
appPrefs.docSetupPrefs.language = ScQApp->currGUILanguage();
appPrefs.docSetupPrefs.language = LanguageManager::instance()->getShortAbbrevFromAbbrevDecomposition(ScQApp->currGUILanguage());
if (appPrefs.docSetupPrefs.language.isEmpty())
appPrefs.docSetupPrefs.language = "en_GB";
appPrefs.docSetupPrefs.pageSize = LocaleManager::instance()->pageSizeForLocale(ScQApp->currGUILanguage());
appPrefs.docSetupPrefs.pageOrientation = 0;
PageSize defaultPageSize(appPrefs.docSetupPrefs.pageSize);
2001,6 → 2004,9
if (dc.tagName()=="DocumentSetup")
{
appPrefs.docSetupPrefs.language = dc.attribute("Language", "en_GB");
appPrefs.docSetupPrefs.language = LanguageManager::instance()->getShortAbbrevFromAbbrevDecomposition(appPrefs.docSetupPrefs.language);
if (appPrefs.docSetupPrefs.language.isEmpty())
appPrefs.docSetupPrefs.language = "en_GB";
appPrefs.docSetupPrefs.docUnitIndex = dc.attribute("UnitIndex", "0").toInt();
appPrefs.docSetupPrefs.pageSize = dc.attribute("PageSize","A4");
appPrefs.docSetupPrefs.pageOrientation = dc.attribute("PageOrientation", "0").toInt();
/trunk/Scribus/scribus/scribusapp.cpp
49,6 → 49,7
#include "scpaths.h"
#include "scribuscore.h"
#include "upgradechecker.h"
#include "util.h"
 
#ifdef WITH_TESTS
#include "tests/runtests.h"
410,6 → 411,7
if (userprefsContext)
{
QString prefslang = userprefsContext->get("gui_language","");
prefslang = cleanupLang(prefslang);
if (!prefslang.isEmpty())
langs.append(prefslang);
}
420,21 → 422,27
 
if (!(lang = ::getenv("LANG")).isEmpty())
{
lang = cleanupLang(lang);
if (lang=="C")
lang="en";
langs.append(lang);
if (!lang.isEmpty())
langs.append(lang);
}
if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
{
lang = cleanupLang(lang);
if (lang=="C")
lang="en";
langs.append(lang);
if (!lang.isEmpty())
langs.append(lang);
}
if (!(lang = ::getenv("LC_ALL")).isEmpty())
{
lang = cleanupLang(lang);
if (lang=="C")
lang="en";
langs.append(lang);
if (!lang.isEmpty())
langs.append(lang);
}
 
#if defined(_WIN32)
458,7 → 466,7
}
#endif
 
langs.append(QString(QLocale::system().name()));
langs.append(QLocale::system().name());
 
// remove duplicate entries...
QStringList::Iterator it = langs.end();
/trunk/Scribus/scribus/ui/smcstylewidget.cpp
309,10 → 309,10
}
 
QString defaultLang(defLang.isEmpty() ? "en_GB" : defLang);
QString clang(cstyle->language().isNull() || cstyle->language().isEmpty() ? defaultLang : cstyle->language());
QString clang(cstyle->language().isEmpty() ? defaultLang : cstyle->language());
QString plang(QString::null);
if (hasParent)
plang = parent->language().isNull() || parent->language().isEmpty() ? defaultLang : parent->language();
plang = parent->language().isEmpty() ? defaultLang : parent->language();
 
int ci = -1, pi = -1, di = -1;
QString tl = LanguageManager::instance()->getAbbrevFromLang(defaultLang, false);
/trunk/Scribus/scribus/util.cpp
50,6 → 50,16
 
using namespace std;
 
QString cleanupLang(const QString& lang)
{
int dotIndex = lang.indexOf(QChar('.'));
if (dotIndex < 0)
return lang;
 
QString cleanLang = lang.left(dotIndex);
return cleanLang;
}
 
int System(const QString exename, const QStringList & args, const QString fileStdErr, const QString fileStdOut, bool* cancel)
{
QProcess proc;
/trunk/Scribus/scribus/util.h
34,7 → 34,10
class ScribusDoc;
class ScribusView;
 
// class Foi;
/*!
\brief Cleanup language strings from extensions such as ".UTF-8" we can get from environment variables
*/
QString cleanupLang(const QString& lang);
 
/*! \brief Compare double values by pre-multiplying by 10000 and converting to long if possible.
If premultiplication does not allow to store result in a long value, perform a standard comparison.