[california/wip/736262-first] Changed strings, waiting for response from reporter
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/736262-first] Changed strings, waiting for response from reporter
- Date: Thu, 11 Sep 2014 00:44:02 +0000 (UTC)
commit 8442144ab29306dfb2be06e11384816d2e9cbb65
Author: Jim Nelson <jim yorba org>
Date: Wed Sep 10 17:43:21 2014 -0700
Changed strings, waiting for response from reporter
po/POTFILES.in | 1 +
po/POTFILES.skip | 1 +
src/calendar/calendar-day-of-week.vala | 37 +++++++++++++++++++++++++
src/component/component-recurrence-rule.vala | 38 ++-----------------------
4 files changed, 42 insertions(+), 35 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0cb24e1..ad5c58b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,6 +10,7 @@ src/application/california-application.vala
src/application/california-commandline.vala
src/calendar/calendar-date-span.vala
src/calendar/calendar-date.vala
+src/calendar/calendar-day-of-week.vala
src/calendar/calendar-exact-time-span.vala
src/calendar/calendar.vala
src/component/component.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 00e9fcb..d937775 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -8,6 +8,7 @@ src/application/california-commandline.c
src/calendar/calendar.c
src/calendar/calendar-date.c
src/calendar/calendar-date-span.c
+src/calendar/calendar-day-of-week.c
src/calendar/calendar-exact-time-span.c
src/component/component.c
src/component/component-event.c
diff --git a/src/calendar/calendar-day-of-week.vala b/src/calendar/calendar-day-of-week.vala
index 0ace8c3..306c3c7 100644
--- a/src/calendar/calendar-day-of-week.vala
+++ b/src/calendar/calendar-day-of-week.vala
@@ -55,6 +55,17 @@ public class DayOfWeek : BaseObject, Gee.Hashable<DayOfWeek> {
public static DayOfWeek[] weekdays;
public static DayOfWeek[] weekend_days;
+ // See get_day_of_week_of_month().
+ private static string[,] dowom_ordinals = {
+ { _("last Monday"), _("first Monday"), _("second Monday"), _("third Monday"), _("fourth Monday"),
_("fifth Monday") },
+ { _("last Tuesday"), _("first Tuesday"), _("second Tuesday"), _("third Tuesday"), _("fourth
Tuesday"), _("fifth Tuesday") },
+ { _("last Wednesday"), _("first Wednesday"), _("second Wednesday"), _("third Wednesday"), _("fourth
Wednesday"), _("fifth Wednesday") },
+ { _("last Thursday"), _("first Thursday"), _("second Thursday"), _("third Thursday"), _("fourth
Thursday"), _("fifth Thursday") },
+ { _("last Friday"), _("first Friday"), _("second Friday"), _("third Friday"), _("fourth Friday"),
_("fifth Friday") },
+ { _("last Saturday"), _("first Saturday"), _("second Saturday"), _("third Saturday"), _("fourth
Saturday"), _("fifth Saturday") },
+ { _("last Sunday"), _("first Sunday"), _("second Sunday"), _("third Sunday"), _("fourth Sunday"),
_("fifth Sunday") },
+ };
+
public const int MIN = 1;
public const int MAX = 7;
public const int COUNT = MAX - MIN + 1;
@@ -298,6 +309,32 @@ public class DayOfWeek : BaseObject, Gee.Hashable<DayOfWeek> {
return a.value_sunday - b.value_sunday;
}
+ /**
+ * Returns a user-visible string indicating the day of the week of the month, i.e. "first
+ * Monday", "third Thursday", "last Monday", etc.
+ *
+ * Appropriate values are -1 and 1 through 5. -1 indicates the last day of the week of the
+ * month ("last Monday of the month"), while 1 to 5 are positive weeks ("second Tuesday of the
+ * month"). All other values will return null.
+ */
+ public string? get_day_of_week_of_month(int week_number) {
+ // Remember: value_monday is 1-based
+ switch (week_number) {
+ case -1:
+ return dowom_ordinals[value_monday - 1, 0];
+
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return dowom_ordinals[value_monday - 1, week_number];
+
+ default:
+ return null;
+ }
+ }
+
public bool equal_to(DayOfWeek other) {
return this == other;
}
diff --git a/src/component/component-recurrence-rule.vala b/src/component/component-recurrence-rule.vala
index 0a9286c..9b02a41 100644
--- a/src/component/component-recurrence-rule.vala
+++ b/src/component/component-recurrence-rule.vala
@@ -753,41 +753,9 @@ public class RecurrenceRule : BaseObject {
if (dow == null)
return null;
- string day;
- switch (position) {
- case 1:
- // As in, "first Thursday of the month"
- day = _("first %s").printf(dow.full_name);
- break;
-
- case 2:
- // As in, "second Thursday of the month"
- day = _("second %s").printf(dow.full_name);
- break;
-
- case 3:
- // As in, "third Thursday of the month"
- day = _("third %s").printf(dow.full_name);
- break;
-
- case 4:
- // As in, "fourth Thursday of the month"
- day = _("fourth %s").printf(dow.full_name);
- break;
-
- case 5:
- // As in, "fifth Thursday of the month"
- day = _("fifth %s").printf(dow.full_name);
- break;
-
- case -1:
- // As in, "last Thursday of the month"
- day = _("last %s").printf(dow.full_name);
- break;
-
- default:
- return null;
- }
+ string? day = dow.get_day_of_week_of_month(position);
+ if (String.is_empty(day))
+ return null;
if (count > 0) {
// As in, "Repeats every month on the first Tuesday, 3 times"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]