Index: osxlocale.c =================================================================== RCS file: /cvs/porting/sal/systools/macxp_extras/x11osx/osxlocale.c,v retrieving revision 1.3 diff -u -u -r1.3 osxlocale.c --- osxlocale.c 2 Feb 2004 19:02:19 -0000 1.3 +++ osxlocale.c 8 Apr 2005 08:28:02 -0000 @@ -2,9 +2,9 @@ * * $RCSfile: osxlocale.c,v $ * - * $Revision: 1.3 $ + * $Revision: 1.2.10.2.4.1 $ * - * last change: $Author: hr $ $Date: 2004/02/02 19:02:19 $ + * last change: $Author: khendricks $ $Date: 2004/08/08 13:44:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,11 +73,14 @@ */ int macxp_getOSXLocale( char *locale, sal_uInt32 bufferLen ) { - LocaleRef lref; + +#if (BUILD_OS_MAJOR == 10) && (BUILD_OS_MINOR == 2) +// Jaguar code + LocaleRef lref; CFArrayRef aref; CFStringRef sref; CFStringRef locNameRef; - + aref = (CFArrayRef)CFPreferencesCopyAppValue( CFSTR( "AppleLanguages" ), kCFPreferencesCurrentApplication ); if ( aref != NULL ) { @@ -86,29 +89,6 @@ sref = (CFStringRef)CFArrayGetValueAtIndex( aref, 0 ); if ( (sref != NULL) && (CFGetTypeID(sref) == CFStringGetTypeID()) ) { -#if (BUILD_OS_MAJOR==10) && (BUILD_OS_MINOR==3) -// Panther code - // This function only exists in Panther and above - locNameRef = CFLocaleCreateCanonicalLocaleIdentifierFromString( kCFAllocatorDefault, sref ); - - if ( locNameRef != NULL ) - { - CFStringGetCString( locNameRef, locale, bufferLen, kCFStringEncodingASCII ); - CFRelease( locNameRef ); - - // If its just en, we want en_US. Since all the locales are also - // UTF-8, we'll append UTF-8 to the end of all returned locales - if ( strcmp(locale, "en") == 0 ) - strlcpy( locale, "en_US", bufferLen ); -// else if ( strchr(locale, '.') == NULL ) -// strlcat( locale, ".UTF-8", bufferLen ); - } - else - fprintf( stderr, "Could not get Canonical Locale Identifier from AppleLanguages value!\n" ); -#endif - -#if (BUILD_OS_MAJOR == 10) && (BUILD_OS_MINOR == 2) -// Jaguar code if ( CFStringGetCString( sref, locale, bufferLen, CFStringGetSystemEncoding() ) ) { LocaleRefFromLocaleString( locale, &lref ); @@ -119,8 +99,11 @@ */ if ( (strlen(locale) == 2) && (strncmp(locale, "en", 2) == 0) ) strncat( locale, "_US", bufferLen - strlen(locale) - 1 ); + // For Japanese locale, just "ja" is not sufficient. + // Use "ja_JP.UTF-8" instead. + if ( (strlen(locale) == 2) && (strncmp(locale, "ja", 2) == 0) ) + strlcpy( locale, "ja_JP.UTF-8", bufferLen ); } -#endif } else fprintf( stderr, "Could not get array index 0 value of CFPref AppleLanguages!\n" ); @@ -132,6 +115,28 @@ fprintf( stderr, "Could not get value of CFPref AppleLanguages! Please reset your locale in the International control panel.\n" ); return( noErr ); + +#else +// Panther and later code + + CFStringRef lstr; + CFLocaleRef lref; + + lref = CFLocaleCopyCurrent(); + lstr = CFLocaleGetIdentifier(lref); + CFStringGetCString(lstr, locale, bufferLen, kCFStringEncodingASCII); + CFRelease(lref); + CFRelease(lstr); + + if ( strchr(locale, '.') == NULL ) + strlcat( locale, ".UTF-8", bufferLen ); + + // fprintf(stderr,"returned locale string is %s\n",locale); + + return ( noErr ); + +#endif + }