Bug 341085 - Forward Email Template Error
Summary: Forward Email Template Error
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: general (show other bugs)
Version: 4.14.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-18 20:22 UTC by Guo Yunhe
Modified: 2014-11-21 17: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 Guo Yunhe 2014-11-18 20:22:16 UTC
This is the default head of forward mail in KMail:
--------------------------------------------------
Subject: xxx
Date: 2014年11月18日 星期二
From: 10:24:08
To: Aalto-yliopisto <no-reply@aalto.fi>
To: Yunhe Guo <yunhe.guo@aalto.fi>
----------------------------------------------------
I checked the template of forward email, the head part is:

Subject: %OFULLSUBJECT
Date: %ODATE
From: %OTIMELONG
To: %OFROMADDR
%OADDRESSEESADDR

%TEXT
-------------------------------------------------------

I think this is a template error.

Reproducible: Always

Steps to Reproduce:
1. Open a email.
2. Right click -> Forward -> Inline...
3. You can see the mail body.
Comment 1 Laurent Montel 2014-11-19 07:28:15 UTC
So what is the error ?
What is the expected result ?
Comment 2 Guo Yunhe 2014-11-19 07:45:58 UTC
(In reply to Laurent Montel from comment #1)
> So what is the error ?
> What is the expected result ?

Error:

This is the default head of forward mail in KMail: 
--------------------------------------------------
Subject: XXXXX
Date: Tuesday 18 November 2014
From: 10:24:08
To: A <someonea@example.com>
To: B <someoneb@example.com>
----------------------------------------------------
1. "From" should not be time but an email address.
2. There are two "To" entries. The first is the address of sender, and the second is the address of receiver. There should only be one "To" entry with receiver's email.

I think the expected result should be:

--------------------------------------------------
Subject: XXXXX
Date: Tuesday 18 November 2014 10:24:08
From: A <someonea@example.com>
To: B <someoneb@example.com>
----------------------------------------------------
Comment 3 Laurent Montel 2014-11-19 08:38:48 UTC
Are you reset default template ?
But default it"s 

%REM="Default forward template"%-

----------  Forwarded Message  ----------

Subject: %OFULLSUBJECT
Date: %ODATE, %OTIMELONG
From: %OFROMADDR
%OADDRESSEESADDR

%TEXT
-----------------------------------------

I don't see the error in source code.
Comment 4 Laurent Montel 2014-11-19 08:41:18 UTC
Perhaps you can send me a test email in private message.
Perhaps in japonese characters creates a problem
Comment 5 Guo Yunhe 2014-11-19 08:49:25 UTC
No I didn't change it. This is the default settings in openSUSE 13.2. Maybe it is only a problem of packaging in openSUSE 13.2.

The default template is (in Chinese):

----------  转发的信件  ----------

主题:%OFULLSUBJECT
日期:%ODATE
发件人:%OTIMELONG
收件人:%OFROMADDR
%OADDRESSEESADDR

%TEXT
-------------------------------------------------------

I guess it might be a translation error of Chinese. When translating, translator changed several lines' orders by mistakes.
Comment 6 Laurent Montel 2014-11-19 08:54:53 UTC
Yes indeed you're right it's in i18n(...)
We need to ask to translator to fix it.
QString DefaultTemplates::defaultForward()
{
    return
        QLatin1String("%REM=\"") + i18n("Default forward template") + QLatin1String("\"%-\n") +
        i18nc("Default forward template: %1: subject of original message, "
              "%2: date of original message, "
              "%3: time of original message, "
              "%4: mail address of original sender, "
              "%5: original message text",
              "\n"
              "----------  Forwarded Message  ----------\n"
              "\n"
              "Subject: %1\n"
              "Date: %2, %3\n"
              "From: %4\n"
              "%OADDRESSEESADDR\n"
              "\n"
              "%5\n"
              "-----------------------------------------",
              QLatin1String("%OFULLSUBJECT"), QLatin1String("%ODATE"), QLatin1String("%OTIMELONG"), QLatin1String("%OFROMADDR"), QLatin1String("%TEXT"));
}

it'es translated so translator make an error I think.
Comment 7 Laurent Montel 2014-11-19 08:57:37 UTC
Hi kde-i18n :)
I think this bug is a translate problem.
Could you verify chinese version please ?

