mirror of
https://git.zap.org.au/git/trader.git
synced 2025-02-02 15:08:13 -05:00
Refactor locale initialisation into init_locale()
This commit is contained in:
parent
aa0e539540
commit
535f4cf965
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
17
src/utils.c
17
src/utils.c
@ -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
|
||||
|
||||
|
14
src/utils.h
14
src/utils.h
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user