mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Make NSLocale use information about libicu availablity (perviously, it would
never build the ICU stuff because the corresponding macro wasn't defined). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30995 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b666cd6884
commit
4848c265e9
4 changed files with 68 additions and 57 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2010-07-19 Niels Grewe <niels.grewe@halbordnung.de>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepBase/GSConfig.h: Define GS_USE_ICU when
|
||||||
|
the configure script indicates libicu availablity.
|
||||||
|
* Headers/Foundation/Foundation.h: Import NSLocale.h
|
||||||
|
* Source/NSLocale.m: Change tests to use GS_USE_ICU.
|
||||||
|
Make sure that the parts of NSLocale relying on ICU actually get built
|
||||||
|
when libicu is available.
|
||||||
|
|
||||||
2010-07-17 Quentin Mathe <quentin.mathe@gmail.com>
|
2010-07-17 Quentin Mathe <quentin.mathe@gmail.com>
|
||||||
|
|
||||||
* Tools/autogsdoc.m:
|
* Tools/autogsdoc.m:
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#if !defined(NeXT_Foundation_LIBRARY)
|
#if !defined(NeXT_Foundation_LIBRARY)
|
||||||
|
|
||||||
/* An alternate to GS_FAKE_MAIN which forces the user to call the
|
/* An alternate to GS_FAKE_MAIN which forces the user to call the
|
||||||
NSProcessInfo initialization in 'main', GS_FAKE_MAIN must also
|
NSProcessInfo initialization in 'main', GS_FAKE_MAIN must also
|
||||||
be undefined. */
|
be undefined. */
|
||||||
#if @GS_PASS_ARGUMENTS@
|
#if @GS_PASS_ARGUMENTS@
|
||||||
|
@ -223,6 +223,7 @@ typedef struct {
|
||||||
#define GS_MIXEDABI @GS_MIXEDABI@
|
#define GS_MIXEDABI @GS_MIXEDABI@
|
||||||
#define GS_USE_AVAHI @HAVE_AVAHI@
|
#define GS_USE_AVAHI @HAVE_AVAHI@
|
||||||
#define GS_USE_MDNS @HAVE_MDNS@
|
#define GS_USE_MDNS @HAVE_MDNS@
|
||||||
|
#define GS_USE_ICU @HAVE_ICU@
|
||||||
#import <GNUstepBase/preface.h>
|
#import <GNUstepBase/preface.h>
|
||||||
|
|
||||||
#endif /* included_GSConfig_h */
|
#endif /* included_GSConfig_h */
|
||||||
|
|
|
@ -5,24 +5,24 @@
|
||||||
|
|
||||||
Written by: Scott Christley <scottc@net-community.com>
|
Written by: Scott Christley <scottc@net-community.com>
|
||||||
Date: Sep 1997
|
Date: Sep 1997
|
||||||
|
|
||||||
This file is part of the GNUstep Base Library.
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free
|
License along with this library; if not, write to the Free
|
||||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02111 USA.
|
Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __Foundation_h_GNUSTEP_BASE_INCLUDE
|
#ifndef __Foundation_h_GNUSTEP_BASE_INCLUDE
|
||||||
#define __Foundation_h_GNUSTEP_BASE_INCLUDE
|
#define __Foundation_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
@ -78,6 +78,7 @@
|
||||||
#import <Foundation/NSKeyedArchiver.h>
|
#import <Foundation/NSKeyedArchiver.h>
|
||||||
#import <Foundation/NSKeyValueCoding.h>
|
#import <Foundation/NSKeyValueCoding.h>
|
||||||
#import <Foundation/NSKeyValueObserving.h>
|
#import <Foundation/NSKeyValueObserving.h>
|
||||||
|
#import <Foundation/NSLocale.h>
|
||||||
#import <Foundation/NSLock.h>
|
#import <Foundation/NSLock.h>
|
||||||
#import <Foundation/NSMapTable.h>
|
#import <Foundation/NSMapTable.h>
|
||||||
#import <Foundation/NSMethodSignature.h>
|
#import <Foundation/NSMethodSignature.h>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* NSLocale.m
|
/* NSLocale.m
|
||||||
|
|
||||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Stefan Bidigaray
|
Written by: Stefan Bidigaray
|
||||||
Date: June, 2010
|
Date: June, 2010
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; see the file COPYING.LIB.
|
License along with this library; see the file COPYING.LIB.
|
||||||
If not, see <http://www.gnu.org/licenses/> or write to the
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||||
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
NSMutableArray *currencies = [[NSMutableArray alloc] initWithCapacity: 10];
|
NSMutableArray *currencies = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
UErrorCode error = U_ZERO_ERROR;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
char *currCode;
|
const char *currCode;
|
||||||
UEnumeration *codes = ucurr_openISOCurrencies (currType, &error);
|
UEnumeration *codes = ucurr_openISOCurrencies (currType, &error);
|
||||||
if (U_FAILURE(error))
|
if (U_FAILURE(error))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int32_t strLength;
|
int32_t strLength;
|
||||||
|
@ -143,7 +143,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
[currencies addObject: [NSString stringWithCString: currCode
|
[currencies addObject: [NSString stringWithCString: currCode
|
||||||
length: strLength]];
|
length: strLength]];
|
||||||
} while (NULL != currCode);
|
} while (NULL != currCode);
|
||||||
|
|
||||||
uenum_close (codes);
|
uenum_close (codes);
|
||||||
result = [NSArray arrayWithArray: currencies];
|
result = [NSArray arrayWithArray: currencies];
|
||||||
RELEASE (currencies);
|
RELEASE (currencies);
|
||||||
|
@ -165,12 +165,12 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
NSLocale *result;
|
NSLocale *result;
|
||||||
|
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == autoupdatingLocale)
|
if (nil == autoupdatingLocale)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
result = RETAIN(autoupdatingLocale);
|
result = RETAIN(autoupdatingLocale);
|
||||||
[classLock unlock];
|
[classLock unlock];
|
||||||
return AUTORELEASE(result);
|
return AUTORELEASE(result);
|
||||||
|
@ -180,7 +180,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
{
|
{
|
||||||
static NSArray *available = nil;
|
static NSArray *available = nil;
|
||||||
|
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
if (nil == available)
|
if (nil == available)
|
||||||
{
|
{
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
|
@ -191,7 +191,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
int32_t count = uloc_countAvailable ();
|
int32_t count = uloc_countAvailable ();
|
||||||
|
|
||||||
array = [[NSMutableArray alloc] initWithCapacity: count];
|
array = [[NSMutableArray alloc] initWithCapacity: count];
|
||||||
|
|
||||||
for (i = 1; i <= count; ++i)
|
for (i = 1; i <= count; ++i)
|
||||||
{
|
{
|
||||||
const char *localeID = uloc_getAvailable (i);
|
const char *localeID = uloc_getAvailable (i);
|
||||||
|
@ -222,14 +222,14 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
+ (NSLocaleLanguageDirection) characterDirectionForLanguage:
|
+ (NSLocaleLanguageDirection) characterDirectionForLanguage:
|
||||||
(NSString *)isoLangCode
|
(NSString *)isoLangCode
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
ULayoutType result;
|
ULayoutType result;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
|
||||||
result = uloc_getCharacterOrientation ([isoLangCode cString], &status);
|
result = uloc_getCharacterOrientation ([isoLangCode cString], &status);
|
||||||
if (U_FAILURE(status) || ULOC_LAYOUT_UNKNOWN == result)
|
if (U_FAILURE(status) || ULOC_LAYOUT_UNKNOWN == result)
|
||||||
return NSLocaleLanguageDirectionUnknown;
|
return NSLocaleLanguageDirectionUnknown;
|
||||||
|
|
||||||
return _ICUToNSLocaleOrientation (result);
|
return _ICUToNSLocaleOrientation (result);
|
||||||
#else
|
#else
|
||||||
return NSLocaleLanguageDirectionLeftToRight; // FIXME
|
return NSLocaleLanguageDirectionLeftToRight; // FIXME
|
||||||
|
@ -238,14 +238,14 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSDictionary *) componentsFromLocaleIdentifier: (NSString *) string
|
+ (NSDictionary *) componentsFromLocaleIdentifier: (NSString *) string
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
char buffer[ULOC_LANG_CAPACITY];
|
char buffer[ULOC_LANG_CAPACITY];
|
||||||
int32_t strLength;
|
int32_t strLength;
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
UErrorCode error = U_ZERO_ERROR;
|
||||||
NSDictionary *result;
|
NSDictionary *result;
|
||||||
NSMutableDictionary *tmpDict =
|
NSMutableDictionary *tmpDict =
|
||||||
[[NSMutableDictionary alloc] initWithCapacity: 5];
|
[[NSMutableDictionary alloc] initWithCapacity: 5];
|
||||||
|
|
||||||
strLength =
|
strLength =
|
||||||
uloc_getLanguage ([string cString], buffer, ULOC_LANG_CAPACITY, &error);
|
uloc_getLanguage ([string cString], buffer, ULOC_LANG_CAPACITY, &error);
|
||||||
if (U_SUCCESS(error))
|
if (U_SUCCESS(error))
|
||||||
|
@ -254,7 +254,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
forKey: NSLocaleLanguageCode];
|
forKey: NSLocaleLanguageCode];
|
||||||
}
|
}
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
|
|
||||||
strLength =
|
strLength =
|
||||||
uloc_getCountry ([string cString], buffer, ULOC_COUNTRY_CAPACITY, &error);
|
uloc_getCountry ([string cString], buffer, ULOC_COUNTRY_CAPACITY, &error);
|
||||||
if (U_SUCCESS(error))
|
if (U_SUCCESS(error))
|
||||||
|
@ -263,7 +263,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
forKey: NSLocaleCountryCode];
|
forKey: NSLocaleCountryCode];
|
||||||
}
|
}
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
|
|
||||||
strLength =
|
strLength =
|
||||||
uloc_getScript ([string cString], buffer, ULOC_SCRIPT_CAPACITY, &error);
|
uloc_getScript ([string cString], buffer, ULOC_SCRIPT_CAPACITY, &error);
|
||||||
if (U_SUCCESS(error))
|
if (U_SUCCESS(error))
|
||||||
|
@ -272,7 +272,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
forKey: NSLocaleScriptCode];
|
forKey: NSLocaleScriptCode];
|
||||||
}
|
}
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
|
|
||||||
strLength =
|
strLength =
|
||||||
uloc_getVariant ([string cString], buffer, ULOC_LANG_CAPACITY, &error);
|
uloc_getVariant ([string cString], buffer, ULOC_LANG_CAPACITY, &error);
|
||||||
if (U_SUCCESS(error))
|
if (U_SUCCESS(error))
|
||||||
|
@ -281,7 +281,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
forKey: NSLocaleVariantCode];
|
forKey: NSLocaleVariantCode];
|
||||||
}
|
}
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
|
|
||||||
result = [NSDictionary dictionaryWithDictionary: tmpDict];
|
result = [NSDictionary dictionaryWithDictionary: tmpDict];
|
||||||
RELEASE(tmpDict);
|
RELEASE(tmpDict);
|
||||||
return result;
|
return result;
|
||||||
|
@ -293,11 +293,11 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
+ (id) currentLocale
|
+ (id) currentLocale
|
||||||
{
|
{
|
||||||
NSLocale *result;
|
NSLocale *result;
|
||||||
|
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == currentLocale)
|
if (nil == currentLocale)
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
const char *cLocaleId = uloc_getDefault ();
|
const char *cLocaleId = uloc_getDefault ();
|
||||||
NSString *localeId = [NSString stringWithCString: cLocaleId];
|
NSString *localeId = [NSString stringWithCString: cLocaleId];
|
||||||
currentLocale = [[NSLocale alloc] initWithLocaleIdentifier: localeId];
|
currentLocale = [[NSLocale alloc] initWithLocaleIdentifier: localeId];
|
||||||
|
@ -310,7 +310,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSArray *) commonISOCurrencyCodes
|
+ (NSArray *) commonISOCurrencyCodes
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
return _currencyCodesWithType (UCURR_COMMON | UCURR_NON_DEPRECATED);
|
return _currencyCodesWithType (UCURR_COMMON | UCURR_NON_DEPRECATED);
|
||||||
#else
|
#else
|
||||||
return nil; // FIXME
|
return nil; // FIXME
|
||||||
|
@ -319,7 +319,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSArray *) ISOCurrencyCodes
|
+ (NSArray *) ISOCurrencyCodes
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
return _currencyCodesWithType (UCURR_ALL);
|
return _currencyCodesWithType (UCURR_ALL);
|
||||||
#else
|
#else
|
||||||
return nil; // FIXME
|
return nil; // FIXME
|
||||||
|
@ -335,7 +335,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == countries)
|
if (nil == countries)
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
|
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
const char *const *codes = uloc_getISOCountries ();
|
const char *const *codes = uloc_getISOCountries ();
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == languages)
|
if (nil == languages)
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
|
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
const char *const *codes = uloc_getISOCountries ();
|
const char *const *codes = uloc_getISOCountries ();
|
||||||
|
|
||||||
|
@ -380,14 +380,14 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSLocaleLanguageDirection) lineDirectionForLanguage: (NSString *) isoLangCode
|
+ (NSLocaleLanguageDirection) lineDirectionForLanguage: (NSString *) isoLangCode
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
ULayoutType result;
|
ULayoutType result;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
|
||||||
result = uloc_getLineOrientation ([isoLangCode cString], &status);
|
result = uloc_getLineOrientation ([isoLangCode cString], &status);
|
||||||
if (U_FAILURE(status) || ULOC_LAYOUT_UNKNOWN == result)
|
if (U_FAILURE(status) || ULOC_LAYOUT_UNKNOWN == result)
|
||||||
return NSLocaleLanguageDirectionUnknown;
|
return NSLocaleLanguageDirectionUnknown;
|
||||||
|
|
||||||
return _ICUToNSLocaleOrientation (result);
|
return _ICUToNSLocaleOrientation (result);
|
||||||
#else
|
#else
|
||||||
return NSLocaleLanguageDirectionTopToBottom; // FIXME
|
return NSLocaleLanguageDirectionTopToBottom; // FIXME
|
||||||
|
@ -404,12 +404,12 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
NSLocale *result;
|
NSLocale *result;
|
||||||
|
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == systemLocale)
|
if (nil == systemLocale)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
result = RETAIN(systemLocale);
|
result = RETAIN(systemLocale);
|
||||||
[classLock unlock];
|
[classLock unlock];
|
||||||
return AUTORELEASE(result);
|
return AUTORELEASE(result);
|
||||||
|
@ -417,7 +417,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSString *) localeIdentifierFromComponents: (NSDictionary *) dict
|
+ (NSString *) localeIdentifierFromComponents: (NSDictionary *) dict
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
char buffer[ULOC_FULLNAME_CAPACITY];
|
char buffer[ULOC_FULLNAME_CAPACITY];
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
const char *language = [[dict objectForKey: NSLocaleLanguageCode] cString];
|
const char *language = [[dict objectForKey: NSLocaleLanguageCode] cString];
|
||||||
|
@ -426,13 +426,13 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
const char *variant = [[dict objectForKey: NSLocaleVariantCode] cString];
|
const char *variant = [[dict objectForKey: NSLocaleVariantCode] cString];
|
||||||
const char *calendar = [[dict objectForKey: NSLocaleCalendar] cString];
|
const char *calendar = [[dict objectForKey: NSLocaleCalendar] cString];
|
||||||
const char *collation = [[dict objectForKey: NSLocaleCollationIdentifier] cString];
|
const char *collation = [[dict objectForKey: NSLocaleCollationIdentifier] cString];
|
||||||
|
|
||||||
#define __TEST_CODE(x) (x ? "_" : ""), (x ? x : "")
|
#define __TEST_CODE(x) (x ? "_" : ""), (x ? x : "")
|
||||||
snprintf (buffer, ULOC_FULLNAME_CAPACITY, "%s%s%s%s%s%s%s",
|
snprintf (buffer, ULOC_FULLNAME_CAPACITY, "%s%s%s%s%s%s%s",
|
||||||
(language ? language : ""), __TEST_CODE(script),
|
(language ? language : ""), __TEST_CODE(script),
|
||||||
__TEST_CODE(country), __TEST_CODE(variant));
|
__TEST_CODE(country), __TEST_CODE(variant));
|
||||||
#undef __TEST_CODE
|
#undef __TEST_CODE
|
||||||
|
|
||||||
if (calendar)
|
if (calendar)
|
||||||
{
|
{
|
||||||
uloc_setKeywordValue (ICUCalendarKeyword, calendar, buffer,
|
uloc_setKeywordValue (ICUCalendarKeyword, calendar, buffer,
|
||||||
|
@ -443,7 +443,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
uloc_setKeywordValue (ICUCollationKeyword, collation, buffer,
|
uloc_setKeywordValue (ICUCollationKeyword, collation, buffer,
|
||||||
ULOC_FULLNAME_CAPACITY, &status);
|
ULOC_FULLNAME_CAPACITY, &status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [NSString stringWithCString: buffer];
|
return [NSString stringWithCString: buffer];
|
||||||
#else
|
#else
|
||||||
return nil; // FIXME
|
return nil; // FIXME
|
||||||
|
@ -452,15 +452,15 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (NSString *) localeIdentifierFromWindowsLocaleCode: (uint32_t) lcid
|
+ (NSString *) localeIdentifierFromWindowsLocaleCode: (uint32_t) lcid
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
char buffer[ULOC_FULLNAME_CAPACITY];
|
char buffer[ULOC_FULLNAME_CAPACITY];
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
|
||||||
int32_t length =
|
int32_t length =
|
||||||
uloc_getLocaleForLCID (lcid, buffer, ULOC_FULLNAME_CAPACITY, &status);
|
uloc_getLocaleForLCID (lcid, buffer, ULOC_FULLNAME_CAPACITY, &status);
|
||||||
if (U_FAILURE(status))
|
if (U_FAILURE(status))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
return [NSString stringWithCString: buffer length: (NSUInteger)length];
|
return [NSString stringWithCString: buffer length: (NSUInteger)length];
|
||||||
#else
|
#else
|
||||||
return nil; // FIXME
|
return nil; // FIXME
|
||||||
|
@ -469,7 +469,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
+ (uint32_t) windowsLocaleCodeFromLocaleIdentifier: (NSString *)localeIdentifier
|
+ (uint32_t) windowsLocaleCodeFromLocaleIdentifier: (NSString *)localeIdentifier
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
return uloc_getLCID ([localeIdentifier cString]);
|
return uloc_getLCID ([localeIdentifier cString]);
|
||||||
#else
|
#else
|
||||||
return 0; // FIXME
|
return 0; // FIXME
|
||||||
|
@ -478,18 +478,18 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
|
|
||||||
- (NSString *) displayNameForKey: (id) key value: (id) value
|
- (NSString *) displayNameForKey: (id) key value: (id) value
|
||||||
{
|
{
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
int32_t length;
|
int32_t length;
|
||||||
unichar buffer[ULOC_FULLNAME_CAPACITY];
|
unichar buffer[ULOC_FULLNAME_CAPACITY];
|
||||||
UErrorCode status;
|
UErrorCode status;
|
||||||
const char *locale = [[self localeIdentifier] cString];
|
const char *locale = [[self localeIdentifier] cString];
|
||||||
|
|
||||||
length = uloc_getDisplayKeywordValue (locale, [key cString],
|
length = uloc_getDisplayKeywordValue (locale, [key cString],
|
||||||
[value cString], (UChar *)buffer, sizeof(buffer)/sizeof(unichar),
|
[value cString], (UChar *)buffer, sizeof(buffer)/sizeof(unichar),
|
||||||
&status);
|
&status);
|
||||||
if (U_FAILURE(status))
|
if (U_FAILURE(status))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
return [NSString stringWithCharacters: buffer length: (NSUInteger)length];
|
return [NSString stringWithCharacters: buffer length: (NSUInteger)length];
|
||||||
#else
|
#else
|
||||||
return nil; // FIXME
|
return nil; // FIXME
|
||||||
|
@ -500,11 +500,11 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
{
|
{
|
||||||
NSLocale *newLocale;
|
NSLocale *newLocale;
|
||||||
NSString *localeId;
|
NSString *localeId;
|
||||||
#if HAVE_ICU
|
#if GS_USE_ICU == 1
|
||||||
int32_t length;
|
int32_t length;
|
||||||
char cLocaleId[ULOC_FULLNAME_CAPACITY];
|
char cLocaleId[ULOC_FULLNAME_CAPACITY];
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
UErrorCode error = U_ZERO_ERROR;
|
||||||
|
|
||||||
length = uloc_canonicalize ([string cString], cLocaleId,
|
length = uloc_canonicalize ([string cString], cLocaleId,
|
||||||
ULOC_FULLNAME_CAPACITY, &error);
|
ULOC_FULLNAME_CAPACITY, &error);
|
||||||
if (U_FAILURE(error))
|
if (U_FAILURE(error))
|
||||||
|
@ -516,7 +516,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
#else
|
#else
|
||||||
localeId = string;
|
localeId = string;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
if (nil == allLocales)
|
if (nil == allLocales)
|
||||||
{
|
{
|
||||||
|
@ -533,8 +533,8 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
[self release];
|
[self release];
|
||||||
self = [newLocale retain];
|
self = [newLocale retain];
|
||||||
}
|
}
|
||||||
[classLock unlock];
|
[classLock unlock];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,13 +547,13 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
{
|
{
|
||||||
// FIXME: this is really messy...
|
// FIXME: this is really messy...
|
||||||
id result;
|
id result;
|
||||||
|
|
||||||
if (key == NSLocaleIdentifier)
|
if (key == NSLocaleIdentifier)
|
||||||
return _localeId;
|
return _localeId;
|
||||||
|
|
||||||
if ((result = [_components objectForKey: key]))
|
if ((result = [_components objectForKey: key]))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if ([_components count] == 0)
|
if ([_components count] == 0)
|
||||||
{
|
{
|
||||||
[_components addEntriesFromDictionary:
|
[_components addEntriesFromDictionary:
|
||||||
|
@ -562,7 +562,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// FIXME: look up other keywords with uloc_getKeywordValue().
|
// FIXME: look up other keywords with uloc_getKeywordValue().
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue