OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 LocaleMac::LocaleMac(NSLocale* locale) | 83 LocaleMac::LocaleMac(NSLocale* locale) |
84 : m_locale(locale) | 84 : m_locale(locale) |
85 , m_gregorianCalendar(AdoptNS, [[NSCalendar alloc] initWithCalendarIdentifie
r:NSGregorianCalendar]) | 85 , m_gregorianCalendar(AdoptNS, [[NSCalendar alloc] initWithCalendarIdentifie
r:NSGregorianCalendar]) |
86 , m_didInitializeNumberData(false) | 86 , m_didInitializeNumberData(false) |
87 { | 87 { |
88 NSArray* availableLanguages = [NSLocale ISOLanguageCodes]; | 88 NSArray* availableLanguages = [NSLocale ISOLanguageCodes]; |
89 // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care
about case. | 89 // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care
about case. |
90 NSString* language = [m_locale.get() objectForKey:NSLocaleLanguageCode]; | 90 NSString* language = [m_locale.get() objectForKey:NSLocaleLanguageCode]; |
91 if ([availableLanguages indexOfObject:language] == NSNotFound) | 91 if ([availableLanguages indexOfObject:language] == NSNotFound) { |
92 m_locale.adoptNS([[NSLocale alloc] initWithLocaleIdentifier:defaultLangu
age()]); | 92 NSString *nsLanguage = [[NSString alloc] initWithUTF8String:defaultLangu
age().utf8().data()]; |
| 93 m_locale.adoptNS([[NSLocale alloc] initWithLocaleIdentifier:nsLanguage])
; |
| 94 [nsLanguage release]; |
| 95 } |
93 [m_gregorianCalendar.get() setLocale:m_locale.get()]; | 96 [m_gregorianCalendar.get() setLocale:m_locale.get()]; |
94 } | 97 } |
95 | 98 |
96 LocaleMac::~LocaleMac() | 99 LocaleMac::~LocaleMac() |
97 { | 100 { |
98 } | 101 } |
99 | 102 |
100 PassOwnPtr<LocaleMac> LocaleMac::create(const String& localeIdentifier) | 103 PassOwnPtr<LocaleMac> LocaleMac::create(const String& localeIdentifier) |
101 { | 104 { |
102 RetainPtr<NSLocale> locale = [[NSLocale alloc] initWithLocaleIdentifier:loca
leIdentifier]; | 105 RetainPtr<NSLocale> locale = [[NSLocale alloc] initWithLocaleIdentifier:loca
leIdentifier]; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 ASSERT(symbols.size() == DecimalSymbolsSize); | 323 ASSERT(symbols.size() == DecimalSymbolsSize); |
321 | 324 |
322 String positivePrefix([formatter.get() positivePrefix]); | 325 String positivePrefix([formatter.get() positivePrefix]); |
323 String positiveSuffix([formatter.get() positiveSuffix]); | 326 String positiveSuffix([formatter.get() positiveSuffix]); |
324 String negativePrefix([formatter.get() negativePrefix]); | 327 String negativePrefix([formatter.get() negativePrefix]); |
325 String negativeSuffix([formatter.get() negativeSuffix]); | 328 String negativeSuffix([formatter.get() negativeSuffix]); |
326 setLocaleData(symbols, positivePrefix, positiveSuffix, negativePrefix, negat
iveSuffix); | 329 setLocaleData(symbols, positivePrefix, positiveSuffix, negativePrefix, negat
iveSuffix); |
327 } | 330 } |
328 | 331 |
329 } | 332 } |
OLD | NEW |