~kevin8t8/mutt

9723c62c88209b6e35e4a488388079f183c427af — Kevin McCarthy a month ago 4aedee8
Allow tagging string config vars as L10N.

Translate them once in mutt_set_default().

Modify makedoc.pl to remove the N_() tag, and to also note the type as
"string (localized)".

The makedoc.pl already will ignore L10N comment so add a basic comment
above each config var in init.h.

I'm not tagging $crypt_protected_headers_subject because the spec now
says this should be "...".  I plan on implementing that change along
with other fixes before the next release.
4 files changed, 49 insertions(+), 10 deletions(-)

M doc/makedoc.pl
M init.c
M init.h
M po/POTFILES.in
M doc/makedoc.pl => doc/makedoc.pl +17 -3
@@ 107,13 107,15 @@ my %type2human = ("DT_NONE"  => "-none-",
                  "DT_RX"    => "regular expression",
                  "DT_MAGIC" => "folder magic",
                  "DT_ADDR"  => "e-mail address",
                  "DT_MBCHARTBL"=> "string");
                  "DT_MBCHARTBL"=> "string",
                  "DT_L10N_STR" => "string (localized)");

my %string_types = ("DT_STR"  => 1,
                    "DT_RX"   => 1,
                    "DT_ADDR" => 1,
                    "DT_PATH" => 1,
                    "DT_MBCHARTBL" => 1);
                    "DT_MBCHARTBL" => 1,
                    "DT_L10N_STR"  => 1);

