From: Bruno Haible Date: Mon, 6 Sep 2004 10:34:00 +0000 (+0000) Subject: Support for determining the user's language preferences on MacOS X. X-Git-Tag: v0.14.2~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ebf85fc71ce5308231137429e3dbdced88d2bb1;p=thirdparty%2Fgettext.git Support for determining the user's language preferences on MacOS X. --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index 1111b9ddb..b1d6f98bd 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,17 @@ +2004-09-05 Bruno Haible + + * langprefs.c: New file. + * gettextP.h (_nl_language_preferences): New declaration. + * dcigettext.c (guess_category_value) [!_LIBC]: Use + _nl_language_preferences. + * Makefile.in (SOURCES): Add langprefs.c. + (OBJECTS): Add langprefs.$lo. + (langprefs.lo): New rule. + * Makefile.msvc (OBJECTS): Add langprefs.obj. + (langprefs.obj): New rule. + * Makefile.vms (OBJECTS): Add langprefs.obj. + (langprefs.obj): New rule. + 2004-09-03 Bruno Haible * localename.c (_nl_locale_name): Use a more intelligent fallback on diff --git a/gettext-runtime/intl/Makefile.in b/gettext-runtime/intl/Makefile.in index 4a9f2bbd0..715961782 100644 --- a/gettext-runtime/intl/Makefile.in +++ b/gettext-runtime/intl/Makefile.in @@ -98,6 +98,7 @@ SOURCES = \ plural-exp.c \ localcharset.c \ relocatable.c \ + langprefs.c \ localename.c \ log.c \ printf.c \ @@ -123,6 +124,7 @@ OBJECTS = \ plural-exp.$lo \ localcharset.$lo \ relocatable.$lo \ + langprefs.$lo \ localename.$lo \ log.$lo \ printf.$lo \ @@ -212,6 +214,8 @@ localcharset.lo: $(srcdir)/localcharset.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c relocatable.lo: $(srcdir)/relocatable.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c +langprefs.lo: $(srcdir)/langprefs.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/langprefs.c localename.lo: $(srcdir)/localename.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localename.c log.lo: $(srcdir)/log.c diff --git a/gettext-runtime/intl/Makefile.msvc b/gettext-runtime/intl/Makefile.msvc index 7fbb2f75c..038321ee2 100644 --- a/gettext-runtime/intl/Makefile.msvc +++ b/gettext-runtime/intl/Makefile.msvc @@ -99,7 +99,7 @@ INSTALL_DATA = copy SHELL = /bin/sh -OBJECTS = bindtextdom.obj dcgettext.obj dgettext.obj gettext.obj finddomain.obj loadmsgcat.obj localealias.obj textdomain.obj l10nflist.obj explodename.obj dcigettext.obj dcngettext.obj dngettext.obj ngettext.obj plural.obj plural-exp.obj localcharset.obj relocatable.obj localename.obj log.obj printf.obj osdep.obj intl-compat.obj +OBJECTS = bindtextdom.obj dcgettext.obj dgettext.obj gettext.obj finddomain.obj loadmsgcat.obj localealias.obj textdomain.obj l10nflist.obj explodename.obj dcigettext.obj dcngettext.obj dngettext.obj ngettext.obj plural.obj plural-exp.obj localcharset.obj relocatable.obj langprefs.obj localename.obj log.obj printf.obj osdep.obj intl-compat.obj RESOURCES = intl.res @@ -166,6 +166,9 @@ localcharset.obj : $(srcdir)\localcharset.c libgnuintl.h $(srcdir)\localcharset. relocatable.obj : $(srcdir)\relocatable.c libgnuintl.h $(srcdir)\relocatable.h $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\relocatable.c +langprefs.obj : $(srcdir)\langprefs.c libgnuintl.h + $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\langprefs.c + localename.obj : $(srcdir)\localename.c libgnuintl.h $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\localename.c diff --git a/gettext-runtime/intl/Makefile.vms b/gettext-runtime/intl/Makefile.vms index 97ab01129..aa5be49d8 100644 --- a/gettext-runtime/intl/Makefile.vms +++ b/gettext-runtime/intl/Makefile.vms @@ -45,7 +45,7 @@ INSTALL_DATA = copy #### End of system configuration section. #### -OBJECTS = bindtextdom.obj,dcgettext.obj,dgettext.obj,gettext.obj,finddomain.obj,loadmsgcat.obj,localealias.obj,textdomain.obj,l10nflist.obj,explodename.obj,dcigettext.obj,dcngettext.obj,dngettext.obj,ngettext.obj,plural-parse.obj,plural-exp.obj,localcharset.obj,relocatable.obj,localename.obj,log.obj,osdep.obj,intl-compat.obj +OBJECTS = bindtextdom.obj,dcgettext.obj,dgettext.obj,gettext.obj,finddomain.obj,loadmsgcat.obj,localealias.obj,textdomain.obj,l10nflist.obj,explodename.obj,dcigettext.obj,dcngettext.obj,dngettext.obj,ngettext.obj,plural-parse.obj,plural-exp.obj,localcharset.obj,relocatable.obj,langprefs.obj,localename.obj,log.obj,osdep.obj,intl-compat.obj all : intl.olb,libintl.h write sys$output "Nothing else to be done for 'all'." @@ -107,6 +107,9 @@ localcharset.obj : $(srcdir)localcharset.c,libgnuintl.h,$(srcdir)localcharset.h, relocatable.obj : $(srcdir)relocatable.c,libgnuintl.h,$(srcdir)relocatable.h $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)relocatable.c +langprefs.obj : $(srcdir)langprefs.c,libgnuintl.h + $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)langprefs.c + localename.obj : $(srcdir)localename.c,libgnuintl.h $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)localename.c diff --git a/gettext-runtime/intl/dcigettext.c b/gettext-runtime/intl/dcigettext.c index 43765ab5e..ed455b9d5 100644 --- a/gettext-runtime/intl/dcigettext.c +++ b/gettext-runtime/intl/dcigettext.c @@ -1133,9 +1133,13 @@ guess_category_value (int category, const char *categoryname) /* The highest priority value is the `LANGUAGE' environment variable. But we don't use the value if the currently selected locale is the C locale. This is a GNU extension. */ +#ifdef _LIBC language = getenv ("LANGUAGE"); if (language != NULL && language[0] == '\0') language = NULL; +#else + language = _nl_language_preferences (); +#endif /* We have to proceed with the POSIX methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some systems this can be done by the diff --git a/gettext-runtime/intl/gettextP.h b/gettext-runtime/intl/gettextP.h index 4d66c3de3..956f817e3 100644 --- a/gettext-runtime/intl/gettextP.h +++ b/gettext-runtime/intl/gettextP.h @@ -1,5 +1,5 @@ /* Header describing internals of libintl library. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. Written by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify it @@ -151,6 +151,7 @@ struct binding extern int _nl_msg_cat_cntr; #ifndef _LIBC +const char *_nl_language_preferences (void); const char *_nl_locale_name (int category, const char *categoryname); #endif diff --git a/gettext-runtime/m4/ChangeLog b/gettext-runtime/m4/ChangeLog index e25651e73..da472d859 100644 --- a/gettext-runtime/m4/ChangeLog +++ b/gettext-runtime/m4/ChangeLog @@ -1,3 +1,7 @@ +2004-09-05 Bruno Haible + + * gettext.m4 (AM_INTL_SUBDIR): Test for CFPreferencesCopyAppValue. + 2004-09-03 Bruno Haible * gettext.m4 (AM_INTL_SUBDIR): Add a test for CFLocaleCopyCurrent. diff --git a/gettext-runtime/m4/gettext.m4 b/gettext-runtime/m4/gettext.m4 index 3d19644b5..d27e52ab2 100644 --- a/gettext-runtime/m4/gettext.m4 +++ b/gettext-runtime/m4/gettext.m4 @@ -431,6 +431,23 @@ __fsetlocking]) gt_LC_MESSAGES fi + dnl Check for API introduced in MacOS X 10.2. + AC_CACHE_CHECK([for CFPreferencesCopyAppValue], + gt_cv_func_CFPreferencesCopyAppValue, + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" + gt_save_LIBS="$LIBS" + LIBS="$LIBS -framework CoreFoundation" + AC_TRY_LINK([#include ], + [CFPreferencesCopyAppValue(NULL, NULL)], + [gt_cv_func_CFPreferencesCopyAppValue=yes], + [gt_cv_func_CFPreferencesCopyAppValue=no]) + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, + [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) + fi dnl Check for API introduced in MacOS X 10.3. AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, [gt_save_CPPFLAGS="$CPPFLAGS" @@ -438,16 +455,18 @@ __fsetlocking]) gt_save_LIBS="$LIBS" LIBS="$LIBS -framework CoreFoundation" AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], - [gt_cv_func_CFLocaleCopyCurrent=yes], [gt_cv_func_CFLocaleCopyCurrent=no]) + [gt_cv_func_CFLocaleCopyCurrent=yes], + [gt_cv_func_CFLocaleCopyCurrent=no]) CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFLocaleCopyCurrent = yes; then AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) + fi + INTL_MACOSX_LDFLAGS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" INTL_MACOSX_LDFLAGS="-Wl,-framework -Wl,CoreFoundation" - else - INTL_MACOSX_LDFLAGS= fi AC_SUBST([INTL_MACOSX_LDFLAGS])