Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
[Freeciv-Dev] Re: I18n patch
Home

[Freeciv-Dev] Re: I18n patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: wooledge@xxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: I18n patch
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sun, 19 Sep 1999 14:58:46 +1000 (EST)

Greg Wooledge wrote:

> Well, I guess the "right" way to deal with this would be to initialize
> the array explicity in code.  It's not as efficient, but correctness is
> more important than efficiency.

Efficiency doesn't count for much if it doesn't work? :-)

> How about this?

Yeah, that would work, though I think I prefer the following
(untested; similar principle) based on a suggestion by Jeff 
Mallatt;

  static char *titles_[6]= {N_("Server Name"), N_("Port"), N_("Version"),
                            N_("Status"), N_("Players"), N_("Comment")};
  static char **titles;

  if (!titles) titles = intl_slist(6, titles_);

where:

/**************************************************************************
  Returns gettext-converted list of n strings.  Allocates the space
  for the returned list, but the individual strings in the list are
  as returned by gettext().  In case of no NLS, the strings will be
  the original strings, so caller should ensure that the originals
  persist for as long as required.  (For no NLS, still allocate the
  list, for consistency.)
**************************************************************************/
char **intl_slist(int n, char **s)
{
  char **ret = fc_malloc(n * sizeof(char*));
  int i;

  for(i=0; i<n; i++) {
    ret[i] = _(s[i]);
  }
  return ret;
}


-- David

[Prev in Thread] Current Thread [Next in Thread]