Changed the path for the external translations to "data dir/translations".

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5670 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-12 18:44:02 +00:00
parent 85070b1b66
commit a0162ced8f
7 changed files with 17 additions and 11 deletions

View File

@ -130,7 +130,7 @@ class RsPlugin
// //
virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const { return NULL ; } virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const { return NULL ; }
virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */ ) const { return NULL ; } virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */, const QString& /* externalDir */ ) const { return NULL ; }
// //
//========================== Plugin Description ==============================// //========================== Plugin Description ==============================//

View File

@ -98,7 +98,7 @@ std::string LinksCloudPlugin::getPluginName() const
return QApplication::translate("LinksCloudPlugin", "LinksCloud").toUtf8().constData(); return QApplication::translate("LinksCloudPlugin", "LinksCloud").toUtf8().constData();
} }
QTranslator* LinksCloudPlugin::qt_translator(QApplication */*app*/, const QString& languageCode) const QTranslator* LinksCloudPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
{ {
if (languageCode == "en") { if (languageCode == "en") {
return NULL; return NULL;
@ -106,7 +106,7 @@ QTranslator* LinksCloudPlugin::qt_translator(QApplication */*app*/, const QStrin
QTranslator* translator = new QTranslator(); QTranslator* translator = new QTranslator();
if (translator->load(QCoreApplication::applicationDirPath() + "/translations/LinksCloud_" + languageCode + ".qm")) { if (translator->load(externalDir + "/LinksCloud_" + languageCode + ".qm")) {
return translator; return translator;
} else if (translator->load(":/lang/LinksCloud_" + languageCode + ".qm")) { } else if (translator->load(":/lang/LinksCloud_" + languageCode + ".qm")) {
return translator; return translator;

View File

@ -14,7 +14,7 @@ class LinksCloudPlugin: public RsPlugin
virtual MainPage *qt_page() const ; virtual MainPage *qt_page() const ;
virtual QIcon *qt_icon() const ; virtual QIcon *qt_icon() const ;
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_RANK ; } virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_RANK ; }
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const; virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode, const QString& externalDir) const;
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ; virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ;
virtual void setPlugInHandler(RsPluginHandler *pgHandler); virtual void setPlugInHandler(RsPluginHandler *pgHandler);

View File

@ -48,7 +48,8 @@ HEADERS = services/p3vors.h \
gui/AudioPopupChatDialog.h \ gui/AudioPopupChatDialog.h \
gui/PluginGUIHandler.h \ gui/PluginGUIHandler.h \
gui/PluginNotifier.h \ gui/PluginNotifier.h \
interface/rsvoip.h interface/rsvoip.h \
VOIPPlugin.h
FORMS = gui/AudioInputConfig.ui \ FORMS = gui/AudioInputConfig.ui \
gui/AudioStats.ui \ gui/AudioStats.ui \

View File

@ -157,7 +157,7 @@ std::string VOIPPlugin::getPluginName() const
return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData(); return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData();
} }
QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& languageCode) const QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
{ {
if (languageCode == "en") { if (languageCode == "en") {
return NULL; return NULL;
@ -165,7 +165,7 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan
QTranslator* translator = new QTranslator(); QTranslator* translator = new QTranslator();
if (translator->load(QCoreApplication::applicationDirPath() + "/translations/VOIP_" + languageCode + ".qm")) { if (translator->load(externalDir + "/VOIP_" + languageCode + ".qm")) {
return translator; return translator;
} else if (translator->load(":/lang/VOIP_" + languageCode + ".qm")) { } else if (translator->load(":/lang/VOIP_" + languageCode + ".qm")) {
return translator; return translator;

View File

@ -21,7 +21,7 @@ class VOIPPlugin: public RsPlugin
virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const ; virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const ;
virtual QIcon *qt_icon() const; virtual QIcon *qt_icon() const;
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const; virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode, const QString& externalDir) const;
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ; virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ;
virtual void setPlugInHandler(RsPluginHandler *pgHandler); virtual void setPlugInHandler(RsPluginHandler *pgHandler);

View File

@ -25,11 +25,14 @@
#include <QLibraryInfo> #include <QLibraryInfo>
#include <rshare.h> #include <rshare.h>
#include <retroshare/rsplugin.h> #include <retroshare/rsplugin.h>
#include <retroshare/rsinit.h>
#include "languagesupport.h" #include "languagesupport.h"
static QMap<RsPlugin*, QTranslator*> translatorPlugins; static QMap<RsPlugin*, QTranslator*> translatorPlugins;
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsInit::getRetroshareDataDirectory().c_str())
/** Initializes the list of available languages. */ /** Initializes the list of available languages. */
QMap<QString, QString> QMap<QString, QString>
LanguageSupport::languages() LanguageSupport::languages()
@ -175,7 +178,7 @@ LanguageSupport::translate(const QString &languageCode)
bool result = true; bool result = true;
if (retroshareTranslator->load(QCoreApplication::applicationDirPath() + "/translations/retroshare_" + languageCode + ".qm")) { if (retroshareTranslator->load(EXTERNAL_TRANSLATION_DIR + "/translations/retroshare_" + languageCode + ".qm")) {
QApplication::installTranslator(retroshareTranslator); QApplication::installTranslator(retroshareTranslator);
} else if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) { } else if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) {
QApplication::installTranslator(retroshareTranslator); QApplication::installTranslator(retroshareTranslator);
@ -199,11 +202,13 @@ bool LanguageSupport::translatePlugins(const QString &languageCode)
return true; return true;
} }
QString externalDir = EXTERNAL_TRANSLATION_DIR + "/translations";
int count = rsPlugins->nbPlugins(); int count = rsPlugins->nbPlugins();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
RsPlugin* plugin = rsPlugins->plugin(i); RsPlugin* plugin = rsPlugins->plugin(i);
if (plugin) { if (plugin) {
QTranslator* translator = plugin->qt_translator(rApp, languageCode); QTranslator* translator = plugin->qt_translator(rApp, languageCode, externalDir);
if (translator) { if (translator) {
QApplication::installTranslator(translator); QApplication::installTranslator(translator);
translatorPlugins[plugin] = translator; translatorPlugins[plugin] = translator;