Thanks.

Le Wednesday 19 November 2014 08:49:25 guoyunhebrave a écrit :
> https://bugs.kde.org/show_bug.cgi?id=341085
> 
> --- Comment #5 from guoyunhebrave <guoyunhebrave@gmail.com> ---
> No I didn't change it. This is the default settings in openSUSE 13.2. Maybe
> it is only a problem of packaging in openSUSE 13.2.
> 
> The default template is (in Chinese):
> 
> ----------  转发的信件  ----------
> 
> 主题:%OFULLSUBJECT
> 日期:%ODATE
> 发件人:%OTIMELONG
> 收件人:%OFROMADDR
> %OADDRESSEESADDR
> 
> %TEXT
> -------------------------------------------------------
> 
> I guess it might be a translation error of Chinese. When translating,
> translator changed several lines' orders by mistakes.
Comment 8 Guo Yunhe 2014-11-19 09:39:34 UTC
I have found the translation message and submitted a patch.

But there is still a problem. The program source code use "%OADDRESSEESADDR" to represent all email receivers:
--------------------------------------------
    "From: %4\n"
    "%OADDRESSEESADDR\n"
--------------------------------------------

This will output following text in Chinese:
----------------------------------------------------------------------------------------
发件人:User C<userc@example.com>
To: User A<usera@example.com>, User B<userb@example.com>
----------------------------------------------------------------------------------------
It is a mixture of Chinese and English.

The reason is %OADDRESSEESADDR output "To: " before all receiver addresses. I hope that %OADDRESSEESADDR only output email addresses without "To: " at the beginning. And then program source code should be:

              "----------  Forwarded Message  ----------\n"
              "\n"
              "Subject: %1\n"
              "Date: %2, %3\n"
              "From: %4\n"
              "To: %5\n"
              "\n"
              "%6\n"
              "-----------------------------------------"
