-rw-r--r-- | library/global.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/library/global.cpp b/library/global.cpp index fd7579a..dd15eb7 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -17,6 +17,7 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #define QTOPIA_INTERNAL_LANGLIST | ||
20 | #include <qpe/qpedebug.h> | 21 | #include <qpe/qpedebug.h> |
21 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
22 | #include <qpe/qdawg.h> | 23 | #include <qpe/qdawg.h> |
@@ -170,12 +171,18 @@ const QDawg& Global::fixedDawg() | |||
170 | 171 | ||
171 | fixed_dawg = new QDawg; | 172 | fixed_dawg = new QDawg; |
172 | QString dawgfilename = dictDir() + "/dawg"; | 173 | QString dawgfilename = dictDir() + "/dawg"; |
173 | QString lang = getenv( "LANG" ); | 174 | QString words_lang; |
174 | QString dawgfilename_lang = dawgfilename + "." + lang; | 175 | QStringList langs = Global::languageList(); |
175 | QString words_lang = dictDir() + "/words." + lang; | 176 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
176 | if ( QFile::exists(dawgfilename_lang) || | 177 | QString lang = *it; |
177 | QFile::exists(words_lang) ) | 178 | words_lang = dictDir() + "/words." + lang; |
178 | dawgfilename = dawgfilename_lang; | 179 | QString dawgfilename_lang = dawgfilename + "." + lang; |
180 | if ( QFile::exists(dawgfilename_lang) || | ||
181 | QFile::exists(words_lang) ) { | ||
182 | dawgfilename = dawgfilename_lang; | ||
183 | break; | ||
184 | } | ||
185 | } | ||
179 | QFile dawgfile(dawgfilename); | 186 | QFile dawgfile(dawgfilename); |
180 | 187 | ||
181 | if ( !dawgfile.exists() ) { | 188 | if ( !dawgfile.exists() ) { |
@@ -639,6 +646,42 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | |||
639 | } | 646 | } |
640 | } | 647 | } |
641 | 648 | ||
649 | QStringList Global::languageList() | ||
650 | { | ||
651 | QString lang = getenv("LANG"); | ||
652 | QStringList langs; | ||
653 | langs.append(lang); | ||
654 | int i = lang.find("."); | ||
655 | if ( i > 0 ) | ||
656 | lang = lang.left( i ); | ||
657 | i = lang.find( "_" ); | ||
658 | if ( i > 0 ) | ||
659 | langs.append(lang.left(i)); | ||
660 | return langs; | ||
661 | } | ||
662 | |||
663 | QStringList Global::helpPath() | ||
664 | { | ||
665 | QStringList path; | ||
666 | QStringList langs = Global::languageList(); | ||
667 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | ||
668 | QString lang = *it; | ||
669 | if ( !lang.isEmpty() ) | ||
670 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | ||
671 | } | ||
672 | path += QPEApplication::qpeDir() + "/pics"; | ||
673 | path += QPEApplication::qpeDir() + "/help/en/html"; | ||
674 | path += QPEApplication::qpeDir() + "/docs"; | ||
675 | QString dir = QDir::current().canonicalPath(); | ||
676 | if ( dir == "/" ) | ||
677 | dir += "/docs"; | ||
678 | else { | ||
679 | path += dir + "/../pics"; | ||
680 | dir += "/../docs"; | ||
681 | path += dir; | ||
682 | } | ||
683 | return path; | ||
684 | } | ||
642 | 685 | ||
643 | 686 | ||
644 | #include "global.moc" | 687 | #include "global.moc" |