* some cleanup in BLocaleRoster
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39018 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1c52448e60
commit
6f43fabafb
@ -4,7 +4,7 @@
|
||||
\brief Main class for accessingthe locale kit data
|
||||
|
||||
The Locale Roster is the central part of the locale roster.
|
||||
It is a blobal object (be_localeÃ_roster) storing all the useful locale
|
||||
It is a blobal object (be_locale_roster) storing all the useful locale
|
||||
data. Other classes from the Locale Kit can be constructed on their own,
|
||||
but only hte Locale Roster allows you to do so while taking account of
|
||||
the user's locale settings.
|
||||
@ -44,11 +44,11 @@ methods of the Locale Kit.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn status_t BLocaleRoster::GetInstalledLanguages(BMessage* message) const
|
||||
\fn status_t BLocaleRoster::GetAvailableLanguages(BMessage* message) const
|
||||
\brief List the available languages
|
||||
|
||||
This function fills the passed BMessage with one or more 'language' string
|
||||
fields, containing the language(s) code(s).
|
||||
fields, containing the language(s) ID(s).
|
||||
|
||||
*/
|
||||
|
||||
@ -57,7 +57,7 @@ fields, containing the language(s) code(s).
|
||||
\brief List the available countries
|
||||
|
||||
This function filles the passed BMessage with one or more 'country' string
|
||||
fields, containing the country names.
|
||||
fields, containing the (ISO-639) code of each country.
|
||||
|
||||
*/
|
||||
|
||||
|
@ -36,10 +36,7 @@ public:
|
||||
|
||||
status_t GetPreferredLanguages(BMessage* message) const;
|
||||
|
||||
status_t GetInstalledLanguages(BMessage* message) const;
|
||||
// the message contains one or more
|
||||
// 'language'-string-fields which
|
||||
// contain the language-name(s)
|
||||
status_t GetAvailableLanguages(BMessage* message) const;
|
||||
|
||||
status_t GetAvailableCountries(
|
||||
BMessage* timeZones) const;
|
||||
|
@ -82,7 +82,7 @@ BootPromptWindow::BootPromptWindow()
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
// Get the list of all known languages (suffice to do it only once)
|
||||
be_locale_roster->GetInstalledLanguages(&fInstalledLanguages);
|
||||
be_locale_roster->GetAvailableLanguages(&fInstalledLanguages);
|
||||
|
||||
fInfoTextView = new BTextView("info", be_plain_font, NULL, B_WILL_DRAW);
|
||||
fInfoTextView->SetInsets(10, 10, 10, 10);
|
||||
@ -279,12 +279,12 @@ BootPromptWindow::_PopulateLanguages()
|
||||
// for translations of this application. So the list of languages will be
|
||||
// limited to catalogs written for this application, which is on purpose!
|
||||
|
||||
const char* languageString;
|
||||
const char* languageID;
|
||||
LanguageItem* currentItem = NULL;
|
||||
for (int32 i = 0; installedCatalogs.FindString("langs", i, &languageString)
|
||||
for (int32 i = 0; installedCatalogs.FindString("language", i, &languageID)
|
||||
== B_OK; i++) {
|
||||
BLanguage* language;
|
||||
if (be_locale_roster->GetLanguage(languageString, &language) == B_OK) {
|
||||
if (be_locale_roster->GetLanguage(languageID, &language) == B_OK) {
|
||||
BString name;
|
||||
language->GetNativeName(name);
|
||||
|
||||
@ -301,15 +301,15 @@ BootPromptWindow::_PopulateLanguages()
|
||||
}
|
||||
|
||||
LanguageItem* item = new LanguageItem(name.String(),
|
||||
languageString);
|
||||
languageID);
|
||||
fLanguagesListView->AddItem(item);
|
||||
// Select this item if it is the first preferred language
|
||||
if (strcmp(firstPreferredLanguage, languageString) == 0)
|
||||
if (strcmp(firstPreferredLanguage, languageID) == 0)
|
||||
currentItem = item;
|
||||
|
||||
delete language;
|
||||
} else
|
||||
printf("failed to get BLanguage for %s\n", languageString);
|
||||
printf("failed to get BLanguage for %s\n", languageID);
|
||||
}
|
||||
|
||||
fLanguagesListView->SortItems(compare_void_list_items);
|
||||
|
@ -601,8 +601,8 @@ default_catalog_get_available_languages(BMessage* availableLanguages,
|
||||
while(dir.GetNextEntry(&file) == B_OK) {
|
||||
file.GetName(fileName);
|
||||
BString langName(fileName);
|
||||
langName.Replace(kCatExtension,"",1);
|
||||
availableLanguages->AddString("langs",langName);
|
||||
langName.Replace(kCatExtension, "", 1);
|
||||
availableLanguages->AddString("language", langName);
|
||||
}
|
||||
|
||||
// search in data folders
|
||||
@ -628,8 +628,8 @@ default_catalog_get_available_languages(BMessage* availableLanguages,
|
||||
while(dir.GetNextEntry(&file) == B_OK) {
|
||||
file.GetName(fileName);
|
||||
BString langName(fileName);
|
||||
langName.Replace(kCatExtension,"",1);
|
||||
availableLanguages->AddString("langs",langName);
|
||||
langName.Replace(kCatExtension, "", 1);
|
||||
availableLanguages->AddString("language", langName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <ICUWrapper.h>
|
||||
|
||||
// ICU includes
|
||||
#include <unicode/locdspnm.h>
|
||||
#include <unicode/locid.h>
|
||||
#include <unicode/timezone.h>
|
||||
|
||||
@ -128,24 +129,21 @@ BLocaleRoster::GetPreferredLanguages(BMessage* languages) const
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Fills \c message with 'language'-fields containing the language-
|
||||
* ID(s) of all available languages.
|
||||
*/
|
||||
status_t
|
||||
BLocaleRoster::GetInstalledLanguages(BMessage* languages) const
|
||||
BLocaleRoster::GetAvailableLanguages(BMessage* languages) const
|
||||
{
|
||||
if (!languages)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
int32 i;
|
||||
UnicodeString icuLanguageName;
|
||||
BString languageName;
|
||||
|
||||
int32_t localeCount;
|
||||
const Locale* icuLocaleList
|
||||
= Locale::getAvailableLocales(localeCount);
|
||||
const Locale* icuLocaleList = Locale::getAvailableLocales(localeCount);
|
||||
|
||||
// TODO: Loop over the strings and add them to a std::set to remove
|
||||
// duplicates?
|
||||
for (i = 0; i < localeCount; i++)
|
||||
languages->AddString("langs", icuLocaleList[i].getName());
|
||||
for (int i = 0; i < localeCount; i++)
|
||||
languages->AddString("language", icuLocaleList[i].getName());
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@ -161,7 +159,7 @@ BLocaleRoster::GetAvailableCountries(BMessage* countries) const
|
||||
const char* const* countryList = uloc_getISOCountries();
|
||||
|
||||
for (i = 0; countryList[i] != NULL; i++)
|
||||
countries->AddString("countries", countryList[i]);
|
||||
countries->AddString("country", countryList[i]);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ LocaleWindow::LocaleWindow()
|
||||
|
||||
// Fill the language list from the LocaleRoster data
|
||||
BMessage installedLanguages;
|
||||
if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) {
|
||||
if (be_locale_roster->GetAvailableLanguages(&installedLanguages) == B_OK) {
|
||||
BString currentID;
|
||||
LanguageListItem* lastAddedCountryItem = NULL;
|
||||
|
||||
for (int i = 0; installedLanguages.FindString("langs", i, ¤tID)
|
||||
for (int i = 0; installedLanguages.FindString("language", i, ¤tID)
|
||||
== B_OK; i++) {
|
||||
// Now get the human-readable, native name for each language
|
||||
BString name;
|
||||
@ -189,7 +189,7 @@ LocaleWindow::LocaleWindow()
|
||||
BCountry defaultFormattingConvention;
|
||||
be_locale->GetCountry(&defaultFormattingConvention);
|
||||
for (int i = 0;
|
||||
installedLanguages.FindString("langs", i, &formattingConventionCode)
|
||||
installedLanguages.FindString("language", i, &formattingConventionCode)
|
||||
== B_OK; i++) {
|
||||
BCountry formattingConvention(formattingConventionCode);
|
||||
BString formattingConventionName;
|
||||
|
@ -281,7 +281,7 @@ TimeZoneView::_BuildZoneMenu()
|
||||
|
||||
BMessage countryList;
|
||||
be_locale_roster->GetAvailableCountries(&countryList);
|
||||
countryList.AddString("countries", "");
|
||||
countryList.AddString("country", "");
|
||||
|
||||
/*
|
||||
* Group timezones by regions, but filter out unwanted (duplicate) regions
|
||||
@ -298,7 +298,7 @@ TimeZoneView::_BuildZoneMenu()
|
||||
zoneMap[*region] = NULL;
|
||||
|
||||
BString countryCode;
|
||||
for (int c = 0; countryList.FindString("countries", c, &countryCode)
|
||||
for (int c = 0; countryList.FindString("country", c, &countryCode)
|
||||
== B_OK; c++) {
|
||||
BCountry country("", countryCode);
|
||||
BString countryName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user