50
50
#include " qcoreapplication.h"
51
51
#include " qcoreapplication_p.h"
52
52
#include " qdatastream.h"
53
+ #include " qdir.h"
53
54
#include " qfile.h"
54
55
#include " qmap.h"
55
56
#include " qalgorithms.h"
61
62
#include " private/qcore_unix_p.h"
62
63
#endif
63
64
65
+ #ifdef Q_OS_SYMBIAN
66
+ #include " private/qcore_symbian_p.h"
67
+ #endif
68
+
64
69
// most of the headers below are already included in qplatformdefs.h
65
70
// also this lacks Large File support but that's probably irrelevant
66
71
#if defined(QT_USE_MMAP)
@@ -402,11 +407,24 @@ bool QTranslator::load(const QString & filename, const QString & directory,
402
407
403
408
QString prefix;
404
409
if (QFileInfo (filename).isRelative ()) {
410
+ #ifdef Q_OS_SYMBIAN
411
+ if (directory.isEmpty ())
412
+ prefix = QCoreApplication::applicationDirPath ();
413
+ else
414
+ prefix = QFileInfo (directory).absoluteFilePath (); // TFindFile doesn't like dirty paths
415
+ if (prefix.length () > 2 && prefix.at (1 ) == QLatin1Char (' :' ) && prefix.at (0 ).isLetter ())
416
+ prefix[0 ] = QLatin1Char (' Y' );
417
+ #else
405
418
prefix = directory;
406
- if (prefix.length () && !prefix.endsWith (QLatin1Char (' /' )))
407
- prefix += QLatin1Char (' /' );
419
+ #endif
420
+ if (prefix.length () && !prefix.endsWith (QLatin1Char (' /' )))
421
+ prefix += QLatin1Char (' /' );
408
422
}
409
423
424
+ #ifdef Q_OS_SYMBIAN
425
+ QString nativePrefix = QDir::toNativeSeparators (prefix);
426
+ #endif
427
+
410
428
QString fname = filename;
411
429
QString realname;
412
430
QString delims;
@@ -415,6 +433,24 @@ bool QTranslator::load(const QString & filename, const QString & directory,
415
433
for (;;) {
416
434
QFileInfo fi;
417
435
436
+ #ifdef Q_OS_SYMBIAN
437
+ // search for translations on other drives, e.g. Qt may be in Z, while app is in C
438
+ // note this uses symbian search rules, i.e. y:->a:, followed by z:
439
+ TFindFile finder (qt_s60GetRFs ());
440
+ QString fname2 = fname + (suffix.isNull () ? QString::fromLatin1 (" .qm" ) : suffix);
441
+ TInt err = finder.FindByDir (
442
+ qt_QString2TPtrC (fname2),
443
+ qt_QString2TPtrC (nativePrefix));
444
+ if (err != KErrNone)
445
+ err = finder.FindByDir (qt_QString2TPtrC (fname), qt_QString2TPtrC (nativePrefix));
446
+ if (err == KErrNone) {
447
+ fi.setFile (qt_TDesC2QString (finder.File ()));
448
+ realname = fi.canonicalFilePath ();
449
+ if (fi.isReadable () && fi.isFile ())
450
+ break ;
451
+ }
452
+ #endif
453
+
418
454
realname = prefix + fname + (suffix.isNull () ? QString::fromLatin1 (" .qm" ) : suffix);
419
455
fi.setFile (realname);
420
456
if (fi.isReadable () && fi.isFile ())
0 commit comments