]> code.delx.au - gnu-emacs/blobdiff - src/nsterm.m
Set locale when run from OS X GUI
[gnu-emacs] / src / nsterm.m
index f77aadba67c59712b69d3fc82f23031876fe8ccb..43d1377f8a717cf6b9be8661fb2acb5d4cbb693a 100644 (file)
@@ -585,6 +585,27 @@ ns_load_path (void)
 }
 
 
+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)
 /* --------------------------------------------------------------------------