void LocaleComboBox::reset() { auto locale = currentLocale(); clear(); for (auto &it : d->items) it.update(); qSort(d->items); d->system.update(); addItem(tr("System locale[%1]").arg(d->system.name), d->system.locale); for (auto &it : d->items) addItem(it.name, it.locale); setCurrentIndex(findData(locale)); }
PassOwnPtr<Collator> Collator::userDefault() { #if OS(DARWIN) && USE(CF) // Mac OS X doesn't set UNIX locale to match user-selected one, so ICU default doesn't work. RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent()); CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get(), kCFLocaleCollatorIdentifier); char buf[256]; if (!collationOrder) return adoptPtr(new Collator("")); CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII); return adoptPtr(new Collator(buf)); #else return adoptPtr(new Collator(0)); #endif }
PassOwnPtr<Collator> Collator::userDefault() { #if OS(DARWIN) && USE(CF) // Mac OS X doesn't set UNIX locale to match user-selected one, so ICU default doesn't work. #if !defined(BUILDING_ON_LEOPARD) && !OS(IOS) RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent()); CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get(), kCFLocaleCollatorIdentifier); #else RetainPtr<CFStringRef> collationOrderRetainer(AdoptCF, (CFStringRef)CFPreferencesCopyValue(CFSTR("AppleCollationOrder"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)); CFStringRef collationOrder = collationOrderRetainer.get(); #endif char buf[256]; if (!collationOrder) return adoptPtr(new Collator("")); CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII); return adoptPtr(new Collator(buf)); #else return adoptPtr(new Collator(0)); #endif }
virtual UObject* getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const { UnicodeString ar; if (actualReturn == NULL) { actualReturn = &ar; } Collator* result = (Collator*)ICULocaleService::getKey(key, actualReturn, status); // Ugly Hack Alert! If the actualReturn length is zero, this // means we got a default object, not a "real" service-created // object. We don't call setLocales() on a default object, // because that will overwrite its correct built-in locale // metadata (valid & actual) with our incorrect data (all we // have is the requested locale). (TODO remove in 3.0) [aliu] if (result && actualReturn->length() > 0) { const LocaleKey& lkey = (const LocaleKey&)key; Locale canonicalLocale(""); Locale currentLocale(""); LocaleUtility::initLocaleFromName(*actualReturn, currentLocale); result->setLocales(lkey.canonicalLocale(canonicalLocale), currentLocale, currentLocale); } return result; }