[Freeciv-Dev] Re: I18n patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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
|
|