ref-filter: allow porcelain to translate messages in the output
[git/git.git] / ref-filter.c
index 47e292b..01b5c18 100644 (file)
 #include "trailer.h"
 #include "wt-status.h"
 
 #include "trailer.h"
 #include "wt-status.h"
 
+static struct ref_msg {
+       const char *gone;
+       const char *ahead;
+       const char *behind;
+       const char *ahead_behind;
+} msgs = {
+        /* Untranslated plumbing messages: */
+       "gone",
+       "ahead %d",
+       "behind %d",
+       "ahead %d, behind %d"
+};
+
+void setup_ref_filter_porcelain_msg(void)
+{
+       msgs.gone = _("gone");
+       msgs.ahead = _("ahead %d");
+       msgs.behind = _("behind %d");
+       msgs.ahead_behind = _("ahead %d, behind %d");
+}
+
 typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
 typedef enum { COMPARE_EQUAL, COMPARE_UNEQUAL, COMPARE_NONE } cmp_status;
 
 typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
 typedef enum { COMPARE_EQUAL, COMPARE_UNEQUAL, COMPARE_NONE } cmp_status;
 
@@ -1181,15 +1202,15 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
        else if (atom->u.remote_ref.option == RR_TRACK) {
                if (stat_tracking_info(branch, &num_ours,
                                       &num_theirs, NULL)) {
        else if (atom->u.remote_ref.option == RR_TRACK) {
                if (stat_tracking_info(branch, &num_ours,
                                       &num_theirs, NULL)) {
-                       *s = xstrdup("gone");
+                       *s = xstrdup(msgs.gone);
                } else if (!num_ours && !num_theirs)
                        *s = "";
                else if (!num_ours)
                } else if (!num_ours && !num_theirs)
                        *s = "";
                else if (!num_ours)
-                       *s = xstrfmt("behind %d", num_theirs);
+                       *s = xstrfmt(msgs.behind, num_theirs);
                else if (!num_theirs)
                else if (!num_theirs)
-                       *s = xstrfmt("ahead %d", num_ours);
+                       *s = xstrfmt(msgs.ahead, num_ours);
                else
                else
-                       *s = xstrfmt("ahead %d, behind %d",
+                       *s = xstrfmt(msgs.ahead_behind,
                                     num_ours, num_theirs);
                if (!atom->u.remote_ref.nobracket && *s[0]) {
                        const char *to_free = *s;
                                     num_ours, num_theirs);
                if (!atom->u.remote_ref.nobracket && *s[0]) {
                        const char *to_free = *s;