init_ntproc (dumping); /* must precede init_editfns. */
#endif
+#ifdef HAVE_NS
+ /* Initialise the locale from user defaults. */
+ ns_init_locale();
+#endif
+
/* Initialize and GC-protect Vinitial_environment and
Vprocess_environment before set_initial_environment fills them
in. */
extern void *ns_alloc_autorelease_pool (void);
extern void ns_release_autorelease_pool (void *);
extern const char *ns_get_defaults_value (const char *key);
+extern void ns_init_locale (void);
+
/* in nsmenu */
extern void update_frame_tool_bar (struct frame *f);
}
+void
+ns_init_locale (void)
+/* OS X doesn't set any environment variables for the locale when run
+ from the GUI. Get the locale from the OS and set LANG. */
+{
+ NSLocale *locale = [NSLocale currentLocale];
+
+ NSTRACE ("ns_init_locale");
+
+ @try
+ {
+ /* Set LANG to locale, but not if LANG is already set. */
+ setenv("LANG", [[locale localeIdentifier] UTF8String], 0);
+ }
+ @catch (NSException *e)
+ {
+ NSLog (@"Locale detection failed: %@: %@", [e name], [e reason]);
+ }
+}
+
+
void
ns_release_object (void *obj)
/* --------------------------------------------------------------------------