Logo Search packages:      
Sourcecode: icu version File versions  Download package

const Locale &U_EXPORT2 Locale::getDefault ( void   )  [static]

Common methods of getting the current default Locale. Used for the presentation: menus, dialogs, etc. Generally set once when your applet or application is initialized, then never reset. (If you do reset the default locale, you probably want to reload your GUI, so that the change is reflected in your interface.)

More advanced programs will allow users to use different locales for different fields, e.g. in a spreadsheet.

Note that the initial setting will match the host system.

Returns:
a reference to the Locale object for the default locale ID ICU 2.0

Definition at line 662 of file locid.cpp.

References locale_set_default_internal, and NULL.

Referenced by Calendar::Calendar(), DecimalFormat::construct(), MeasureFormat::createCurrencyFormat(), NumberFormat::createCurrencyInstance(), createFromName(), NumberingSystem::createInstance(), NumberFormat::createInstance(), DateTimePatternGenerator::createInstance(), DateIntervalFormat::createInstance(), DateFormat::createInstance(), Collator::createInstance(), Calendar::createInstance(), NumberFormat::createPercentInstance(), NumberFormat::createScientificInstance(), CurrencyPluralInfo::CurrencyPluralInfo(), DateFormatSymbols::DateFormatSymbols(), DecimalFormat::expandAffix(), getDisplayCountry(), getDisplayLanguage(), Transliterator::getDisplayName(), TimeZone::getDisplayName(), Collator::getDisplayName(), ICUService::getDisplayName(), getDisplayName(), ICUService::getDisplayNames(), getDisplayScript(), getDisplayVariant(), ResourceBundle::getLocale(), init(), PluralFormat::PluralFormat(), PluralFormatTest::pluralFormatBasicTest(), ResourceBundle::ResourceBundle(), IntlTestNumberFormat::runIndexedTest(), IntlTestDateFormat::runIndexedTest(), DateFormatRegressionTest::Test4065240(), CalendarRegressionTest::test4086724(), CalendarRegressionTest::test4106136(), LocaleTest::TestBasicGetters(), RBBIAPITest::TestCloneEquals(), NewResourceBundleTest::TestConstruction(), ResourceBundleTest::TestConstruction(), RBBITest::TestEndBehaviour(), IntlTestDateFormatSymbols::TestGetMonths(), RBBIAPITest::TestgetRules(), RBBIAPITest::TestGetSetAdoptText(), RBBIAPITest::TestHashCode(), RBBIAPITest::TestIteration(), NewResourceBundleTest::TestResourceBundles(), ResourceBundleTest::TestResourceBundles(), NumberFormatTest::TestScientific(), TimeUnitFormat::TimeUnitFormat(), UnicodeString::toLower(), UnicodeString::toTitle(), and UnicodeString::toUpper().

{
    const Locale *retLocale;
    UMTX_CHECK(NULL, gDefaultLocale, retLocale);
    if (retLocale == NULL) {
        locale_set_default_internal(NULL);
        umtx_lock(NULL);
        // Need a mutex  in case some other thread set a new
        // default inbetween when we set and when we get the new default.  For
        // processors with weak memory coherency, we might not otherwise see all
        // of the newly created new default locale.
        retLocale = gDefaultLocale;
        umtx_unlock(NULL);
    }
    return *retLocale;
}


Generated by  Doxygen 1.6.0   Back to index