2341 // Should be executed prior to the CheckHeader method! |
2352 // Should be executed prior to the CheckHeader method! |
2342 // ----------------------------------------------------------------------------- |
2353 // ----------------------------------------------------------------------------- |
2343 // |
2354 // |
2344 void ChspsInstallationHandler::AddLocalesL( |
2355 void ChspsInstallationHandler::AddLocalesL( |
2345 const TDesC& aPath ) |
2356 const TDesC& aPath ) |
2346 { |
2357 { |
2347 // Find all locale specific subfolders |
2358 // Retrieve phone supported language. |
2348 TFindFile fileFinder( iFsSession ); |
2359 CArrayFixFlat<TInt>* languageCodes = NULL; |
2349 _LIT( KFilter, "*" ); |
2360 hspsServerUtil::GetInstalledLanguagesL( languageCodes ); |
2350 CDir* fileList( NULL ); |
2361 CleanupStack::PushL( languageCodes ); |
2351 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
2362 |
2352 if ( fileList ) |
2363 // Ensure that path contains '\' at the end. |
2353 { |
2364 TFileName xuikonPath; |
2354 CleanupStack::PushL( fileList ); |
2365 xuikonPath.Copy( aPath ); |
2355 TFileName localePath; |
2366 if( xuikonPath.Length() > KPathDelim().Length() ) |
2356 for( TInt i = 0; i < fileList->Count(); i++ ) |
2367 { |
2357 { |
2368 if( xuikonPath.Mid( xuikonPath.Length() - |
2358 const TEntry& entry = (*fileList)[i]; |
2369 KPathDelim().Length() |
2359 if ( entry.IsDir() ) |
2370 ).Compare( KPathDelim ) != 0 ) |
2360 { |
2371 { |
2361 TInt languageIndex = 0; |
2372 xuikonPath.Append( KPathDelim ); |
2362 TLex lex( entry.iName ); |
2373 } |
2363 TInt error = lex.Val( languageIndex ); |
2374 } |
2364 |
2375 |
2365 // See enumarations from e32lang.h |
2376 _LIT( KFormatting, "%02d" ); |
2366 if( !error && languageIndex >= ELangTest ) |
2377 TFileName localePath; |
2367 { |
2378 |
2368 |
2379 for( TInt i = 0; i < languageCodes->Count(); i++ ) |
2369 // Process only supported languages |
2380 { |
2370 CArrayFixFlat<TInt>* languageCodes = NULL; |
2381 const TInt languageCode = languageCodes->At( i ); |
2371 hspsServerUtil::GetInstalledLanguagesL( languageCodes ); |
2382 |
2372 CleanupStack::PushL( languageCodes ); |
2383 // Construct locale path using two digit minium |
2373 TBool isSupported = EFalse; |
2384 // width and zero as padding. |
2374 for( TInt i=0; i<languageCodes->Count(); i++ ) |
2385 |
2375 { |
2386 localePath.Copy( xuikonPath ); |
2376 if( languageCodes->At( i ) == languageIndex ) |
2387 localePath.AppendFormat( KFormatting, languageCode ); |
2377 { |
2388 localePath.Append( KPathDelim ); |
2378 isSupported = ETrue; |
2389 |
2379 break; |
2390 // Check if folder for supported language exists. |
2380 } |
2391 TBool exists = EFalse; |
2381 } |
2392 |
2382 CleanupStack::PopAndDestroy( languageCodes ); |
2393 if( BaflUtils::FolderExists( iFsSession, localePath ) ) |
2383 if( !isSupported ) |
2394 { |
2384 { |
2395 exists = ETrue; |
2385 continue; |
2396 } |
2386 } |
2397 |
2387 |
2398 // Support also one digit type folder naming. |
2388 // If we found the first language specification |
2399 if( !exists && languageCode < 10 ) |
2389 if ( !iDefaultSpecificationSet ) |
2400 { |
2390 { |
2401 localePath.Copy( xuikonPath ); |
2391 // Assume this is the default language shown incase |
2402 localePath.AppendNum( languageCode ); |
2392 // there is no locale for the active UI language |
2403 localePath.Append( KPathDelim ); |
2393 iDefaultSpecification = (TLanguage)languageIndex; |
2404 |
2394 iDefaultSpecificationSet = ETrue; |
2405 if( BaflUtils::FolderExists( iFsSession, localePath ) ) |
2395 } |
2406 { |
2396 |
2407 exists = ETrue; |
2397 // Setup a path to the subdirectory |
2408 } |
2398 localePath.Copy( aPath ); |
2409 } |
2399 localePath.Append( entry.iName ); |
2410 |
2400 localePath.Append( KPathDelim ); |
2411 if( exists ) |
2401 |
2412 { |
2402 // Find localized resources |
2413 // If we found the first language specification |
2403 AddLocalizedResourcesL( |
2414 if ( !iDefaultSpecificationSet ) |
2404 localePath, |
2415 { |
2405 (TLanguage)languageIndex ); |
2416 // Assume this is the default language shown incase |
2406 } |
2417 // there is no locale for the active UI language |
2407 } |
2418 iDefaultSpecification = (TLanguage)languageCode; |
2408 |
2419 iDefaultSpecificationSet = ETrue; |
|
2420 } |
|
2421 |
|
2422 |
|
2423 // Find and add localized resources |
|
2424 AddLocalizedResourcesL( |
|
2425 localePath, |
|
2426 (TLanguage)languageCode ); |
2409 } |
2427 } |
2410 CleanupStack::PopAndDestroy( fileList ); |
2428 } |
2411 fileList = NULL; |
2429 |
2412 } |
2430 CleanupStack::PopAndDestroy( languageCodes ); |
|
2431 languageCodes = NULL; |
2413 } |
2432 } |
2414 |
2433 |
2415 // ----------------------------------------------------------------------------- |
2434 // ----------------------------------------------------------------------------- |
2416 // Adds localized resources from the provided subdirectory |
2435 // Adds localized resources from the provided subdirectory |
2417 // ----------------------------------------------------------------------------- |
2436 // ----------------------------------------------------------------------------- |