Added translation for plugins and added german language to LinksCloud. Recompile needed.

Changed the name and the description of the plugin to utf8.
Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4672 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-11-17 21:17:24 +00:00
parent 4d9727f47a
commit 8fc1a46ee7
19 changed files with 411 additions and 346 deletions

View file

@ -3,4 +3,5 @@ TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
libbitdht/src/libbitdht.pro \ libbitdht/src/libbitdht.pro \
libretroshare/src/libretroshare.pro \ libretroshare/src/libretroshare.pro \
retroshare-gui/src/RetroShare.pro retroshare-gui/src/RetroShare.pro \
plugins/plugins.pro

View file

@ -41,6 +41,8 @@ class MainPage ;
class QIcon ; class QIcon ;
class QString ; class QString ;
class QWidget ; class QWidget ;
class QTranslator;
class QApplication;
class RsCacheService ; class RsCacheService ;
class ftServer ; class ftServer ;
class pqiService ; class pqiService ;
@ -81,13 +83,14 @@ class RsPlugin
virtual MainPage *qt_page() const { return NULL ; } virtual MainPage *qt_page() const { return NULL ; }
virtual QWidget *qt_config_panel() const { return NULL ; } virtual QWidget *qt_config_panel() const { return NULL ; }
virtual QIcon *qt_icon() const { return NULL ; } virtual QIcon *qt_icon() const { return NULL ; }
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const { return NULL ; }
virtual std::string configurationFileName() const { return std::string() ; } virtual std::string configurationFileName() const { return std::string() ; }
virtual std::string getShortPluginDescription() const = 0 ; virtual std::string getShortPluginDescription() const = 0 ;
virtual std::string getPluginName() const = 0 ; virtual std::string getPluginName() const = 0 ;
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ; virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ;
virtual void setPlugInHandler(RsPluginHandler* pgHandler) = 0; virtual void setPlugInHandler(RsPluginHandler* pgHandler) = 0;
virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0; virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0;
}; };
class RsPluginHandler class RsPluginHandler

View file

@ -15,10 +15,10 @@ win32 {
MOC_DIR = temp/moc MOC_DIR = temp/moc
RCC_DIR = temp/qrc RCC_DIR = temp/qrc
UI_DIR = temp/ui UI_DIR = temp/ui
DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW
DEFINES *= MINIUPNPC_VERSION=13 DEFINES *= MINIUPNPC_VERSION=13
DESTDIR = lib # DESTDIR = lib
# Switch off optimization for release version # Switch off optimization for release version
QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE -= -O2

View file

@ -55,7 +55,7 @@ AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
// if(link.valid() && link.type() == RetroShareLink::TYPE_FILE) // if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
// ui.titleLineEdit->setText(link.name()); // ui.titleLineEdit->setText(link.name());
// else // else
ui.titleLineEdit->setText("New File"); ui.titleLineEdit->setText(tr("New Link"));
load(); load();

View file

@ -1,6 +1,6 @@
!include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri") !include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
CONFIG += qt uic qrc release resources CONFIG += qt uic qrc resources
SOURCES = p3ranking.cc LinksDialog.cpp rsrankitems.cc AddLinksDialog.cpp LinksCloudPlugin.cpp SOURCES = p3ranking.cc LinksDialog.cpp rsrankitems.cc AddLinksDialog.cpp LinksCloudPlugin.cpp
HEADERS = rsrank.h p3ranking.h LinksDialog.h rsrankitems.h AddLinksDialog.h LinksCloudPlugin.h HEADERS = rsrank.h p3ranking.h LinksDialog.h rsrankitems.h AddLinksDialog.h LinksCloudPlugin.h
@ -8,4 +8,4 @@ FORMS = LinksDialog.ui AddLinksDialog.ui
TARGET = LinksCloud TARGET = LinksCloud
RESOURCES = linksCloud_images.qrc RESOURCES = linksCloud_images.qrc lang/lang.qrc

View file

@ -1,4 +1,5 @@
#include <retroshare/rsplugin.h> #include <retroshare/rsplugin.h>
#include <QTranslator>
#include "LinksCloudPlugin.h" #include "LinksCloudPlugin.h"
#include "LinksDialog.h" #include "LinksDialog.h"
@ -77,7 +78,25 @@ QIcon *LinksCloudPlugin::qt_icon() const
std::string LinksCloudPlugin::getShortPluginDescription() const std::string LinksCloudPlugin::getShortPluginDescription() const
{ {
return "This plugin provides a set of cached links, and a voting system to promote them." ; return QApplication::translate("LinksCloudPlugin", "This plugin provides a set of cached links, and a voting system to promote them.").toUtf8().constData();
} }
std::string LinksCloudPlugin::getPluginName() const
{
return QApplication::translate("LinksCloudPlugin", "LinksCloud").toUtf8().constData();
}
QTranslator* LinksCloudPlugin::qt_translator(QApplication *app, const QString& languageCode) const
{
if (languageCode == "en") {
return NULL;
}
QTranslator* translator = new QTranslator(app);
if (translator->load(":/lang/LinksCloud_" + languageCode + ".qm")) {
return translator;
}
delete(translator);
return NULL;
}

View file

@ -14,21 +14,22 @@ 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 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);
virtual std::string configurationFileName() const { return std::string() ; } virtual std::string configurationFileName() const { return std::string() ; }
virtual std::string getShortPluginDescription() const ; virtual std::string getShortPluginDescription() const ;
virtual std::string getPluginName() const { return "LinksCloud" ; } virtual std::string getPluginName() const;
virtual void setInterfaces(RsPlugInInterfaces& interfaces); virtual void setInterfaces(RsPlugInInterfaces& interfaces);
private: private:
mutable p3Ranking *mRanking ; mutable p3Ranking *mRanking ;
mutable RsPluginHandler *mPlugInHandler; mutable RsPluginHandler *mPlugInHandler;
mutable RsFiles* mFiles; mutable RsFiles* mFiles;
mutable RsPeers* mPeers; mutable RsPeers* mPeers;
mutable MainPage *mainpage ; mutable MainPage* mainpage ;
mutable QIcon *mIcon ; mutable QIcon* mIcon ;
}; };

