Bug 196888 - Create Calender: Year formatted as 2,009 on last page of wizard
Summary: Create Calender: Year formatted as 2,009 on last page of wizard
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-Calendar (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-17 16:48 UTC by Michael G. Hansen
Modified: 2018-03-23 11:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.5.0


Attachments
Screenshot of wrongly formatted "2,009" on last page of calender wizard (22.10 KB, image/png)
2009-07-06 11:54 UTC, Michael G. Hansen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael G. Hansen 2009-06-17 16:48:36 UTC
Version:           0.3 (using KDE 4.2.4)
OS:                Linux
Installed from:    Debian testing/unstable Packages

On the last page of the "Create Calender" wizard, the year is formatted wrong.

Can be fixed by changing line 201 in calwizard.cpp to:
wPrintLabel_->setText(i18n("Click Next to start Printing<br/><br/>"
                    "Following months will be printed for year %1:<br/>").arg(year)
                    + printList.join(" - ") + extra);
Comment 1 Nicolas L. 2009-07-06 11:28:22 UTC
i don't see anything wrong on the calendar wizard and your patch is already what is wrote on the code.

could you provide a screenshot please ?   thanks
Comment 2 Michael G. Hansen 2009-07-06 11:54:37 UTC
Created attachment 35091 [details]
Screenshot of wrongly formatted "2,009" on last page of calender wizard

Locale: LANG="en_US.UTF-8"
Comment 3 Andi Clemens 2009-07-06 12:09:06 UTC
I had fixed a similar problem in digikam some time ago:
http://websvn.kde.org/?view=rev&revision=893026
http://websvn.kde.org/?view=rev&revision=893030

I guess this should work here, too.
Comment 4 Andi Clemens 2009-07-06 12:13:24 UTC
Oh by the way, I can confirm it :-)
But for me it looks like this:

"2 009"
So a whitespace has been added.

I will assume to use my patches made to digiKam, if possible.
Unfortunately I have no access to the sources at work today, so I can't test it.
Comment 5 Nicolas L. 2009-07-06 12:15:04 UTC
Mickael which digikam version do you have ?
Comment 6 Nicolas L. 2009-07-06 12:16:24 UTC
2 009  for me too.  To be correct it have to be 2009  right ?
Comment 7 Michael G. Hansen 2009-07-06 12:21:49 UTC
I have digikam version 0.10, kipiplugins 0.4, KDE 4.2.4, Qt 4.5.1

Does i18n format numbers locale-aware? I could not find anything on this in the documentation, that's why I suggested to use Qt's .arg, which does locale-aware formatting only if you write "%L1". But Nicolas' suggestion of converting the integer to a string first should have the same effect.
Comment 8 Andi Clemens 2009-07-06 12:31:34 UTC
(In reply to comment #6)
> 2 009  for me too.  To be correct it have to be 2009  right ?

Sure ;-)
Comment 9 Nicolas L. 2009-07-12 21:41:20 UTC
SVN commit 995464 by nlecureuil:

Fix year formating in calendar
BUG:196888


 M  +1 -1      calwizard.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=995464
Comment 10 Andi Clemens 2009-07-12 22:04:49 UTC
This patch is not locale aware. As I posted above, we should use KLocale instead.

Something like

KLocale tmpLocale(*KGlobal::locale());                                 	  	 
tmpLocale.setDateFormat("%Y");
QString year = tmpLocale.formatDate(date);

would be better.
Comment 11 Nicolas L. 2009-07-12 23:28:55 UTC
Ah yes for the local aware part but if i understand correctly, year can't be a QString.

i will try to do a patch and post it on the bugzilla
Comment 12 Andi Clemens 2009-07-12 23:41:24 UTC
Why not? It is a QString now... :-)
QString::number generates a QString object.
Comment 13 Nicolas L. 2009-07-12 23:46:05 UTC
i have a pb with :

QString year = tmpLocale.formatDate(date);


what should be used instead of date ?  i tried cSettings_->year()   but that doesn't work
Comment 14 Andi Clemens 2009-07-12 23:57:39 UTC
Why not use the d object (QDate)?
Comment 15 Andi Clemens 2009-07-13 08:53:22 UTC
I'm not sure if QDate is already locale aware, because we set it with

KGlobal::locale()->calendar()->setDate(d, cSettings_->year(), 1, 1);

before.
So you can either try using the QDate object directly:

[...] "Following months will be printed for year %1:<br/>", QString::number(d.year()))

or use it like that:

QString year = tmpLocale.formatDate(d);
Comment 16 Nicolas L. 2009-07-14 11:43:41 UTC
ok but when using QString::number(d.year()))  how can i see if this is locale-aware   ?
Comment 17 Andi Clemens 2009-07-14 11:51:27 UTC
No clue :D
The best would be just to use the KLocale... code. It doesn't hurt if we really localize this twice:

QString year = tmpLocale.formatDate(d);
Comment 18 Nicolas L. 2009-07-16 23:07:35 UTC
because of line 184, year have to be an int, so i needed to create a new var.

What do you think of: 

Index: calendar/calwizard.cpp
===================================================================
--- calendar/calwizard.cpp      (révision 995464)
+++ calendar/calwizard.cpp      (copie de travail)
@@ -188,7 +188,7 @@
         }
         else
         {
-            int year = cSettings_->year();
+           int year = cSettings_->year();

             QString extra;
             if ((KGlobal::locale()->calendar()->month(QDate::currentDate()) >= 6 &&
@@ -198,8 +198,12 @@
                         "calendar for<br/>the current year or a year in the "
                         "past.")+"</b>";

+           KLocale tmpLocale(*KGlobal::locale());
+           tmpLocale.setDateFormat("%Y");
+           QString year_locale = tmpLocale.formatDate(d);
+
             wPrintLabel_->setText(i18n("Click Next to start Printing<br/><br/>"
-                    "Following months will be printed for year %1:<br/>", QString::number(year))
+                    "Following months will be printed for year %1:<br/>", year_locale)
                     + printList.join(" - ") + extra);
             wPrintLabel_->setTextFormat(Qt::RichText);
Comment 19 Andi Clemens 2009-07-17 18:17:02 UTC
Yes sure, this was what I suggested before :D
It should work fine... if not, we can change it again :)

Andi
Comment 20 Nicolas L. 2009-07-17 18:29:14 UTC
SVN commit 998433 by nlecureuil:

make year locale aware
CCBUG:196888


 M  +5 -1      calwizard.cpp  


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