[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Patch for KAboutData for adding information about translators
From:       Matthias Kiefer <matthias.kiefer () gmx ! net>
Date:       2000-12-28 14:56:10
[Download RAW message or body]

Hi,

I would like to add the attached patches for KAboutData and for 
KAboutApplication. It brings the ability to show the translator(s) of the 
application in the aboutDialog. I think this will give some motivation to the 
translators ;-)
You can see, how the about dialogs looks like in this screenshot:
http://www.uni-karlsruhe.de/~Matthias.Kiefer/abouttranslator.png
The message about the translation teams is intended to get replaced about 
information about the translation team of the current language.

Please review and say if it is ok to commit. 


To enable showing the translators, one have to call 
KAboutData::setTranslator(const char *names, const char *emails) with some 
dummy text marked for translation, e.g. 
aboutData.setTranslator(I18N_NOOP("NAMES OF THE 
TRANSLATORS"),I18N_NOOP("EMAIL OF THE TRANSLATORS"));

Then the translators can replace this text with a comma separated list of 
names and email addresses. If there is no translation or the default language 
is used, then the texts are ignored and no translator page is shown in the 
about dialog.

I have added an additional class KAboutTranslator , because KAboutPerson uses 
internaly const char *, so there would be a memory leak when using it or one 
would have to keep a reference to the string in the object. Maybe someone has 
a idea how to solve this?

Additionaly I changed KAboutPerson to use QString::fromUtf8() instead of 
QString::fromLatin1(), so it is now possible to use non-latin1 characters in 
names of developers and others.

Please also have a look at  binary compatibility, because I had to add two 
private members to KAboutData and therefore had to create the private d 
pointer.

Comments are welcome.

kind regards,
   Matthias
-- 
Matthias Kiefer
E-Mail: matthias.kiefer@gmx.de

["kaboutapplication.patch" (text/plain)]

Index: kaboutapplication.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kaboutapplication.cpp,v
retrieving revision 1.6
diff -u -r1.6 kaboutapplication.cpp
--- kaboutapplication.cpp	2000/11/29 14:04:11	1.6
+++ kaboutapplication.cpp	2000/12/26 14:44:35
@@ -112,6 +112,25 @@
     }
   }
 
