{
static const char* LANGUAGE_LIST_FILE_PATH ="/opt/data/setting/langlist.xml";
static const char* TIMEZONE_LIST_FILE_PATH = "/opt/data/setting/tzlist.ini";
+static const char* CLOCALE_LIST_FILE_PATH = "/opt/usr/etc/clocale.list";
+
static const int TIMEZONE_MAX = 224;
static const char* TimeZoneList[TIMEZONE_MAX] =
{
return Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null);
}
+
+IMap*
+_LocaleManagerImpl::GetAvailableEglibcLocaesN(void)
+{
+ File file;
+ result r = E_SUCCESS;
+ String clocaleFilePath(CLOCALE_LIST_FILE_PATH);
+
+ std::unique_ptr<HashMap> pClocaleMap(new (std::nothrow) HashMap(SingleObjectDeleter));
+ SysTryReturn(NID_LCL, pClocaleMap, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+ r = file.Construct(clocaleFilePath, "r");
+ SysTryReturn(NID_LCL, r == E_SUCCESS, null,E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the clocale list from the list file.");
+
+ pClocaleMap->Construct();
+
+ do
+ {
+ String strBuf;
+ r = file.Read(strBuf);
+ if ( r == E_END_OF_FILE)
+ {
+ break;
+ }
+ SysTryReturn(NID_LCL, r == E_SUCCESS, null, r, "[%s] It is failed to read the clocale list.", GetErrorMessage(r));
+ std::unique_ptr< String > pClocaleId(new (std::nothrow) String());
+ SysTryReturn(NID_LCL, pClocaleId, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+ r = strBuf.SubString(0, 5, *pClocaleId);
+ if (IsFailed(r))
+ {
+ continue;
+ }
+
+ if (!pClocaleMap->ContainsKey(*(pClocaleId.get())))
+ {
+ std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
+ SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = pClocaleMap->Add(*(pClocaleId.get()), *(pDummyValue.get()));
+ SysTryReturn(NID_LCL, r == E_SUCCESS, null, r,
+ "[%s] It is failed to add the clocale id into the clocale map.", GetErrorMessage(r));
+ pClocaleId.release();
+ pDummyValue.release();
+ }
+ }while(1);
+ return pClocaleMap.release();
+}
+
IList*
_LocaleManagerImpl::GetAvailableLocalesN(void)
{
int count = 0;
const U_ICU_NAMESPACE::Locale* pIcuLocaleList = U_ICU_NAMESPACE::Locale::getAvailableLocales(count);
SysTryReturn(NID_LCL, count > 0, null, E_SYSTEM,
- "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+ "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
- std::unique_ptr<LinkedList, AllElementsDeleter> pAvailableLocaleList(new (std::nothrow) LinkedList());
+ std::unique_ptr<LinkedList> pAvailableLocaleList(new (std::nothrow) LinkedList(SingleObjectDeleter));
SysTryReturn(NID_LCL, pAvailableLocaleList, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+ "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ std::unique_ptr< IMap > pClocaleMap(GetAvailableEglibcLocaesN());
for (int i = 0; i < count; i++)
{
- SysTryReturn(NID_LCL, (pIcuLocaleList + i) != null, null, E_SYSTEM,
- "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
-
- Locale ospLocale = _LocaleImpl(*(pIcuLocaleList + i)).GetOspLocale();
+ const U_ICU_NAMESPACE::Locale* pIcuLocale = (pIcuLocaleList + i);
+ SysTryReturn(NID_LCL, pIcuLocale, null, E_SYSTEM,
+ "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
+ Locale ospLocale = _LocaleImpl(*pIcuLocale).GetOspLocale();
if (_LocaleImpl::IsSupported(ospLocale))
{
std::unique_ptr< Locale > pLocale(new (std::nothrow) Locale(ospLocale));
SysTryReturn(NID_LCL, pLocale, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
- if (!pAvailableLocaleList->Contains(*(pLocale.get())))
+
+ String localeId(pIcuLocale->getLanguage());
+ localeId = localeId + L"_" + String(pIcuLocale->getCountry());
+
+ if (!pAvailableLocaleList->Contains(*(pLocale.get())) && pClocaleMap->ContainsKey(localeId))
{
r = pAvailableLocaleList->Add(*(pLocale.get()));
SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make the locale list");