This should have been part of previous commit :

Add Language->IsCountry to tell if a language holds a country specifier (like fr_FR) or not (fr alone). This allows separating them in the preflet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35366 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2010-01-31 21:17:39 +00:00
parent fbc6963056
commit e6a7a30e3b
2 changed files with 11 additions and 19 deletions

View File

@ -6,6 +6,8 @@
#include <Language.h>
#include <iostream>
#include <Path.h>
#include <String.h>
#include <FindDirectory.h>
@ -135,7 +137,7 @@ BLanguage::GetName(BString* name)
// TODO: This will return the language not in the current be_app_catalog,
// but in the current system wide language! Don't know the exact reason.
UnicodeString s;
fICULocale->getDisplayLanguage(s);
fICULocale->getDisplayName(s);
BStringByteSink converter(name);
s.toUTF8(converter);
return B_OK;
@ -146,3 +148,10 @@ BLanguage::Code()
{
return fICULocale->getLanguage();
}
bool
BLanguage::IsCountry()
{
return *(fICULocale->getCountry()) != '\0';
}

View File

@ -509,31 +509,14 @@ BLocaleRoster::GetInstalledLanguages(BMessage *languages) const
int32 i;
UnicodeString icuLanguageName;
BString languageName;
std::set<BString> languageSet;
#undef REALLY_ALL_LANGUAGES
#ifdef REALLY_ALL_LANGUAGES
const char* const* icuLocaleList = Locale::getISOLanguages();
// Loop over the strings and add them to an std::set to remove duplicates
for (i = 0; icuLocaleList[i]; i++) {
languageSet.insert(BString(icuLocaleList[i]));
}
#else
int32_t localeCount;
const Locale* icuLocaleList
= Locale::getAvailableLocales(localeCount);
// Loop over the strings and add them to an std::set to remove duplicates
for (i = 0; i < localeCount; i++) {
languageSet.insert(icuLocaleList[i].getLanguage());
}
#endif
std::set<BString>::const_iterator lastLang = languageSet.end();
for (std::set<BString>::const_iterator setIterator = languageSet.begin();
setIterator != lastLang; setIterator++) {
languages->AddString("langs", *setIterator);
languages->AddString("langs", icuLocaleList[i].getName());
}
return B_OK;