Re: [PATCH v2 05/11] i18n: add--interactive: mark message for translation
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 25, 2016, 23:09 UTC
- Message-ID
- <xmqqbmzby3tc.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1472646690-9699-6-git-send-email-vascomalmeida@sapo.pt>
Vasco Almeida <vascomalmeida@sapo.pt> writes:
Show 6 quoted lines
> - print colored $prompt_color, $patch_mode_flavour{VERB},
> - ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :
> - $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
> - ' this hunk'),
> - $patch_mode_flavour{TARGET},
> - " [y,n,q,a,d,/$other,?]? ";I hate to say this but expanding this single-liner into if/elsif/ cascade of uncountable number of arms is simply a disaster.
Show 15 quoted lines
> + if ($patch_mode eq 'stage') {
> + if ($hunk[$ix]{TYPE} eq 'mode') {
> + print colored $prompt_color,
> + sprintf(__("Stage mode change [y,n,q,a,d,/%s,?]? "), $other);
> + } elsif ($hunk[$ix]{TYPE} eq 'deletion') {
> + print colored $prompt_color,
> + sprintf(__("Stage deletion [y,n,q,a,d,/%s,?]? "), $other);
> + } else {
> + print colored $prompt_color,
> + sprintf(__("Stage this hunk [y,n,q,a,d,/%s,?]? "), $other);
> + }
> + } elsif ($patch_mode eq 'stash') {
> + ...
> + }
> + }I wonder if you can make a simple helper function so that the caller here can still be a single-liner:
print_colored $prompt_color,
sprintf(patch_update_prompt_string($patch_mode, $hunk[$ix]{TYPE}), $other);
where the patch_update_prompt_string helper function would look up
these messages from a table that is looked up by patch-mode and TYPE
and the run __() on it, or something?