diff --git a/docs/user/locale/LocaleRoster.dox b/docs/user/locale/LocaleRoster.dox index 8de0bfa14a..2c20e0a319 100644 --- a/docs/user/locale/LocaleRoster.dox +++ b/docs/user/locale/LocaleRoster.dox @@ -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. */ diff --git a/headers/os/locale/LocaleRoster.h b/headers/os/locale/LocaleRoster.h index 5ce7210f5b..9a1e625ccf 100644 --- a/headers/os/locale/LocaleRoster.h +++ b/headers/os/locale/LocaleRoster.h @@ -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; diff --git a/src/apps/readonlybootprompt/BootPromptWindow.cpp b/src/apps/readonlybootprompt/BootPromptWindow.cpp index b43bb04141..efd5e7d19b 100644 --- a/src/apps/readonlybootprompt/BootPromptWindow.cpp +++ b/src/apps/readonlybootprompt/BootPromptWindow.cpp @@ -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); diff --git a/src/kits/locale/DefaultCatalog.cpp b/src/kits/locale/DefaultCatalog.cpp index 2a811e22f9..d9eecb18f1 100644 --- a/src/kits/locale/DefaultCatalog.cpp +++ b/src/kits/locale/DefaultCatalog.cpp @@ -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); } } } diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index a638762091..346ad9389f 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -37,6 +37,7 @@ #include // ICU includes +#include #include #include @@ -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; } diff --git a/src/preferences/locale/LocaleWindow.cpp b/src/preferences/locale/LocaleWindow.cpp index 5f59a30095..5bf5f63718 100644 --- a/src/preferences/locale/LocaleWindow.cpp +++ b/src/preferences/locale/LocaleWindow.cpp @@ -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; diff --git a/src/preferences/time/ZoneView.cpp b/src/preferences/time/ZoneView.cpp index 523bb59aaf..9ddda907eb 100644 --- a/src/preferences/time/ZoneView.cpp +++ b/src/preferences/time/ZoneView.cpp @@ -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;