1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-09-29 17:45:55 -04:00

Refactor locale initialisation into init_locale()

This commit is contained in:
John Zaitseff 2021-01-14 12:28:02 +11:00
parent aa0e539540
commit 535f4cf965
3 changed files with 32 additions and 8 deletions

View File

@ -373,14 +373,7 @@ void init_program_prelim (int argc, char *argv[])
init_program_name(argv[0]);
// Initialise the locale and message catalogs
if (setlocale(LC_ALL, "") == NULL) {
err_exit("could not set locale "
"(check LANG, LC_ALL and LANGUAGE in environment)");
}
// Use correct message catalogs for the locale
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
init_locale();
}

View File

@ -581,6 +581,23 @@ extern int randi (int limit)
// These functions are documented in the file "utils.h"
/***********************************************************************/
// init_locale: Initialise locale and message catalogs
extern void init_locale (void)
{
// Initialise the current locale
if (setlocale(LC_ALL, "") == NULL) {
err_exit("could not set locale "
"(check LANG, LC_ALL and LANGUAGE in environment)");
}
// Use correct message catalogs for the locale
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
}
/***********************************************************************/
// init_locale_vars: Initialise locale-specific variables

View File

@ -229,6 +229,20 @@ extern int randi (int limit);
* Locale-aware function prototypes *
************************************************************************/
/*
Function: init_locale - Initialise locale and message catalogs
Parameters: (none)
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.
*/
extern void init_locale (void);
/*
Function: init_locale_vars - Initialise locale-specific variables
Parameters: (none)