2 * Copyright 2003-2011, Axel Dörfler, axeld@pinc-software.de.
3 * Copyright 2009-2010, Adrien Destugues, pulkomandy@gmail.com.
4 * Distributed under the terms of the MIT License.
8 #include <unicode/uversion.h>
11 #include <AutoDeleter.h>
12 #include <IconUtils.h>
15 #include <LocaleRoster.h>
16 #include <Resources.h>
19 #include <unicode/locid.h>
20 #include <unicode/ulocdata.h>
21 #include <ICUWrapper.h>
31 BCountry::BCountry(const char* countryCode
)
33 fICULocale(new icu::Locale("", countryCode
))
38 BCountry::BCountry(const BCountry
& other
)
40 fICULocale(new icu::Locale(*other
.fICULocale
))
46 BCountry::operator=(const BCountry
& other
)
51 *fICULocale
= *other
.fICULocale
;
64 BCountry::GetNativeName(BString
& name
) const
67 fICULocale
->getDisplayName(*fICULocale
, string
);
68 string
.toTitle(NULL
, *fICULocale
);
71 BStringByteSink
converter(&name
);
72 string
.toUTF8(converter
);
79 BCountry::GetName(BString
& name
, const BLanguage
* displayLanguage
) const
81 status_t status
= B_OK
;
83 if (displayLanguage
== NULL
) {
84 BMessage preferredLanguages
;
85 status
= BLocaleRoster::Default()->GetPreferredLanguages(
88 status
= preferredLanguages
.FindString("language", 0, &appLanguage
);
90 appLanguage
= displayLanguage
->Code();
94 UnicodeString uString
;
95 fICULocale
->getDisplayName(Locale(appLanguage
), uString
);
97 BStringByteSink
stringConverter(&name
);
98 uString
.toUTF8(stringConverter
);
106 BCountry::Code() const
108 return fICULocale
->getCountry();
113 BCountry::GetIcon(BBitmap
* result
) const
115 return BLocaleRoster::Default()->GetFlagIconForCountry(result
, Code());
120 BCountry::GetAvailableTimeZones(BMessage
* timeZones
) const
122 return BLocaleRoster::Default()->GetAvailableTimeZonesForCountry(timeZones
,