In the status line, the pager and index report where the current view
is as a percentage of the total, by default in the lower right.

This commit allows that percentage to be localized by the translators.
For example, Turkish uses "%90", and French uses "90 %".

Since there are only two places in the commit, I could have put the
translation marker around each usage, but I thought it might be more
useful in the future to have the L10N comments in one place.

This is based on Emir SARI's patch sent to mutt-po.

Thanks to Oswald Buddenhagen for his feedback.
---
 muttlib.c | 16 ++++++++++++++++
 pager.c   |  6 ++++--
 protos.h  |  2 ++
 status.c  |  2 +-
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/muttlib.c b/muttlib.c
index 59a48378..7f8c0123 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -1212,6 +1212,22 @@ void mutt_buffer_sanitize_filename(BUFFER *d, const char 
*f, int flags)
   }
 }
 
+/* L10N:
+ * A percentage value, for example 32%.  This is used in
+ * the index status line and pager status line.
+ * Note the %d is the number and %% is a percentage sign.
+ * You can reverse the order and/or substitute a different symbol
+ * that your locale uses, for example:
+ *   "%%%d"  which would generate "%32"
+ *   "%d %%" which would generate "32 %"
+ */
+static const char *localized_percentage = N_("%d%%");
+
+const char *mutt_i18n_percentage(void)
+{
+  return _(localized_percentage);
+}
+
 void mutt_expand_file_fmt(BUFFER *dest, const char *fmt, const char *src)
 {
   BUFFER *tmp;
diff --git a/pager.c b/pager.c
index a9c30dbd..92fa152a 100644
--- a/pager.c
+++ b/pager.c
@@ -2007,13 +2007,15 @@ static void pager_menu_redraw(MUTTMENU *pager_menu)
   if (pager_menu->redraw & REDRAW_STATUS)
   {
     struct hdr_format_info hfi;
-    char pager_progress_str[4];
+    char pager_progress_str[20];
 
     hfi.ctx = Context;
     hfi.pager_progress = pager_progress_str;
 
     if (rd->last_pos < rd->sb.st_size - 1)
-      snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", 
(100 * rd->last_offset / rd->sb.st_size));
+      snprintf(pager_progress_str, sizeof(pager_progress_str),
+               mutt_i18n_percentage(),
+               (int) (100 * rd->last_offset / rd->sb.st_size));
     else
       strfcpy(pager_progress_str, (rd->topline == 0) ? "all" : "end", 
sizeof(pager_progress_str));
 
diff --git a/protos.h b/protos.h
index e5f115f8..a9ec6031 100644
--- a/protos.h
+++ b/protos.h
@@ -168,6 +168,8 @@ const char *mutt_make_version(void);
 
 const char *mutt_fqdn(short);
 
+const char *mutt_i18n_percentage(void);
+
 group_t *mutt_pattern_group(const char *);
 
 REGEXP *mutt_compile_regexp(const char *, int);
diff --git a/status.c b/status.c
index 761cc2f2..522d333c 100644
--- a/status.c
+++ b/status.c
@@ -225,7 +225,7 @@ status_format_str(char *buf, size_t buflen, size_t col, int 
cols, char op, const
       else
       {
         count = (100 * (menu->top + menu->pagelen)) / menu->max;
-        snprintf(tmp, sizeof(tmp), "%d%%", count);
+        snprintf(tmp, sizeof(tmp), mutt_i18n_percentage(), count);
         cp = tmp;
       }
       snprintf(fmt, sizeof(fmt), "%%%ss", prefix);
-- 
2.54.0

Reply via email to