예제 #1
0
/*!
    Retrieves Symbian locale zero digit.
*/
static QString symbianZeroDigit()
{
    TLocale *locale = _s60Locale.GetLocale();

    // TDigitType enumeration value returned by TLocale
    // will always correspond to zero digit unicode value.
    TDigitType digit = locale->DigitType();
    return QChar(digit);
}
/**
This routine is used to check if conversion of digits is needed.
Conversion is needed if user language is   
- Arabic, Urdu or Farsi and if digit type is Arabic-Indic
- Urdu or Farsi and digit type is Eastern Arabic_indic
- Hindi and digit type is Devanagari. 

@return  ETrue if conversion is needed, EFalse if not
*/
TBool CResourceLoader::LanguageSpecificNumberConverter::IsConversionNeeded()
    {
    TLocale locale;
    locale.Refresh();
    const TLanguage language = User::Language();
    const TDigitType digitType = locale.DigitType();
    
    if ( ( ( language == ELangArabic || language == ELangUrdu || language == ELangFarsi ) &&
         digitType == EDigitTypeArabicIndic ) 
         || ( ( language == ELangUrdu || language == ELangFarsi ) &&
         digitType == EDigitTypeEasternArabicIndic )
         || ( language == ELangHindi && digitType == EDigitTypeDevanagari )
        )
        {
        return ETrue;
        }

    return EFalse;
    }
/**
This routine is used to convert between European digits and 
Arabic-Indic, Eastern Arabic-Indic, Devanagari or Thai digits 
based on existing digit type setting. 

@param aDes  Parameter to change
*/
void CResourceLoader::LanguageSpecificNumberConverter::Convert( TDes &aDes )
    {   
    TLocale locale;
    locale.Refresh();
    const TDigitType digitType = locale.DigitType();
    TChar toArea = 0x030;
    switch( digitType )
        {
        case EDigitTypeWestern:
        case EDigitTypeArabicIndic:
        case EDigitTypeEasternArabicIndic:
        case EDigitTypeDevanagari:
        case EDigitTypeThai:
            toArea = digitType;
            break;
        case EDigitTypeUnknown:
        case EDigitTypeAllTypes:
            return;
        }
    
    const TInt length = aDes.Length();
    for( TInt i = 0; i < length; i++ )
        {
        TChar character = aDes[i];
        TChar fromArea = NumberToBase( character );
        TChar::TBdCategory cat = character.GetBdCategory();
        switch( cat )
            {
            case TChar::EArabicNumber:
            case TChar::EEuropeanNumber:
                character += toArea;
                character -= fromArea;
                aDes[i] = TUint16( character );
                break;
            default: 
                break;
            }
        }
    }
/**
* Current implementation of this should work for any RTL language if it sets the 
* digit type to digit types checked for below
*
* It is meant as a patch for S60 2.0, not as a complete solution to the problem of date
* presentation.
*/
TBool AknDateFormatUtils::DateFieldReOrderingNeeded(TLanguage* aForceLanguage )
    {
    TBool reorderingNeeded(EFalse);
    TLocale locale;
    TLanguage language = (aForceLanguage != NULL) ? *aForceLanguage : AknLangUtils::UserLanguage();

    // Reordering needed in case of RTL language, we have arabic digits and if the separator is not 
    // numeric separator.
     if ( TBidiText::ScriptDirectionality( language ) == TBidiText::ERightToLeft )
        {
        TInt digitType = locale.DigitType();
        if ( digitType == EDigitTypeArabicIndic ||
             digitType == EDigitTypeEasternArabicIndic )
            {
            TChar sep( locale.DateSeparator(1) );
            if ( sep.GetBdCategory() != TChar::ECommonNumberSeparator )
                {
                reorderingNeeded = ETrue;
                }
            }
        }
        
    return reorderingNeeded;
    }