[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Review Request 118448: Use KCalendarSystem to get the list of the month and day names that shoul
From: "John Layt" <jlayt () kde ! org>
Date: 2014-06-03 13:34:01
Message-ID: 20140603133401.19148.47445 () probe ! kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> On June 1, 2014, 5:22 p.m., Alexander Potashev wrote:
> > What is the user changes the locale at run-time - will the query parser reload \
> > the month/weekday names?
>
> Denis Steckelmacher wrote:
> It depends on the client application. This list is cached in pass_periodnames, that \
> is private to one Baloo::QueryParser instance. If the application, let's say \
> KRunner, instantiates a new parser for every query, then the new calendar will be \
> used as soon as the user changes it.
> Alexander Potashev wrote:
> OK. I guess adding some notification/listening API of KCalendarSystem in order to \
> pull the changes in the current locale automatically would be an overkill. May be \
> this name caching should be told about in a comment in code.
> John Layt wrote:
> The Locale KCM does signal out when it changes teh locale, you may be able to \
> listen for that:
> KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, \
> KGlobalSettings::SETTINGS_LOCALE);
> Note that this, like KCalendarSystem itself, is KDE4 only: in KF5 we switch to \
> using QLocale, and I haven't yet got calendar system support merged into Qt.
> Denis Steckelmacher wrote:
> Hummm, how will this problem be solved in KF5 then? The Baloo query parser is \
> supposed to make it first apparition in KF5, so it has to work well there. Do you \
> think that, as a temporary workaround, the query parser should provide the month \
> and day names itself (a bit like what was done before this patch, but with the \
> ability to decouple calendar systems from languages)?
Baloo should not localise them itself, it should always use the locale via KLocale or \
QLocale, that's what they are there for. In KDE4 it must be via \
KLocale/KCalendarSystem, in KF5 via QLocale. The KF5 Porting Aid library \
kdelibs4support still has KCalendarSystem, but that's only supported for 3 releases. \
I plan to have QCalendarSystem in Qt 5.4 or 5.5, so before kdelibs4support gets \
dropped. Even if I don't, QLocale already has dayName() and monthName() methods that \
will give you the current names.
- John
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118448/#review58904
-----------------------------------------------------------
On June 1, 2014, 12:54 p.m., Denis Steckelmacher wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118448/
> -----------------------------------------------------------
>
> (Updated June 1, 2014, 12:54 p.m.)
>
>
> Review request for Baloo, Localization and Translation (l10n) and Alexander \
> Potashev.
>
> Repository: baloo
>
>
> Description
> -------
>
> The query parser made the erroneous assumption that each language uses at most one \
> calendar system, and therefore used i18nc to translate the month and day names \
> recognized by the parser. This patches changes that and uses the KCalendarSystem of \
> the user to get the month and day names.
> I've written the code by looking at how the gregorian, hebrew and islamic calendars \
> work (these are the three that I somehow understand). The idea is to try to get as \
> many days and months as possible, by incrementing an index until the calendar \
> system returns NULL strings. This works well for days, but monthName() requires a \
> year, that is used by some calendar systems to rename/add months on leap years. I \
> pass the current year, as most of the users will look for dates not too far in the \
> future nor in the past. Is there a mean to get the complete list of month names and \
> their corresponding number, using KCalendarSystem or anything else?
>
> Diffs
> -----
>
> src/queryparser/pass_periodnames.h 1d7d522
> src/queryparser/pass_periodnames.cpp da688ed
>
> Diff: https://git.reviewboard.kde.org/r/118448/diff/
>
>
> Testing
> -------
>
> The query parser testsuite still passes, and properly gets the name of Gregorian \
> months and days (the tests run using the C locale).
>
> Thanks,
>
> Denis Steckelmacher
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/118448/">https://git.reviewboard.kde.org/r/118448/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <p style="margin-top: 0;">On June 1st, 2014, 5:22 p.m. BST, <b>Alexander \
Potashev</b> wrote:</p> <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;"> <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">What is the user changes the locale at run-time - will the query parser \
reload the month/weekday names?</pre> </blockquote>
<p>On June 1st, 2014, 5:48 p.m. BST, <b>Denis Steckelmacher</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">It depends on the client \
application. This list is cached in pass_periodnames, that is private to one \
Baloo::QueryParser instance. If the application, let's say KRunner, instantiates \
a new parser for every query, then the new calendar will be used as soon as the user \
changes it.</pre> </blockquote>
<p>On June 1st, 2014, 10:49 p.m. BST, <b>Alexander Potashev</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">OK. I guess adding some \
notification/listening API of KCalendarSystem in order to pull the changes in the \
current locale automatically would be an overkill. May be this name caching should be \
told about in a comment in code.</pre> </blockquote>
<p>On June 3rd, 2014, 11:46 a.m. BST, <b>John Layt</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The Locale KCM does \
signal out when it changes teh locale, you may be able to listen for that:
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, \
KGlobalSettings::SETTINGS_LOCALE);
Note that this, like KCalendarSystem itself, is KDE4 only: in KF5 we switch to using \
QLocale, and I haven't yet got calendar system support merged into Qt.</pre> \
</blockquote>
<p>On June 3rd, 2014, 1:10 p.m. BST, <b>Denis Steckelmacher</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Hummm, how will this \
problem be solved in KF5 then? The Baloo query parser is supposed to make it first \
apparition in KF5, so it has to work well there. Do you think that, as a temporary \
workaround, the query parser should provide the month and day names itself (a bit \
like what was done before this patch, but with the ability to decouple calendar \
systems from languages)?</pre> </blockquote>
</blockquote>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Baloo should not \
localise them itself, it should always use the locale via KLocale or QLocale, \
that's what they are there for. In KDE4 it must be via KLocale/KCalendarSystem, \
in KF5 via QLocale. The KF5 Porting Aid library kdelibs4support still has \
KCalendarSystem, but that's only supported for 3 releases. I plan to have \
QCalendarSystem in Qt 5.4 or 5.5, so before kdelibs4support gets dropped. Even if I \
don't, QLocale already has dayName() and monthName() methods that will give you \
the current names.</pre> <br />
<p>- John</p>
<br />
<p>On June 1st, 2014, 12:54 p.m. BST, Denis Steckelmacher wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Baloo, Localization and Translation (l10n) and Alexander \
Potashev.</div> <div>By Denis Steckelmacher.</div>
<p style="color: grey;"><i>Updated June 1, 2014, 12:54 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
baloo
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The query parser made the erroneous assumption that each language uses \
at most one calendar system, and therefore used i18nc to translate the month and day \
names recognized by the parser. This patches changes that and uses the \
KCalendarSystem of the user to get the month and day names.
I've written the code by looking at how the gregorian, hebrew and islamic \
calendars work (these are the three that I somehow understand). The idea is to try to \
get as many days and months as possible, by incrementing an index until the calendar \
system returns NULL strings. This works well for days, but monthName() requires a \
year, that is used by some calendar systems to rename/add months on leap years. I \
pass the current year, as most of the users will look for dates not too far in the \
future nor in the past. Is there a mean to get the complete list of month names and \
their corresponding number, using KCalendarSystem or anything else?</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The query parser testsuite still passes, and properly gets the name of \
Gregorian months and days (the tests run using the C locale).</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>src/queryparser/pass_periodnames.h <span style="color: \
grey">(1d7d522)</span></li>
<li>src/queryparser/pass_periodnames.cpp <span style="color: \
grey">(da688ed)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/118448/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic