* 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:
@@ -4,7 +4,7 @@
|
|||||||
\brief Main class for accessingthe locale kit data
|
\brief Main class for accessingthe locale kit data
|
||||||
|
|
||||||
The Locale Roster is the central part of the locale roster.
|
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,
|
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
|
but only hte Locale Roster allows you to do so while taking account of
|
||||||
the user's locale settings.
|
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
|
\brief List the available languages
|
||||||
|
|
||||||
This function fills the passed BMessage with one or more 'language' string
|
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
|
\brief List the available countries
|
||||||
|
|
||||||
This function filles the passed BMessage with one or more 'country' string
|
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 GetPreferredLanguages(BMessage* message) const;
|
||||||
|
|
||||||
status_t GetInstalledLanguages(BMessage* message) const;
|
status_t GetAvailableLanguages(BMessage* message) const;
|
||||||
// the message contains one or more
|
|
||||||
// 'language'-string-fields which
|
|
||||||
// contain the language-name(s)
|
|
||||||
|
|
||||||
status_t GetAvailableCountries(
|
status_t GetAvailableCountries(
|
||||||
BMessage* timeZones) const;
|
BMessage* timeZones) const;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ BootPromptWindow::BootPromptWindow()
|
|||||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
// Get the list of all known languages (suffice to do it only once)
|
// 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 = new BTextView("info", be_plain_font, NULL, B_WILL_DRAW);
|
||||||
fInfoTextView->SetInsets(10, 10, 10, 10);
|
fInfoTextView->SetInsets(10, 10, 10, 10);
|
||||||
@@ -279,12 +279,12 @@ BootPromptWindow::_PopulateLanguages()
|
|||||||
// for translations of this application. So the list of languages will be
|
// for translations of this application. So the list of languages will be
|
||||||
// limited to catalogs written for this application, which is on purpose!
|
// limited to catalogs written for this application, which is on purpose!
|
||||||
|
|
||||||
const char* languageString;
|
const char* languageID;
|
||||||
LanguageItem* currentItem = NULL;
|
LanguageItem* currentItem = NULL;
|
||||||
for (int32 i = 0; installedCatalogs.FindString("langs", i, &languageString)
|
for (int32 i = 0; installedCatalogs.FindString("language", i, &languageID)
|
||||||
== B_OK; i++) {
|
== B_OK; i++) {
|
||||||
BLanguage* language;
|
BLanguage* language;
|
||||||
if (be_locale_roster->GetLanguage(languageString, &language) == B_OK) {
|
if (be_locale_roster->GetLanguage(languageID, &language) == B_OK) {
|
||||||
BString name;
|
BString name;
|
||||||
language->GetNativeName(name);
|
language->GetNativeName(name);
|
||||||
|
|
||||||
@@ -301,15 +301,15 @@ BootPromptWindow::_PopulateLanguages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LanguageItem* item = new LanguageItem(name.String(),
|
LanguageItem* item = new LanguageItem(name.String(),
|
||||||
languageString);
|
languageID);
|
||||||
fLanguagesListView->AddItem(item);
|
fLanguagesListView->AddItem(item);
|
||||||
// Select this item if it is the first preferred language
|
// Select this item if it is the first preferred language
|
||||||
if (strcmp(firstPreferredLanguage, languageString) == 0)
|
if (strcmp(firstPreferredLanguage, languageID) == 0)
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
|
|
||||||
delete language;
|
delete language;
|
||||||
} else
|
} 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);
|
fLanguagesListView->SortItems(compare_void_list_items);
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ default_catalog_get_available_languages(BMessage* availableLanguages,
|
|||||||
file.GetName(fileName);
|
file.GetName(fileName);
|
||||||
BString langName(fileName);
|
BString langName(fileName);
|
||||||
langName.Replace(kCatExtension, "", 1);
|
langName.Replace(kCatExtension, "", 1);
|
||||||
availableLanguages->AddString("langs",langName);
|
availableLanguages->AddString("language", langName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// search in data folders
|
// search in data folders
|
||||||
@@ -629,7 +629,7 @@ default_catalog_get_available_languages(BMessage* availableLanguages,
|
|||||||
file.GetName(fileName);
|
file.GetName(fileName);
|
||||||
BString langName(fileName);
|
BString langName(fileName);
|
||||||
langName.Replace(kCatExtension, "", 1);
|
langName.Replace(kCatExtension, "", 1);
|
||||||
availableLanguages->AddString("langs",langName);
|
availableLanguages->AddString("language", langName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <ICUWrapper.h>
|
#include <ICUWrapper.h>
|
||||||
|
|
||||||
// ICU includes
|
// ICU includes
|
||||||
|
#include <unicode/locdspnm.h>
|
||||||
#include <unicode/locid.h>
|
#include <unicode/locid.h>
|
||||||
#include <unicode/timezone.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
|
status_t
|
||||||
BLocaleRoster::GetInstalledLanguages(BMessage* languages) const
|
BLocaleRoster::GetAvailableLanguages(BMessage* languages) const
|
||||||
{
|
{
|
||||||
if (!languages)
|
if (!languages)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
int32 i;
|
|
||||||
UnicodeString icuLanguageName;
|
|
||||||
BString languageName;
|
|
||||||
|
|
||||||
int32_t localeCount;
|
int32_t localeCount;
|
||||||
const Locale* icuLocaleList
|
const Locale* icuLocaleList = Locale::getAvailableLocales(localeCount);
|
||||||
= Locale::getAvailableLocales(localeCount);
|
|
||||||
|
|
||||||
// TODO: Loop over the strings and add them to a std::set to remove
|
for (int i = 0; i < localeCount; i++)
|
||||||
// duplicates?
|
languages->AddString("language", icuLocaleList[i].getName());
|
||||||
for (i = 0; i < localeCount; i++)
|
|
||||||
languages->AddString("langs", icuLocaleList[i].getName());
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -161,7 +159,7 @@ BLocaleRoster::GetAvailableCountries(BMessage* countries) const
|
|||||||
const char* const* countryList = uloc_getISOCountries();
|
const char* const* countryList = uloc_getISOCountries();
|
||||||
|
|
||||||
for (i = 0; countryList[i] != NULL; i++)
|
for (i = 0; countryList[i] != NULL; i++)
|
||||||
countries->AddString("countries", countryList[i]);
|
countries->AddString("country", countryList[i]);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,11 +102,11 @@ LocaleWindow::LocaleWindow()
|
|||||||
|
|
||||||
// Fill the language list from the LocaleRoster data
|
// Fill the language list from the LocaleRoster data
|
||||||
BMessage installedLanguages;
|
BMessage installedLanguages;
|
||||||
if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) {
|
if (be_locale_roster->GetAvailableLanguages(&installedLanguages) == B_OK) {
|
||||||
BString currentID;
|
BString currentID;
|
||||||
LanguageListItem* lastAddedCountryItem = NULL;
|
LanguageListItem* lastAddedCountryItem = NULL;
|
||||||
|
|
||||||
for (int i = 0; installedLanguages.FindString("langs", i, ¤tID)
|
for (int i = 0; installedLanguages.FindString("language", i, ¤tID)
|
||||||
== B_OK; i++) {
|
== B_OK; i++) {
|
||||||
// Now get the human-readable, native name for each language
|
// Now get the human-readable, native name for each language
|
||||||
BString name;
|
BString name;
|
||||||
@@ -189,7 +189,7 @@ LocaleWindow::LocaleWindow()
|
|||||||
BCountry defaultFormattingConvention;
|
BCountry defaultFormattingConvention;
|
||||||
be_locale->GetCountry(&defaultFormattingConvention);
|
be_locale->GetCountry(&defaultFormattingConvention);
|
||||||
for (int i = 0;
|
for (int i = 0;
|
||||||
installedLanguages.FindString("langs", i, &formattingConventionCode)
|
installedLanguages.FindString("language", i, &formattingConventionCode)
|
||||||
== B_OK; i++) {
|
== B_OK; i++) {
|
||||||
BCountry formattingConvention(formattingConventionCode);
|
BCountry formattingConvention(formattingConventionCode);
|
||||||
BString formattingConventionName;
|
BString formattingConventionName;
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ TimeZoneView::_BuildZoneMenu()
|
|||||||
|
|
||||||
BMessage countryList;
|
BMessage countryList;
|
||||||
be_locale_roster->GetAvailableCountries(&countryList);
|
be_locale_roster->GetAvailableCountries(&countryList);
|
||||||
countryList.AddString("countries", "");
|
countryList.AddString("country", "");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Group timezones by regions, but filter out unwanted (duplicate) regions
|
* Group timezones by regions, but filter out unwanted (duplicate) regions
|
||||||
@@ -298,7 +298,7 @@ TimeZoneView::_BuildZoneMenu()
|
|||||||
zoneMap[*region] = NULL;
|
zoneMap[*region] = NULL;
|
||||||
|
|
||||||
BString countryCode;
|
BString countryCode;
|
||||||
for (int c = 0; countryList.FindString("countries", c, &countryCode)
|
for (int c = 0; countryList.FindString("country", c, &countryCode)
|
||||||
== B_OK; c++) {
|
== B_OK; c++) {
|
||||||
BCountry country("", countryCode);
|
BCountry country("", countryCode);
|
||||||
BString countryName;
|
BString countryName;
|
||||||
|
|||||||
Reference in New Issue
Block a user