View file

@ -1,7 +1,7 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
calendar_plugin puzzle_plugin qcheckers_plugin qdiagram_plugin calendar_plugin puzzle_plugin qcheckers_plugin qdiagram_plugin LinksCloud

View file

@ -290,7 +290,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
icon = QIcon(":images/extension_48.png") ; icon = QIcon(":images/extension_48.png") ;
std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl; std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl;
ui.stackPages->add(rsPlugins->plugin(i)->qt_page(), createPageAction(icon, QString::fromStdString(rsPlugins->plugin(i)->getPluginName()), grp)); ui.stackPages->add(rsPlugins->plugin(i)->qt_page(), createPageAction(icon, QString::fromUtf8(rsPlugins->plugin(i)->getPluginName().c_str()), grp));
} }
else if(rsPlugins->plugin(i) == NULL) else if(rsPlugins->plugin(i) == NULL)
std::cerr << " No plugin object !" << std::endl; std::cerr << " No plugin object !" << std::endl;

View file

@ -1,280 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>PluginItem</class> <class>PluginItem</class>
<widget class="QWidget" name="PluginItem"> <widget class="QWidget" name="PluginItem">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>519</width> <width>519</width>
<height>185</height> <height>185</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <layout class="QVBoxLayout" name="verticalLayout_7">
<string>Form</string> <item>
</property> <widget class="QFrame" name="frame">
<layout class="QVBoxLayout" name="verticalLayout_7"> <property name="enabled">
<item> <bool>true</bool>
<widget class="QFrame" name="frame"> </property>
<property name="enabled"> <property name="sizePolicy">
<bool>true</bool> <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
</property> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="Expanding" vsizetype="Maximum"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="styleSheet">
</sizepolicy> <string notr="true">QFrame#frame{border: 2px solid green;
</property> background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
<property name="styleSheet"> stop: 0 #62E0B1, stop: 1 #8EFFD3);
<string notr="true">QFrame#frame{border: 2px solid green; border-radius: 0px}</string>
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, </property>
stop: 0 #62E0B1, stop: 1 #8EFFD3); <property name="frameShape">
border-radius: 0px}</string> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShape"> <property name="frameShadow">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="frameShadow"> <layout class="QVBoxLayout" name="verticalLayout_6">
<enum>QFrame::Raised</enum> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout_6"> <item>
<item> <layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <property name="sizeConstraint">
<item> <enum>QLayout::SetDefaultConstraint</enum>
<layout class="QVBoxLayout" name="verticalLayout_4"> </property>
<property name="sizeConstraint"> <item>
<enum>QLayout::SetDefaultConstraint</enum> <widget class="QPushButton" name="_pluginIcon">
</property> <property name="sizePolicy">
<item> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<widget class="QPushButton" name="_pluginIcon"> <horstretch>48</horstretch>
<property name="sizePolicy"> <verstretch>48</verstretch>
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> </sizepolicy>
<horstretch>48</horstretch> </property>
<verstretch>48</verstretch> <property name="minimumSize">
</sizepolicy> <size>
</property> <width>48</width>
<property name="minimumSize"> <height>48</height>
<size> </size>
<width>48</width> </property>
<height>48</height> <property name="maximumSize">
</size> <size>
</property> <width>48</width>
<property name="maximumSize"> <height>48</height>
<size> </size>
<width>48</width> </property>
<height>48</height> <property name="text">
</size> <string/>
</property> </property>
<property name="text"> <property name="iconSize">
<string/> <size>
</property> <width>24</width>
<property name="iconSize"> <height>24</height>
<size> </size>
<width>24</width> </property>
<height>24</height> <property name="flat">
</size> <bool>true</bool>
</property> </property>
<property name="flat"> </widget>
<bool>true</bool> </item>
</property> <item>
</widget> <spacer name="verticalSpacer_2">
</item> <property name="orientation">
<item> <enum>Qt::Vertical</enum>
<spacer name="verticalSpacer_2"> </property>
<property name="orientation"> <property name="sizeHint" stdset="0">
<enum>Qt::Vertical</enum> <size>
</property> <width>20</width>
<property name="sizeHint" stdset="0"> <height>40</height>
<size> </size>
<width>20</width> </property>
<height>40</height> </spacer>
</size> </item>
</property> </layout>
</spacer> </item>
</item> <item>
</layout> <layout class="QVBoxLayout" name="verticalLayout_5">
</item> <item>
<item> <widget class="QLabel" name="subjectLabel">
<layout class="QVBoxLayout" name="verticalLayout_5"> <property name="sizePolicy">
<item> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<widget class="QLabel" name="subjectLabel"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="font">
</sizepolicy> <font>
</property> <pointsize>11</pointsize>
<property name="font"> <weight>75</weight>
<font> <bold>true</bold>
<pointsize>11</pointsize> </font>
<weight>75</weight> </property>
<bold>true</bold> <property name="text">
</font> <string notr="true">subjectLabel</string>
</property> </property>
<property name="text"> <property name="wordWrap">
<string notr="true">subjectLabel</string> <bool>true</bool>
</property> </property>
<property name="wordWrap"> </widget>
<bool>true</bool> </item>
</property> <item>
</widget> <layout class="QHBoxLayout" name="horizontalLayout_2">
</item> <item>
<item> <layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <item>
<item> <widget class="QLabel" name="label_2">
<layout class="QVBoxLayout" name="verticalLayout_3"> <property name="text">
<item> <string>Status: </string>
<widget class="QLabel" name="label_2"> </property>
<property name="text"> </widget>
<string>Status: </string> </item>
</property> <item>
</widget> <widget class="QLabel" name="label">
</item> <property name="text">
<item> <string>File hash:</string>
<widget class="QLabel" name="label"> </property>
<property name="text"> </widget>
<string>File hash:</string> </item>
</property> <item>
</widget> <widget class="QLabel" name="label_5">
</item> <property name="text">
<item> <string>File name: </string>
<widget class="QLabel" name="label_5"> </property>
<property name="text"> </widget>
<string>File name: </string> </item>
</property> </layout>
</widget> </item>
</item> <item>
</layout> <layout class="QVBoxLayout" name="verticalLayout_2">
</item> <item>
<item> <widget class="QLabel" name="_statusLabel">
<layout class="QVBoxLayout" name="verticalLayout_2"> <property name="sizePolicy">
<item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<widget class="QLabel" name="_statusLabel"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="text">
</sizepolicy> <string notr="true">TextLabel</string>
</property> </property>
<property name="text"> </widget>
<string>TextLabel</string> </item>
</property> <item>
</widget> <widget class="QLabel" name="_hashLabel">
</item> <property name="sizePolicy">
<item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<widget class="QLabel" name="_hashLabel"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="text">
</sizepolicy> <string notr="true">TextLabel</string>
</property> </property>
<property name="text"> </widget>
<string>TextLabel</string> </item>
</property> <item>
</widget> <widget class="QLabel" name="_name_LE">
</item> <property name="sizePolicy">
<item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<widget class="QLabel" name="_name_LE"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="text">
</sizepolicy> <string notr="true">TextLabel</string>
</property> </property>
<property name="text"> </widget>
<string>TextLabel</string> </item>
</property> </layout>
</widget> </item>
</item> </layout>
</layout> </item>
</item> <item>
</layout> <spacer name="verticalSpacer">
</item> <property name="orientation">
<item> <enum>Qt::Vertical</enum>
<spacer name="verticalSpacer"> </property>
<property name="orientation"> <property name="sizeHint" stdset="0">
<enum>Qt::Vertical</enum> <size>
</property> <width>20</width>
<property name="sizeHint" stdset="0"> <height>40</height>
<size> </size>
<width>20</width> </property>
<height>40</height> </spacer>
</size> </item>
</property> </layout>
</spacer> </item>
</item> </layout>
</layout> </item>
</item> <item>
</layout> <layout class="QHBoxLayout" name="horizontalLayout">
</item> <item>
<item> <widget class="QFrame" name="expandFrame">
<layout class="QHBoxLayout" name="horizontalLayout"> <property name="frameShape">
<item> <enum>QFrame::StyledPanel</enum>
<widget class="QFrame" name="expandFrame"> </property>
<property name="frameShape"> <property name="frameShadow">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="frameShadow"> <layout class="QVBoxLayout" name="_2">
<enum>QFrame::Raised</enum> <item>
</property> <widget class="QLabel" name="msgLabel">
<layout class="QVBoxLayout" name="_2"> <property name="sizePolicy">
<item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<widget class="QLabel" name="msgLabel"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="text">
</sizepolicy> <string notr="true">Long
</property> message here</string>
<property name="text"> </property>
<string notr="true">Long <property name="wordWrap">
message here</string> <bool>true</bool>
</property> </property>
<property name="wordWrap"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openExternalLinks"> </widget>
<bool>true</bool> </item>
</property> </layout>
</widget> </widget>
</item> </item>
</layout> <item>
</widget> <layout class="QVBoxLayout" name="verticalLayout">
</item> <item>
<item> <widget class="QPushButton" name="_configure_PB">
<layout class="QVBoxLayout" name="verticalLayout"> <property name="toolTip">
<item> <string>Launch configuration panel, if provided by the plugin</string>
<widget class="QPushButton" name="_configure_PB"> </property>
<property name="toolTip"> <property name="text">
<string>Launch configuration panel, if provided by the plugin</string> <string>Configure</string>
</property> </property>
<property name="text"> </widget>
<string>Configure</string> </item>
</property> <item>
</widget> <widget class="QCheckBox" name="_enabled_CB">
</item> <property name="toolTip">
<item> <string>Add the plugin into the white list of accepted plugins. This will be effective after you restart RetroShare, since plugins need to be loaded at startup.</string>
<widget class="QCheckBox" name="_enabled_CB"> </property>
<property name="toolTip"> <property name="text">
<string>Add the plugin into the white list of accepted plugins. This will be effective after you restart RetroShare, since plugins need to be loaded at startup.</string> <string>Enabled</string>
</property> </property>
<property name="text"> </widget>
<string>Enabled</string> </item>
</property> </layout>
</widget> </item>
</item> </layout>
</layout> </item>
</item> </layout>
</layout> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> <resources/>
</layout> <connections/>
</widget> </ui>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -78,8 +78,8 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WFlags flags)
if(plugin->qt_icon() != NULL) if(plugin->qt_icon() != NULL)
plugin_icon = *plugin->qt_icon() ; plugin_icon = *plugin->qt_icon() ;
pluginTitle = QString::fromStdString(plugin->getPluginName()) ; pluginTitle = QString::fromUtf8(plugin->getPluginName().c_str()) ;
pluginDescription = QString::fromStdString(plugin->getShortPluginDescription()) ; pluginDescription = QString::fromUtf8(plugin->getShortPluginDescription().c_str()) ;
} }
PluginItem *item = new PluginItem(i,pluginTitle,pluginDescription,status_string, PluginItem *item = new PluginItem(i,pluginTitle,pluginDescription,status_string,
@ -107,6 +107,9 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WFlags flags)
text += "<b>"+QString::fromStdString(dirs[i]) + "</b><br>" ; text += "<b>"+QString::fromStdString(dirs[i]) + "</b><br>" ;
ui._lookupDirectories_TB->setHtml(text) ; ui._lookupDirectories_TB->setHtml(text) ;
// todo
ui.enableAll->setEnabled(false);
} }
void PluginsPage::configurePlugin(int i) void PluginsPage::configurePlugin(int i)
{ {

View file

@ -540,7 +540,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="checkBox"> <widget class="QCheckBox" name="enableAll">
<property name="text"> <property name="text">
<string>Authorize all plugins</string> <string>Authorize all plugins</string>
</property> </property>

View file

@ -24,9 +24,11 @@
#include <QLocale> #include <QLocale>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <rshare.h> #include <rshare.h>
#include <retroshare/rsplugin.h>
#include "languagesupport.h" #include "languagesupport.h"
static QMap<RsPlugin*, QTranslator*> translatorPlugins;
/** Initializes the list of available languages. */ /** Initializes the list of available languages. */
QMap<QString, QString> QMap<QString, QString>
@ -117,6 +119,19 @@ LanguageSupport::isRightToLeft(const QString &languageCode)
|| !languageCode.compare("fa", Qt::CaseInsensitive) || !languageCode.compare("fa", Qt::CaseInsensitive)
|| !languageCode.compare("he", Qt::CaseInsensitive)); || !languageCode.compare("he", Qt::CaseInsensitive));
} }
static void removePluginTranslation()
{
QMap<RsPlugin*, QTranslator*>::iterator it;
for (it = translatorPlugins.begin(); it != translatorPlugins.end(); ++it) {
if (it.value()) {
QApplication::removeTranslator(it.value());
delete(it.value());
}
}
translatorPlugins.clear();
}
/** Sets the application's translator to the specified language. */ /** Sets the application's translator to the specified language. */
bool bool
LanguageSupport::translate(const QString &languageCode) LanguageSupport::translate(const QString &languageCode)
@ -130,6 +145,8 @@ LanguageSupport::translate(const QString &languageCode)
QApplication::removeTranslator(retroshareTranslator); QApplication::removeTranslator(retroshareTranslator);
delete(retroshareTranslator); delete(retroshareTranslator);
retroshareTranslator = NULL; retroshareTranslator = NULL;
removePluginTranslation();
} }
if (languageCode == "en") if (languageCode == "en")
@ -156,11 +173,40 @@ LanguageSupport::translate(const QString &languageCode)
retroshareTranslator = new QTranslator(rApp); retroshareTranslator = new QTranslator(rApp);
Q_CHECK_PTR(retroshareTranslator); Q_CHECK_PTR(retroshareTranslator);
bool result = true;
if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) { if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) {
QApplication::installTranslator(retroshareTranslator); QApplication::installTranslator(retroshareTranslator);
return true; } else {
delete retroshareTranslator;
retroshareTranslator = NULL;
result = false;
} }
delete retroshareTranslator;
retroshareTranslator = NULL; result = translatePlugins(languageCode) && result;
return false;
return result;
}
/** Sets the application's translator to the specified language for the plugins. */
bool LanguageSupport::translatePlugins(const QString &languageCode)
{
removePluginTranslation();
if (rsPlugins == NULL) {
return true;
}
int count = rsPlugins->nbPlugins();
for (int i = 0; i < count; ++i) {
RsPlugin* plugin = rsPlugins->plugin(i);
if (plugin) {
QTranslator* translator = plugin->qt_translator(rApp, languageCode);
if (translator) {
QApplication::installTranslator(translator);
translatorPlugins[plugin] = translator;
}
}
}
return true;
} }