Comment 9 Laurent Montel 2014-11-19 09:49:43 UTC
            } else if (cmd.startsWith(QLatin1String("OADDRESSEESADDR"))) {
                qDebug() << "Command: OADDRESSEESADDR";
                i += strlen("OADDRESSEESADDR");
                if (mOrigMsg) {
                    const QString to = mOrigMsg->to()->asUnicodeString();
                    const QString cc = mOrigMsg->cc()->asUnicodeString();
                    if (!to.isEmpty()) {
                        QString toLine =  i18nc("@item:intext email To", "To:") + QLatin1Char(' ') + to;
                        plainBody.append(toLine);
                        const QString body = plainToHtml(toLine);
                        htmlBody.append(body);
                    }
                    if (!to.isEmpty() && !cc.isEmpty()) {
                        plainBody.append(QLatin1Char('\n'));
                        const QString str = plainToHtml(QString(QLatin1Char('\n')));
                        htmlBody.append(str);
                    }
                    if (!cc.isEmpty()) {
                        QString ccLine = i18nc("@item:intext email CC", "CC:") + QLatin1Char(' ') +  cc;
                        plainBody.append(ccLine);
                        const QString str = plainToHtml(ccLine);
                        htmlBody.append(str);
                    }
                }
" QString toLine =  i18nc("@item:intext email To", "To:") + QLatin1Char(' ') + to;"
=> it's translated
so it's not a probem.
Comment 10 Guo Yunhe 2014-11-19 09:53:03 UTC
OK, I understand. Thank you!
Comment 11 Guo Yunhe 2014-11-19 10:08:27 UTC
But I tried to use "%OADDRESSEESADDR" in my customized template. (Program language is Chinese) It displays English "To:" not Chinese "收件人:".

i18nc("@item:intext email To", "To:") is defined in Chinese translation indeed. That is strange.
Comment 12 Guo Yunhe 2014-11-19 10:43:02 UTC
I tested Finnish language, it works well. So it is only a Chinese translation problem.

But I still suggest my solution that "%OADDRESSEESADDR" only outputs email addresses.

i18n defined in "%OADDRESSEESADDR" always use the translation of current application language. But non-English users may have two language templates: English and their mother tongue. They usually have to define customized template of reply, reply and forward.

If my KMail UI is in Chinese, "%OADDRESSEESADDR" always shows "发件人:XXX". When I want to make an English template to communicate with foreign friends, I cannot change the translation of "%OADDRESSEESADDR" in my customized template, because it is totally decided by application language.
Comment 13 Laurent Montel 2014-11-19 11:19:34 UTC
indeed but I can't change it.
Otherwise I will break all template for all users.
Comment 14 Guo Yunhe 2014-11-19 12:18:33 UTC
Yes, I fully understand your consideration. How about providing another parser "OTOALLADDR" for those who want to use customized templates? This solution does not affect old users' template settings.

parser name:
            OTOALLADDR
description:
            All recipients without "To:" label.
example output:
            Jon Larry<jon.larry@example.com>, Thomas Whel <thomas.whel@example.com>
Comment 15 Laurent Montel 2014-11-19 12:32:16 UTC
Another problem is that this variable allows to add "CC" too.

But you can use "OTOLIST" no ?
Comment 16 Guo Yunhe 2014-11-19 12:48:08 UTC
Yes. I can use OTOLIST. If I need CC I can customize my template as:

-----------------------------------------
From: %OFROMADDR
To: %OTOLIST
Cc: %OCCADDR
-----------------------------------------

But %OCCADDR only output one address, isn't it? There is not %OCCLIST parser.
Comment 17 Laurent Montel 2014-11-19 13:06:23 UTC
            } else if (cmd.startsWith(QLatin1String("OADDRESSEESADDR"))) {
                qDebug() << "Command: OADDRESSEESADDR";
                i += strlen("OADDRESSEESADDR");
                if (mOrigMsg) {
                    const QString to = mOrigMsg->to()->asUnicodeString();
                    const QString cc = mOrigMsg->cc()->asUnicodeString();

and 
            } else if (cmd.startsWith(QLatin1String("OCCADDR"))) {
                qDebug() << "Command: OCCADDR";
                i += strlen("OCCADDR");
                if (mOrigMsg) {
                    const QString str = mOrigMsg->cc()->asUnicodeString();
                    plainBody.append(str);
                    const QString body = plainToHtml(str);
                    htmlBody.append(body);
                }


=> for me it's the same code for cc 
=> it's ok
Comment 18 Guo Yunhe 2014-11-19 13:19:15 UTC
After test, I found %OTOADDR and %OCCADDR both outputs all email addresses. So I can use:

-----------------------------------------
From: %OFROMADDR
To: %OTOADDR
Cc: %OCCADDR
-----------------------------------------

So, what is the difference between %OTOADDR and %OTOLIST? They seem output the same email list of the same format.
Comment 19 Laurent Montel 2014-11-19 13:29:59 UTC
There is not difference when I look at source code.
I think that it was old variable which was never removed.
I can't remove it for compatibility but indeed you can use %OTOADDR or %OTOLIST
Comment 20 Guo Yunhe 2014-11-19 13:32:31 UTC
Thanks for your patient answer. Every question is clearly explained. I will work with KDE China i18n team to solve the translation error.
Comment 21 Laurent Montel 2014-11-21 15:22:33 UTC
Please close this bug when i18n is fixed.
Thanks
Comment 22 Weng Xuetian 2014-11-21 17:52:47 UTC
SVN commit 1407013 by xuetianweng:

Fix forward template translation.



 M  +36 -66    libtemplateparser.po  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1407013