Browse Source

Load configuration translation files

Neal Wilson 8 years ago
parent
commit
cef02089a7
1 changed files with 13 additions and 6 deletions
  1. 13
    6
      src/typica.w

+ 13
- 6
src/typica.w View File

4339
     QFile file(filename);
4339
     QFile file(filename);
4340
     QFileInfo info(filename);
4340
     QFileInfo info(filename);
4341
     directory = info.dir();
4341
     directory = info.dir();
4342
+    QTranslator *configtr = new QTranslator;
4343
+    if(configtr->load(QString("config.%1").arg(QLocale::system().name()),
4344
+                     QString("%1/Translations").arg(directory.canonicalPath())))
4345
+    {
4346
+        QCoreApplication::installTranslator(configtr);
4347
+    }
4342
     settings.setValue("config", directory.path());
4348
     settings.setValue("config", directory.path());
4343
     if(file.open(QIODevice::ReadOnly))
4349
     if(file.open(QIODevice::ReadOnly))
4344
     {
4350
     {
5419
     QString text =
5425
     QString text =
5420
         QCoreApplication::translate(element.attribute("trcontext").toAscii().data(),
5426
         QCoreApplication::translate(element.attribute("trcontext").toAscii().data(),
5421
                                     element.attribute("name").toUtf8().data());
5427
                                     element.attribute("name").toUtf8().data());
5428
+    qDebug() << element.attribute("name").toUtf8().data() << "translated to" << text << "using context" << element.attribute("trcontext").toAscii().data();
5422
     if(element.hasAttribute("type"))
5429
     if(element.hasAttribute("type"))
5423
     {
5430
     {
5424
         QString type = element.attribute("type");
5431
         QString type = element.attribute("type");
12606
 details, see the Qt Linguist manual.
12613
 details, see the Qt Linguist manual.
12607
 
12614
 
12608
 @<Load translation objects@>=
12615
 @<Load translation objects@>=
12609
-QTranslator base;
12610
-if(base.load(QString("qt_%1").arg(QLocale::system().name())))
12616
+QTranslator *base = new QTranslator;
12617
+if(base->load(QString("qt_%1").arg(QLocale::system().name())))
12611
 {
12618
 {
12612
-    installTranslator(&base);
12619
+    installTranslator(base);
12613
 }
12620
 }
12614
-QTranslator app;
12615
-if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
12621
+QTranslator *app = new QTranslator;
12622
+if(app->load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
12616
 {
12623
 {
12617
-    installTranslator(&app);
12624
+    installTranslator(app);
12618
 }
12625
 }
12619
 
12626
 
12620
 @ We also want to be able to access the application instance from within the
12627
 @ We also want to be able to access the application instance from within the

Loading…
Cancel
Save