+  const QValueList<KAboutTranslator> translatorList = aboutData->translators();
+
+  if(translatorList.count() > 0)
+  {
+      KAboutContainer *translatorPage =
+          addScrolledContainerPage( i18n("T&ranslation") );
+
+      QValueList<KAboutTranslator>::ConstIterator it;
+      for(it = translatorList.begin(); it != translatorList.end(); ++it)
+      {
+          translatorPage->addPerson((*it).name(), (*it).emailAddress(),
+                  0,0);
+      }
+
+      QLabel *label = new QLabel(KAboutData::aboutTranslationTeam()
+              ,translatorPage);
+      translatorPage->addWidget(label);
+  }
+
   if (!aboutData->license().isEmpty() )
   {
     addLicensePage( i18n("&License agreement"), aboutData->license() );

["kaboutdata.patch" (text/plain)]

Index: kaboutdata.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kaboutdata.cpp,v
retrieving revision 1.10
diff -u -r1.10 kaboutdata.cpp
--- kaboutdata.cpp	2000/08/05 05:30:16	1.10
+++ kaboutdata.cpp	2000/12/26 14:44:53
@@ -29,7 +29,7 @@
 QString
 KAboutPerson::name() const
 {
-   return QString::fromLatin1(mName);
+   return QString::fromUtf8(mName);
 }
 
 QString
@@ -44,16 +44,47 @@
 QString
 KAboutPerson::emailAddress() const
 {
-   return QString::fromLatin1(mEmailAddress);
+   return QString::fromUtf8(mEmailAddress);
 }
 
 
 QString
 KAboutPerson::webAddress() const
 {
-   return QString::fromLatin1(mWebAddress);
+   return QString::fromUtf8(mWebAddress);
 }
 
+
+KAboutTranslator::KAboutTranslator(const QString name
+                , const QString emailAddress)
+{
+    mName=name;
+    mEmail=emailAddress;
+}
+
+QString KAboutTranslator::KAboutTranslator::name() const
+{
+    return mName;
+}
+
+QString KAboutTranslator::KAboutTranslator::emailAddress() const
+{
+    return mEmail;
+}
+
+class KAboutDataPrivate
+{
+public:
+    KAboutDataPrivate()
+        : translatorName(0)
+        , translatorEmail(0) 
+        {};
+    const char *translatorName;
+    const char *translatorEmail;
+};
+
+
+
 KAboutData::KAboutData( const char *appName,
                         const char *programName,
 			const char *version,
@@ -73,6 +104,8 @@
   mHomepageAddress( homePageAddress ),
   mBugEmailAddress( bugsEmailAddress )
 {
+   d = new KAboutDataPrivate;
+   
    if( appName ) {
      const char *p = strrchr(appName, '/');
      if( p )
@@ -83,6 +116,11 @@
      mAppName = 0;
 }
 
+KAboutData::~KAboutData()
+{
+    delete d;
+}
+
 void
 KAboutData::addAuthor( const char *name, const char *task,
 		    const char *emailAddress, const char *webAddress )
@@ -97,6 +135,13 @@
   mCreditList.append(KAboutPerson(name,task,emailAddress,webAddress));
 }
 
+void 
+KAboutData::setTranslator( const char *name, const char *emailAddress)
+{
+  d->translatorName=name;
+  d->translatorEmail=emailAddress;
+}
+
 void
 KAboutData::setLicenseText( const char *licenseText )
 {
@@ -164,6 +209,65 @@
 KAboutData::credits() const
 {
    return mCreditList;
+}
+
+const QValueList<KAboutTranslator> 
+KAboutData::translators() const
+{    
+    QValueList<KAboutTranslator> personList;
+        
+    if(d->translatorName == 0)
+        return personList;
+
+    QStringList nameList;
+    QStringList emailList;
+
+    QString names = i18n(d->translatorName);
+    if(names != QString::fromUtf8(d->translatorName))
+    {
+        nameList = QStringList::split(',',names);
+    }
+
+    
+    QString emails;
+    if(d->translatorEmail)
+    {
+        emails = i18n(d->translatorEmail);
+        
+        if(emails != QString::fromUtf8(d->translatorEmail))
+        {
+            emailList = QStringList::split(',',emails,true);
+        }
+    }
+    
+    
+    QStringList::Iterator nit;
+    QStringList::Iterator eit=emailList.begin();
+
+    for(nit = nameList.begin(); nit != nameList.end(); ++nit)
+    {
+        QString email;
+        if(eit != emailList.end())
+        {
+            email=*eit;
+            ++eit;
+        }
+
+        QString name=*nit;
+        
+        personList.append(KAboutTranslator( name, email));
+    }
+        
+    return personList;
+}
+
+QString
+KAboutData::aboutTranslationTeam()
+{
+    return i18n("replace this with information about your translation team",
+            "<p>KDE is translated in many languages thanks to the work "
+            "of the translation teams all over the world.</p>"
+            "<p>For more information visit http://i18n.kde.org</p>");
 }
 
 QString
Index: kaboutdata.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kaboutdata.h,v
retrieving revision 1.14
diff -u -r1.14 kaboutdata.h
--- kaboutdata.h	2000/12/01 19:45:56	1.14
+++ kaboutdata.h	2000/12/26 14:44:53
@@ -93,6 +93,22 @@
     KAboutPersonPrivate *d;
 };
 
+
+class KAboutTranslator
+{
+public:
+    KAboutTranslator(QString name=QString::null
+            , QString emailAddress=QString::null);
+
+    QString name() const;
+    QString emailAddress() const;
+    
+private:
+    QString mName;
+    QString mEmail;
+};
+
+
 /**
  * This class is used to store information about a program. It can store
  * such values a version number, program name, homepage, email address
@@ -171,6 +187,8 @@
 		const char *bugsEmailAddress = "submit@bugs.kde.org"
 		);
 
+     ~KAboutData();
+
     /**
      * Defines an author. You can call this function as many times you
      * need. Each entry is appended to a list. The person in the first entry
@@ -217,6 +235,22 @@
 		    const char *webAddress=0 );
 
     /**
+     * Sets the name of the translator of the gui. Since this depends
+     * on the language, just use a dummy text marked for translation.
+     * For example:
+     * setTranslator(I18N_NOOP("NAME OF THE TRANSLATORS")
+     * ,I18N_NOOP("EMAIL OF THE TRANSLATORS"));
+     *
+     * The translator can then translate this dummy text with his name
+     * or with a list of names separated with ",".
+     * If there is no translation or the application is used with the
+     * default language, this function call is ignored.
+     *
+     * @see KAboutTranslator
+     */
+    void setTranslator(const char* name, const char* emailAddress);
+    
+    /**
      * Defines a licence text.
      *
      * @param license The license text in utf8 encoding.
@@ -279,6 +313,17 @@
     const QValueList<KAboutPerson> credits() const;
 
     /**
+     * @return translators information 
+     */
+    const QValueList<KAboutTranslator> translators() const;
+
+    /** 
+     * @return a message about the translation team 
+     */
+    static QString aboutTranslationTeam();
+
+
+    /**
      * @return the free form text (translated). 
      */
     QString otherText() const;
@@ -297,6 +342,7 @@
      */
     QString copyrightStatement() const { return( QString::fromLatin1(mCopyrightStatement )); }
 
+
   private:
     const char *mAppName;
     const char *mProgramName;
@@ -313,7 +359,6 @@
 
     KAboutDataPrivate *d;
 };
-
 
 #endif
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic