Re: [PATCH v7 14/17] ref-filter: allow porcelain to translate messages in the output
- From
Jakub Narębski <jnareb@gmail.com>
- Date
- Nov 18, 2016, 22:46 UTC
- Message-ID
- <af0b7bdc-2b29-0d04-85f1-aa1d5a2ba549@gmail.com>
- In-Reply-To
- <20161108201211.25213-15-Karthik.188@gmail.com>
W dniu 08.11.2016 o 21:12, Karthik Nayak pisze:
Show 42 quoted lines
> From: Karthik Nayak <karthik.188@gmail.com>
>
> Introduce setup_ref_filter_porcelain_msg() so that the messages used in
> the atom %(upstream:track) can be translated if needed. This is needed
> as we port branch.c to use ref-filter's printing API's.
>
> Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
> Mentored-by: Christian Couder <christian.couder@gmail.com>
> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
> ref-filter.c | 28 ++++++++++++++++++++++++----
> ref-filter.h | 2 ++
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index b47b900..944671a 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -15,6 +15,26 @@
> #include "version.h"
> #include "wt-status.h"
>
> +static struct ref_msg {
> + const char *gone;
> + const char *ahead;
> + const char *behind;
> + const char *ahead_behind;
> +} msgs = {
> + "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");
> +}Do I understand it correctly that this mechanism is here to avoid repeated calls into gettext, as those messages would get repeated over and over; otherwise one would use foo = N_("...") and _(foo), isn't it?
I wonder if there is some way to avoid duplication here, but I don't see anything easy and safe (e.g. against running setup_*() twice).
Best,
-- Jakub Narębski