mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-30 17:20:32 +01:00
2022-09-28 Fred Gleason <fredg@paravelsystems.com>
* Added an 'RDTranslator' class. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -269,6 +269,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
||||
rdtrackermodel.cpp rdtrackermodel.h\
|
||||
rdtrackertableview.cpp rdtrackertableview.h\
|
||||
rdtrackerwidget.cpp rdtrackerwidget.h\
|
||||
rdtranslator.cpp rdtranslator.h\
|
||||
rdtransportbutton.cpp rdtransportbutton.h\
|
||||
rdtransfer.cpp rdtransfer.h\
|
||||
rdtreeview.cpp rdtreeview.h\
|
||||
@@ -427,6 +428,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
|
||||
moc_rdtrackertableview.cpp\
|
||||
moc_rdtrackerwidget.cpp\
|
||||
moc_rdtransfer.cpp\
|
||||
moc_rdtranslator.cpp\
|
||||
moc_rdtransportbutton.cpp\
|
||||
moc_rdtreeview.cpp\
|
||||
moc_rdtrimaudio.cpp\
|
||||
|
||||
@@ -208,6 +208,7 @@ SOURCES += rdtrackereditdialog.cpp
|
||||
SOURCES += rdtrackermodel.cpp
|
||||
SOURCES += rdtrackertableview.cpp
|
||||
SOURCES += rdtrackerwidget.cpp
|
||||
SOURCES += rdtranslator.cpp
|
||||
SOURCES += rdtransportbutton.cpp
|
||||
SOURCES += rdtreeview.cpp
|
||||
SOURCES += rdtty.cpp
|
||||
@@ -399,6 +400,7 @@ HEADERS += rdtrackereditdialog.h
|
||||
HEADERS += rdtrackermodel.h
|
||||
HEADERS += rdtrackertableview.h
|
||||
HEADERS += rdtrackerwidget.h
|
||||
HEADERS += rdtranslator.h
|
||||
HEADERS += rdtransportbutton.h
|
||||
HEADERS += rdtreeview.h
|
||||
HEADERS += rdtty.h
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Base Application Class
|
||||
//
|
||||
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2022 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -24,11 +24,13 @@
|
||||
#include <QApplication>
|
||||
#include <QProcess>
|
||||
#include <QStyleFactory>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "dbversion.h"
|
||||
#include "rdapplication.h"
|
||||
#include "rdcmd_switch.h"
|
||||
#include "rdescape_string.h"
|
||||
#include "rdtranslator.h"
|
||||
|
||||
RDCoreApplication *rdc=NULL;
|
||||
QStringList __rdapplication_temp_files;
|
||||
@@ -76,6 +78,11 @@ RDCoreApplication::RDCoreApplication(const QString &module_name,
|
||||
app_short_date_format=RD_DEFAULT_SHORT_DATE_FORMAT;
|
||||
app_show_twelve_hour_time=false;
|
||||
|
||||
//
|
||||
// Translations
|
||||
//
|
||||
rdt=new RDTranslator(app_command_name,this);
|
||||
|
||||
atexit(__RDCoreApplication_ExitCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Base Application Class
|
||||
//
|
||||
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2022 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -24,8 +24,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qstringlist.h>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include <rdairplay_conf.h>
|
||||
#include <rdcae.h>
|
||||
|
||||
54
lib/rdtranslator.cpp
Normal file
54
lib/rdtranslator.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// rdtranslate.cpp
|
||||
//
|
||||
// Load translation objects for Rivendell
|
||||
//
|
||||
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
// version 2 as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "rdapplication.h"
|
||||
#include "rdtranslator.h"
|
||||
|
||||
RDTranslator *rdt=NULL;
|
||||
|
||||
RDTranslator::RDTranslator(const QString &cmdname,QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
d_command_name=cmdname;
|
||||
|
||||
QString loc=RDApplication::locale().left(2)+".qm";
|
||||
LoadTranslation("qt_"+loc,"/usr/share/qt5/translations");
|
||||
LoadTranslation("librd_"+loc,"/usr/share/rivendell");
|
||||
LoadTranslation("rdhpi_"+loc,"/usr/share/rivendell");
|
||||
LoadTranslation(d_command_name+"_"+loc,"/usr/share/rivendell");
|
||||
}
|
||||
|
||||
|
||||
bool RDTranslator::LoadTranslation(const QString &filename,
|
||||
const QString &dirname)
|
||||
{
|
||||
QTranslator *qt=new QTranslator(0);
|
||||
if(!qt->load(filename,dirname)) {
|
||||
fprintf(stderr,"%s: failed to load translation file \"%s/%s\"\n",
|
||||
d_command_name.toUtf8().constData(),
|
||||
dirname.toUtf8().constData(),
|
||||
filename.toUtf8().constData());
|
||||
delete qt;
|
||||
return false;
|
||||
}
|
||||
return qApp->installTranslator(qt);
|
||||
}
|
||||
39
lib/rdtranslator.h
Normal file
39
lib/rdtranslator.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// rdtranslate.h
|
||||
//
|
||||
// Load translation objects for Rivendell
|
||||
//
|
||||
// (C) Copyright 2022 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
// version 2 as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef RDTRANSLATE_H
|
||||
#define RDTRANSLATE_H
|
||||
|
||||
#include <QTranslator>
|
||||
|
||||
class RDTranslator : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
RDTranslator(const QString &cmdname,QObject *parent=0);
|
||||
|
||||
private:
|
||||
bool LoadTranslation(const QString &filename,const QString &dirname);
|
||||
QString d_command_name;
|
||||
};
|
||||
|
||||
extern RDTranslator *rdt;
|
||||
|
||||
#endif // RDTRANSLATE_H
|
||||
Reference in New Issue
Block a user