View file

@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#ifndef _LANGUAGESUPPORT_H #ifndef _LANGUAGESUPPORT_H
#define _LANGUAGESUPPORT_H #define _LANGUAGESUPPORT_H
@ -29,8 +27,6 @@
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
class LanguageSupport class LanguageSupport
{ {
public: public:
@ -52,7 +48,8 @@ public:
static bool isRightToLeft(const QString &languageCode); static bool isRightToLeft(const QString &languageCode);
/** Sets the application's translator to the specified language. */ /** Sets the application's translator to the specified language. */
static bool translate(const QString &languageCode); static bool translate(const QString &languageCode);
/** Sets the application's translator to the specified language for the plugins. */
static bool translatePlugins(const QString &languageCode);
}; };
#endif #endif

View file

@ -8849,51 +8849,43 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>PluginItem</name> <name>PluginItem</name>
<message> <message>
<location filename="../gui/settings/PluginItem.ui" line="+14"/>
<source>Form</source> <source>Form</source>
<translation type="unfinished">Formular</translation> <translation type="obsolete">Formular</translation>
</message> </message>
<message> <message>
<location line="+115"/> <location filename="../gui/settings/PluginItem.ui" line="+126"/>
<source>Status: </source> <source>Status: </source>
<translation type="unfinished"></translation> <translation>Status:</translation>
</message> </message>
<message> <message>
<location line="+7"/> <location line="+7"/>
<source>File hash:</source> <source>File hash:</source>
<translation type="unfinished"></translation> <translation>Datei Prüfsumme:</translation>
</message> </message>
<message> <message>
<location line="+7"/> <location line="+7"/>
<source>File name: </source> <source>File name: </source>
<translation type="unfinished"></translation> <translation>Dateiname:</translation>
</message> </message>
<message> <message>
<location line="+17"/> <location line="+107"/>
<location line="+13"/>
<location line="+13"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+64"/>
<source>Launch configuration panel, if provided by the plugin</source> <source>Launch configuration panel, if provided by the plugin</source>
<translation type="unfinished"></translation> <translation>Starte Einstellungen, wenn vom Plugin unterstützt</translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>Configure</source> <source>Configure</source>
<translation type="unfinished"></translation> <translation>Einstellung</translation>
</message> </message>
<message> <message>
<location line="+7"/> <location line="+7"/>
<source>Add the plugin into the white list of accepted plugins. This will be effective after you restart RetroShare, since plugins need to be loaded at startup.</source> <source>Add the plugin into the white list of accepted plugins. This will be effective after you restart RetroShare, since plugins need to be loaded at startup.</source>
<translation type="unfinished"></translation> <translation>Fügt das Plugin als vertrauenswürdig hinzu. Das wirkt sich nach dem Neustart von RetroShare aus, da die Plugins beim Start geladen werden.</translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>Enabled</source> <source>Enabled</source>
<translation type="unfinished"></translation> <translation>Aktivieren</translation>
</message> </message>
</context> </context>
<context> <context>
@ -8919,57 +8911,57 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location filename="../gui/settings/PluginsPage.ui" line="+519"/> <location filename="../gui/settings/PluginsPage.ui" line="+519"/>
<source>Loaded plugins</source> <source>Loaded plugins</source>
<translation type="unfinished"></translation> <translation>Geladene Plugins</translation>
</message> </message>
<message> <message>
<location line="+26"/> <location line="+26"/>
<source>Authorize all plugins</source> <source>Authorize all plugins</source>
<translation type="unfinished"></translation> <translation>Erlaube alle Plugins</translation>
</message> </message>
<message> <message>
<location line="+7"/> <location line="+7"/>
<source>Plugin look-up directories</source> <source>Plugin look-up directories</source>
<translation type="unfinished"></translation> <translation>Plugin Verzeichnis</translation>
</message> </message>
<message> <message>
<location filename="../gui/settings/PluginsPage.cpp" line="+57"/> <location filename="../gui/settings/PluginsPage.cpp" line="+57"/>
<source>Hash rejected. Add to white list.</source> <source>Hash rejected. Add to white list.</source>
<translation type="unfinished"></translation> <translation>Hash abgelehnt. Füge das Plugin als vertrauenswürdig hinzu.</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Loading error.</source> <source>Loading error.</source>
<translation type="unfinished"></translation> <translation>Fehler beim Laden.</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Missing symbol. Wrong version?</source> <source>Missing symbol. Wrong version?</source>
<translation type="unfinished"></translation> <translation>Fehlendes Symbol. Falsche Version?</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>No plugin object</source> <source>No plugin object</source>
<translation type="unfinished"></translation> <translation>Kein Plugin Objekt</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
<source>Plugins is loaded.</source> <source>Plugins is loaded.</source>
<translation type="unfinished"></translation> <translation>Plugin ist geladen.</translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>Unknown status.</source> <source>Unknown status.</source>
<translation type="unfinished"></translation> <translation>Unbekannter Status.</translation>
</message> </message>
<message> <message>
<location line="+5"/> <location line="+5"/>
<source>Title unavailable</source> <source>Title unavailable</source>
<translation type="unfinished"></translation> <translation>Titel nicht verfügbar</translation>
</message> </message>
<message> <message>
<location line="+1"/> <location line="+1"/>
<source>Description unavailable</source> <source>Description unavailable</source>
<translation type="unfinished"></translation> <translation>Beschreibung nicht verfügbar</translation>
</message> </message>
</context> </context>
<context> <context>
@ -10050,7 +10042,7 @@ Lockdatei:
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/common/RsCollectionDialog.cpp" line="+136"/> <location filename="../gui/common/RsCollectionDialog.cpp" line="+179"/>
<source>Unable to make path</source> <source>Unable to make path</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -10484,7 +10476,7 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>RsCollectionDialog</name> <name>RsCollectionDialog</name>
<message> <message>
<location filename="../gui/common/RsCollectionDialog.cpp" line="-95"/> <location filename="../gui/common/RsCollectionDialog.cpp" line="-135"/>
<source>File</source> <source>File</source>
<translation>Datei</translation> <translation>Datei</translation>
</message> </message>
@ -10504,7 +10496,7 @@ p, li { white-space: pre-wrap; }
<translation>Kollektion</translation> <translation>Kollektion</translation>
</message> </message>
<message> <message>
<location line="+14"/> <location line="+17"/>
<source>File name :</source> <source>File name :</source>
<translation>Dateiname:</translation> <translation>Dateiname:</translation>
</message> </message>
@ -10519,7 +10511,7 @@ p, li { white-space: pre-wrap; }
<translation>Ausgewählt:</translation> <translation>Ausgewählt:</translation>
</message> </message>
<message> <message>
<location line="+86"/> <location line="+92"/>
<source>Select all</source> <source>Select all</source>
<translation>Alle auswählen</translation> <translation>Alle auswählen</translation>
</message> </message>

