[california/wip/731723-locale] Localize Week view day header labels: Bug #731723
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/731723-locale] Localize Week view day header labels: Bug #731723
- Date: Thu, 19 Jun 2014 00:47:43 +0000 (UTC)
commit 7fc85eb36d714c0e738d288176a85613278590c3
Author: Jim Nelson <jim yorba org>
Date: Wed Jun 18 17:46:57 2014 -0700
Localize Week view day header labels: Bug #731723
The ordering of the Week view day header labels needs to be available
for localization.
src/calendar/calendar-date.vala | 10 ++++++++++
src/calendar/calendar.vala | 21 +++++++++++++++++++++
src/view/week/week-grid.vala | 6 ++++--
3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/calendar-date.vala b/src/calendar/calendar-date.vala
index ce762f0..ab8c29e 100644
--- a/src/calendar/calendar-date.vala
+++ b/src/calendar/calendar-date.vala
@@ -37,6 +37,10 @@ public class Date : Unit<Date>, Gee.Comparable<Date>, Gee.Hashable<Date> {
*/
ABBREV,
/**
+ * Indicates the returned string should be as compact as possible (implies { link ABBREV}.
+ */
+ COMPACT,
+ /**
* Indicates that the year should be included in the return date string.
*/
INCLUDE_YEAR,
@@ -338,6 +342,7 @@ public class Date : Unit<Date>, Gee.Comparable<Date>, Gee.Hashable<Date> {
* or INCLUDE_YEAR flag is specified.
*/
public string to_pretty_string(PrettyFlag flags) {
+ bool compact = (flags & PrettyFlag.COMPACT) != 0;
bool abbrev = (flags & PrettyFlag.ABBREV) != 0;
bool with_year = (flags & PrettyFlag.INCLUDE_YEAR) != 0;
bool no_today = (flags & PrettyFlag.NO_TODAY) != 0;
@@ -352,6 +357,11 @@ public class Date : Unit<Date>, Gee.Comparable<Date>, Gee.Hashable<Date> {
fmt = with_year ? FMT_PRETTY_DATE_ABBREV_NO_DOW : FMT_PRETTY_DATE_ABBREV_NO_DOW_NO_YEAR;
else
fmt = with_year ? FMT_PRETTY_DATE_ABBREV : FMT_PRETTY_DATE_ABBREV_NO_YEAR;
+ } else if (compact) {
+ if (no_dow)
+ fmt = with_year ? FMT_PRETTY_DATE_COMPACT_NO_DOW : FMT_PRETTY_DATE_COMPACT_NO_DOW_NO_YEAR;
+ else
+ fmt = with_year ? FMT_PRETTY_DATE_COMPACT : FMT_PRETTY_DATE_COMPACT_NO_YEAR;
} else {
if (no_dow)
fmt = with_year ? FMT_PRETTY_DATE_NO_DOW : FMT_PRETTY_DATE_NO_DOW_NO_YEAR;
diff --git a/src/calendar/calendar.vala b/src/calendar/calendar.vala
index 70866ab..96fa49a 100644
--- a/src/calendar/calendar.vala
+++ b/src/calendar/calendar.vala
@@ -59,6 +59,10 @@ private unowned string FMT_PRETTY_DATE_NO_DOW;
private unowned string FMT_PRETTY_DATE_ABBREV_NO_DOW;
private unowned string FMT_PRETTY_DATE_NO_DOW_NO_YEAR;
private unowned string FMT_PRETTY_DATE_ABBREV_NO_DOW_NO_YEAR;
+private unowned string FMT_PRETTY_DATE_COMPACT;
+private unowned string FMT_PRETTY_DATE_COMPACT_NO_YEAR;
+private unowned string FMT_PRETTY_DATE_COMPACT_NO_DOW;
+private unowned string FMT_PRETTY_DATE_COMPACT_NO_DOW_NO_YEAR;
private unowned string FMT_AM;
private unowned string FMT_BRIEF_AM;
private unowned string FMT_PM;
@@ -106,6 +110,7 @@ public void init() throws Error {
FMT_DAY_OF_WEEK_FULL = "%A";
FMT_DAY_OF_WEEK_ABBREV = "%a";
FMT_FULL_DATE = "%x";
+ FMT_PRETTY_DATE_COMPACT_NO_DOW = "%x";
// The month and year according to locale preferences, i.e. "March 2014"
// See http://www.cplusplus.com/reference/ctime/strftime/ for format reference
@@ -150,6 +155,22 @@ public void init() throws Error {
// See http://www.cplusplus.com/reference/ctime/strftime/ for format reference
FMT_PRETTY_DATE_ABBREV_NO_DOW_NO_YEAR = _("%b %e");
+ // A "pretty" date compacted according to locale preferences, i.e. "Mon 3/10/2014"
+ // Leading zeroes will be stripped.
+ // See http://www.cplusplus.com/reference/ctime/strftime/ for format reference
+ FMT_PRETTY_DATE_COMPACT = _("%a %x");
+
+ // A "pretty" date abbreviated and no year according to locale preferences, i.e. "Mon 3/10"
+ // Leading zeroes will be stripped.
+ // See http://www.cplusplus.com/reference/ctime/strftime/ for format reference
+ FMT_PRETTY_DATE_COMPACT_NO_YEAR = _("%a %m/%d");
+
+ // A "pretty" date abbreviated with no day of week or year according to locale preferences,
+ // i.e. "3/10"
+ // Leading zeroes will be stripped.
+ // See http://www.cplusplus.com/reference/ctime/strftime/ for format reference
+ FMT_PRETTY_DATE_COMPACT_NO_DOW_NO_YEAR = _("%m/%d");
+
// Ante meridiem
// (Please translate even if 24-hour clock used in your locale; this allows for GNOME time
// format user settings to be honored)
diff --git a/src/view/week/week-grid.vala b/src/view/week/week-grid.vala
index f38ea4b..cdc4cd7 100644
--- a/src/view/week/week-grid.vala
+++ b/src/view/week/week-grid.vala
@@ -25,6 +25,9 @@ namespace California.View.Week {
internal class Grid : Gtk.Box {
public const string PROP_WEEK = "week";
+ private const Calendar.Date.PrettyFlag DATE_LABEL_FLAGS =
+ Calendar.Date.PrettyFlag.COMPACT | Calendar.Date.PrettyFlag.NO_TODAY;
+
public weak Controller owner { get; private set; }
/**
@@ -98,8 +101,7 @@ internal class Grid : Gtk.Box {
// to account for spacer/HourRunner
int col = 1;
foreach (Calendar.Date date in week) {
- Gtk.Label date_label = new Gtk.Label("%s %d/%d".printf(date.day_of_week.abbrev_name,
- date.month_of_year().month.value, date.day_of_month.value));
+ Gtk.Label date_label = new Gtk.Label(date.to_pretty_string(DATE_LABEL_FLAGS));
// draw a line along the bottom of the label
date_label.draw.connect(on_draw_bottom_line);
top_grid.attach(date_label, col, 0, 1, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]