1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-12-04 14:46:45 -05:00

Allow TEXTDOMAINDIR to specify the message catalog path

This commit is contained in:
John Zaitseff 2021-01-14 13:06:31 +11:00
parent 535f4cf965
commit 2cc2dfffd5
4 changed files with 22 additions and 6 deletions

4
NEWS
View File

@ -25,6 +25,10 @@ __ https://www.zap.org.au/
Version 7.16 (not yet released)
-------------------------------
Added code to allow the ``TEXTDOMAINDIR`` environment variable to specify
where compiled translations are located. Updated the documentation to
mention this new feature.
Added an application metadata file that conforms to the AppStream 0.12
specification. Updated all translations to suit, using parts of existing
strings.

View File

@ -41,7 +41,7 @@
.if \n[.g] .mso www.tmac
.\"
.\" *********************************************************************
.TH TRADER 6 "12th January, 2021" "Unix-like systems"
.TH TRADER 6 "14th January, 2021" "Unix-like systems"
.SH NAME
trader \- a game of interstellar trading
.\" *********************************************************************
@ -183,6 +183,12 @@ using \fBLC_NUMERIC\fP and monetary quantities will use
or
.BR setlocale (3)
manual pages for more details on locale settings.
.TP
.B TEXTDOMAINDIR
If set, Star Traders will use this path as the base with which to locate
its message catalogs instead of the compiled-in path; the relevant
\fItrader.mo\fP files should be located in language-code subdirectories
(such as \fIen_AU\fP), in \fILC_MESSAGES\fP sub-subdirectories.
.\" *********************************************************************
.SH FILES
.TP

View File

@ -586,6 +586,9 @@ extern int randi (int limit)
extern void init_locale (void)
{
const char *podir = getenv("TEXTDOMAINDIR");
// Initialise the current locale
if (setlocale(LC_ALL, "") == NULL) {
err_exit("could not set locale "
@ -593,7 +596,9 @@ extern void init_locale (void)
}
// Use correct message catalogs for the locale
bindtextdomain(PACKAGE, LOCALEDIR);
bindtextdomain(
PACKAGE,
(podir != NULL && *podir != '\0') ? podir : LOCALEDIR);
textdomain(PACKAGE);
}

View File

@ -235,10 +235,11 @@ extern int randi (int limit);
Returns: (nothing)
This function initialises the locale and message catalog used by this
program. The message catalog must reside in the location specified
during "./configure" via the "--localedir" option; this location is
passed to this source code file as PREFIXDIR. This function must be
called before using any locale or Gettext functions.
program. If the TEXTDOMAINDIR environment variable is set, the message
catalog must reside in that location, otherwise it must be in the
location specified during "./configure" via the "--localedir" option.
This function must be called before using any locale or Gettext
functions.
*/
extern void init_locale (void);