View file

@ -219,6 +219,7 @@ int main(int argc, char *argv[])
splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom);
rsicontrol->StartupRetroShare(); rsicontrol->StartupRetroShare();
Rshare::initPlugins();
splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom);

View file

@ -308,7 +308,7 @@ Rshare::setLanguage(QString languageCode)
if (languageCode.isEmpty()) { if (languageCode.isEmpty()) {
languageCode = Settings->getLanguageCode(); languageCode = Settings->getLanguageCode();
} }
/* Translate into the desired langauge */ /* Translate into the desired language */
if (LanguageSupport::translate(languageCode)) { if (LanguageSupport::translate(languageCode)) {
_language = languageCode; _language = languageCode;
return true; return true;
@ -345,7 +345,6 @@ Rshare::setSheet(QString sheet)
/* Apply the specified GUI stylesheet */ /* Apply the specified GUI stylesheet */
_stylesheet = sheet; _stylesheet = sheet;
return true; return true;
} }
void Rshare::resetLanguageAndStyle() void Rshare::resetLanguageAndStyle()
@ -360,6 +359,12 @@ void Rshare::resetLanguageAndStyle()
setSheet(_args.value(ARG_GUISTYLESHEET)); setSheet(_args.value(ARG_GUISTYLESHEET));
} }
/** Initialize plugins. */
void Rshare::initPlugins()
{
LanguageSupport::translatePlugins(_language);
}
/** Returns the directory RetroShare uses for its data files. */ /** Returns the directory RetroShare uses for its data files. */
QString QString
Rshare::dataDirectory() Rshare::dataDirectory()

View file

@ -84,6 +84,8 @@ public:
*/ */
static void resetLanguageAndStyle(); static void resetLanguageAndStyle();
/** Initialize plugins. */
static void initPlugins();
/** Returns the current language. */ /** Returns the current language. */
static QString language() { return _language; } static QString language() { return _language; }