[gnote] * Properly use plural forms (Close #579412)
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] * Properly use plural forms (Close #579412)
- Date: Mon, 20 Apr 2009 20:03:31 -0400 (EDT)
commit c1aacc937df532d31ce063df03ee1dd6db587b3c
Author: Hubert Figuiere <hub figuiere net>
Date: Mon Apr 20 18:42:29 2009 -0400
* Properly use plural forms (Close #579412)
---
NEWS | 1 +
src/note.cpp | 24 ++++++++++++++----------
src/recentchanges.cpp | 21 +++------------------
src/utils.cpp | 28 ++++------------------------
4 files changed, 22 insertions(+), 52 deletions(-)
diff --git a/NEWS b/NEWS
index 365823c..1179b79 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ Translations:
* Ensure the spelling of Gnote.
* Some strings shouldn't be translated. (Close #579197)
* Date format are non localizable. (Close #579207)
+ * Properly use plural forms (Close #579412)
* Added translations:
- Swedish (sv)
- Greek (el)
diff --git a/src/note.cpp b/src/note.cpp
index d8deadc..c17de58 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -61,17 +61,21 @@ namespace gnote {
void show_deletion_dialog (const std::list<Note::Ptr> & notes, Gtk::Window * parent)
{
std::string message;
-
- if (notes.size() == 1)
- message = _("Really delete this note?");
- else
- message = str(boost::format(_("Really delete these %1% notes?")) % notes.size());
-
+
+ // %1% is the number of note.
+ message = ngettext("Really delete this note?", "Really delete these %1% notes?", notes.size());
+
+ boost::format format(message);
+ // make sure an exception is not raised for the non-plural form
+ format.exceptions( boost::io::all_error_bits ^
+ ( boost::io::too_many_args_bit |
+ boost::io::too_few_args_bit ) );
+
utils::HIGMessageDialog dialog(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
- Gtk::MESSAGE_QUESTION,
- Gtk::BUTTONS_NONE,
- message,
- _("If you delete a note it is permanently lost."));
+ Gtk::MESSAGE_QUESTION,
+ Gtk::BUTTONS_NONE,
+ str(format % notes.size()),
+ _("If you delete a note it is permanently lost."));
Gtk::Button *button;
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 46789b6..17c033a 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -564,12 +564,7 @@ namespace gnote {
match_count = miter->second;
if (match_count > 0) {
const char * fmt;
- if(match_count == 1) {
- fmt = _("%1% match");
- }
- else {
- fmt = _("%1% matches");
- }
+ fmt = ngettext("%1% match", "%1% matches", match_count);
match_str = str(boost::format(fmt) % match_count);
}
}
@@ -582,12 +577,7 @@ namespace gnote {
void NoteRecentChanges::update_total_note_count (int total)
{
const char * fmt;
- if(total == 1) {
- fmt = _("Total: %1% note");
- }
- else {
- fmt = _("Total: %1% notes");
- }
+ fmt = ngettext("Total: %1% note", "Total: %1% notes", total);
m_note_count.set_text(str(boost::format (fmt) % total));
}
@@ -595,12 +585,7 @@ namespace gnote {
void NoteRecentChanges::update_match_note_count (int matches)
{
const char * fmt;
- if(matches == 1) {
- fmt = _("Matches: %1% note");
- }
- else {
- fmt = _("Matches: %1% notes");
- }
+ fmt = ngettext("Matches: %1% note", "Matches: %1% notes", matches);
m_note_count.set_text(str(boost::format (fmt) % matches));
}
diff --git a/src/utils.cpp b/src/utils.cpp
index e825436..388a193 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -179,21 +179,11 @@ namespace gnote {
int num_days = now.day_of_year() - date.day_of_year();
const char * fmt;
if(show_time) {
- if(num_days == 1) {
- fmt = _("%1% day ago, %2%");
- }
- else {
- fmt = _("%1% days ago, %2%");
- }
+ fmt = ngettext("%1% day ago, %2%", "%1% days ago, %2%", num_days);
pretty_str = str(boost::format(fmt) % num_days % short_time);
}
else {
- if(num_days == 1) {
- fmt = _("%1% day ago");
- }
- else {
- fmt = _("%1% days ago");
- }
+ fmt = ngettext("%1% day ago", "%1% days ago", num_days);
pretty_str = str(boost::format(fmt) % num_days);
}
}
@@ -208,21 +198,11 @@ namespace gnote {
int num_days = date.day_of_year() - now.day_of_year();
const char * fmt;
if(show_time) {
- if(num_days == 1) {
- fmt = _("In %1% day, %2%");
- }
- else {
- fmt = _("In %1% days, %2%");
- }
+ fmt = ngettext("In %1% day, %2%", "In %1% days, %2%", num_days);
pretty_str = str(boost::format(fmt) % num_days % short_time);
}
else {
- if(num_days == 1) {
- fmt = _("In %1% day");
- }
- else {
- fmt = _("In %1% days");
- }
+ fmt = ngettext("In %1% day", "In %1% days", num_days);
pretty_str = str(boost::format(fmt) % num_days);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]