- char *save_textdom = textdomain(NULL);
- setlocale(LC_ALL, ""); /* In fact only necessary if main program doesn't
- do this */
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
+ save_locale = strdup(locale);
+ if (! save_locale) {
+ MEMORY_ERROR;
+ return result;
+ }
+
+ save_textdom = textdomain(NULL);
+ if (!save_textdom) {
+ gedcom_error(_("Could not retrieve locale domain: %s"), strerror(errno));
+ return result;
+ }
+
+ if (! setlocale(LC_ALL, "")
+ || ! bindtextdomain(PACKAGE, LOCALEDIR)
+ || ! bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING)
+ || ! textdomain(PACKAGE)) {
+ gedcom_error(_("Could not set locale: %s"), strerror(errno));
+ return result;
+ }