my %quad2human = ("MUTT_YES" => "yes",
                  "MUTT_NO"  => "no",


@@ 239,13 241,25 @@ sub flush_doc($) {
sub handle_confline($) {
  my ($line) = @_;

  my $localized = 0;
  my ($name, $type, $flags, $data, $val) = split(/\s*,\s*/, $line, 5);
  $name =~ s/"//g;

  $type =~ s/\|.*//;
  if ($type =~ /DT_L10N_STR/) {
    $localized = 1;
    $type = "DT_L10N_STR";
  }
  else {
    $type =~ s/\|.*//;
  }

  $val =~ s/^{\s*\.[lp]\s*=\s*"?//;
  $val =~ s/"?\s*}\s*},\s*$//;
  if ($localized) {
    $val =~ s/^N_\s*\("//;
    $val =~ s/"\)$//;
  }

  # This is a hack to concatenate compile-time constants.
  # (?<!..) is a zero-width negative lookbehind assertion, asserting
  # the first quote isn't preceded by a backslash

M init.c => init.c +2 -0
@@ 1757,6 1757,8 @@ static void mutt_set_default (struct option_t *p)
    case DT_PATH:
      if (!p->init.p && *((char **) p->data.p))
        p->init.p = safe_strdup (* ((char **) p->data.p));
      else if (p->init.p && (p->type & DT_L10N_STR))
        p->init.p = safe_strdup (_(p->init.p));
      break;
    case DT_ADDR:
      if (!p->init.p && *((ADDRESS **) p->data.p))

M init.h => init.h +29 -7
@@ 51,6 51,7 @@
#define DT_SORT_KEYS	0x40
#define DT_SORT_AUX	0x80
#define DT_SORT_SIDEBAR	0x100
#define DT_L10N_STR     0x200

/* flags to parse_set() */
#define MUTT_SET_INV	(1<<0)	/* default is to invert all vars */


@@ 281,7 282,10 @@ struct option_t MuttVars[] = {
  ** $$attach_sep separator is added after each attachment. When \fIset\fP,
  ** Mutt will operate on the attachments one by one.
  */
  { "attribution",	DT_STR,	 R_NONE, {.p=&Attribution}, {.p="On %d, %n wrote:"} },
  /* L10N:
     $attribution default value
  */
  { "attribution",	DT_STR|DT_L10N_STR, R_NONE, {.p=&Attribution}, {.p=N_("On %d, %n wrote:")} },
  /*
  ** .pp
  ** This is the string that will precede a message which has been included


@@ 544,7 548,10 @@ struct option_t MuttVars[] = {
  ** When \fIunset\fP, Mutt will not collapse a thread if it contains any
  ** unread messages.
  */
  { "compose_format",	DT_STR,	 R_MENU, {.p=&ComposeFormat}, {.p="-- Mutt: Compose  [Approx. msg size: %l   Atts: %a]%>-"} },
  /* L10N:
     $compose_format default value
  */
  { "compose_format",	DT_STR|DT_L10N_STR, R_MENU, {.p=&ComposeFormat}, {.p=N_("-- Mutt: Compose  [Approx. msg size: %l   Atts: %a]%>-")} },
  /*
  ** .pp
  ** Controls the format of the status line displayed in the ``compose''


@@ 1159,7 1166,10 @@ struct option_t MuttVars[] = {
  ** to the newly composed message if this quadoption is \fIset\fP or
  ** answered with ``yes''.
  */
  { "forward_attribution_intro", DT_STR, R_NONE, {.p=&ForwardAttrIntro}, {.p="----- Forwarded message from %f -----"} },
  /* L10N:
     $forward_attribution_intro default value
  */
  { "forward_attribution_intro", DT_STR|DT_L10N_STR, R_NONE, {.p=&ForwardAttrIntro}, {.p=N_("----- Forwarded message from %f -----")} },
  /*
  ** .pp
  ** This is the string that will precede a message which has been forwarded


@@ 1167,7 1177,10 @@ struct option_t MuttVars[] = {
  ** For a full listing of defined \fCprintf(3)\fP-like sequences see
  ** the section on $$index_format.  See also $$attribution_locale.
  */
  { "forward_attribution_trailer", DT_STR, R_NONE, {.p=&ForwardAttrTrailer}, {.p="----- End forwarded message -----"} },
  /* L10N:
     $forward_attribution_trailer default value
  */
  { "forward_attribution_trailer", DT_STR|DT_L10N_STR, R_NONE, {.p=&ForwardAttrTrailer}, {.p=N_("----- End forwarded message -----")} },
  /*
  ** .pp
  ** This is the string that will follow a message which has been forwarded


@@ 4077,7 4090,10 @@ struct option_t MuttVars[] = {
  ** message mode (Certain operations like composing a new mail, replying,
  ** forwarding, etc. are not permitted in this mode).
  */
  { "status_format",	DT_STR,	 R_BOTH, {.p=&Status}, {.p="-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?B? Back:%B?%?l? %l?]---(%s/%S)-%>-(%P)---"} },
  /* L10N:
     $status_format default value
  */
  { "status_format", DT_STR|DT_L10N_STR, R_BOTH, {.p=&Status}, {.p=N_("-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?B? Back:%B?%?l? %l?]---(%s/%S)-%>-(%P)---")} },
  /*
  ** .pp
  ** Controls the format of the status line displayed in the ``index''


@@ 4277,7 4293,10 @@ struct option_t MuttVars[] = {
  ** NOTE: When you delete a message in the trash folder, it is really
  ** deleted, so that you have a way to clean the trash.
  */
  {"ts_icon_format",	DT_STR,  R_BOTH, {.p=&TSIconFormat}, {.p="M%?n?AIL&ail?"} },
  /* L10N:
     $ts_icon_format default value
  */
  {"ts_icon_format", DT_STR|DT_L10N_STR, R_BOTH, {.p=&TSIconFormat}, {.p=N_("M%?n?AIL&ail?")} },
  /*
  ** .pp
  ** Controls the format of the icon title, as long as ``$$ts_enabled'' is set.


@@ 4291,7 4310,10 @@ struct option_t MuttVars[] = {
  ** Controls whether mutt tries to set the terminal status line and icon name.
  ** Most terminal emulators emulate the status line in the window title.
  */
  {"ts_status_format",	DT_STR,   R_BOTH, {.p=&TSStatusFormat}, {.p="Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"} },
  /* L10N:
     $ts_status_format default value
  */
  {"ts_status_format", DT_STR|DT_L10N_STR, R_BOTH, {.p=&TSStatusFormat}, {.p=N_("Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?")} },
  /*
  ** .pp
  ** Controls the format of the terminal status line (or window title),

M po/POTFILES.in => po/POTFILES.in +1 -0
@@ 42,6 42,7 @@ imap/imap.c
imap/message.c
imap/util.c
init.c
init.h
keymap.c
lib.c
main.c