Bug 226377 - Human-readable channel mode announcements don't get translated properly
Summary: Human-readable channel mode announcements don't get translated properly
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-11 21:02 UTC by Eike Hein
Modified: 2010-03-02 04:52 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Hein 2010-02-11 21:02:44 UTC
English: "[18:23] *** Channel modes: no messages from outside, topic protection"
German: "[20:15] *** Kanalmodi: no messages from outside, topic protection"

As can be seen, the mode descriptions aren't translated in the view. This is despite the messages having been extracted into the gettext templates and translated by the translator, and applies to all languages. I.e. the i18n() calls in the method building up the mode description hash table in common.cpp are ineffective.
Comment 1 Travis McHenry 2010-03-02 04:52:45 UTC
commit c46b1b0e94c19a9df5f044ad65645034c17358f0
Author: Travis McHenry <wordsizzle@gmail.com>
Date:   Mon Mar 1 20:46:02 2010 -0700

    Fix the translations for the channel modes
    
    Previously the channel modes were loaded into the hash at runtime.
    Now, we load it when it's needed, coincidentally after KInstance
    has been started, so the i18n() calls now work.
    BUG:226377

diff --git a/src/common.cpp b/src/common.cpp
index 87aac43..f8e740c 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -31,7 +31,7 @@ namespace Konversation
         "([-.\\d\\w]+@[-.\\d\\w]{2,}\\.[\\w]{2,})");
     static QRegExp tdlPattern("(.*)\\.(\\w+),$");
 
-    QHash<QChar,QString> initChanModesHash()
+    void initChanModesHash()
     {
         QHash<QChar,QString> myHash;
 
@@ -47,14 +47,15 @@ namespace Konversation
         myHash.insert('c', i18n("no colors allowed"));
         myHash.insert('l', i18n("user throttling"));
 
-        return myHash;
+        m_modesHash = myHash;
     }
 
-    const QHash<QChar,QString> ChanModes::m_hash = initChanModesHash();
-
     QHash<QChar,QString> getChannelModesHash()
     {
-        return ChanModes::m_hash;
+        if(m_modesHash.isEmpty())
+            initChanModesHash();
+
+        return m_modesHash;
     }
 
     QString removeIrcMarkup(const QString& text)
diff --git a/src/common.h b/src/common.h
index c0b56ca..c30c9ab 100644
--- a/src/common.h
+++ b/src/common.h
@@ -49,11 +49,6 @@ namespace Konversation
         CreateNewConnection
     };
 
-    struct ChanModes
-    {
-        static const QHash<QChar,QString> m_hash;
-    };
-
     struct TextUrlData
     {
         QList<QPair<int, int> > urlRanges;
@@ -74,6 +69,7 @@ namespace Konversation
     bool isUtf8(const QByteArray& text);
     uint colorForNick(const QString& nickname);
 
+    static QHash<QChar,QString> m_modesHash;
     QHash<QChar,QString> getChannelModesHash();
 
     QString sterilizeUnicode(const QString& s);