UBool LocalizationInfo::operator==(const LocalizationInfo* rhs) const { if (rhs) { if (this == rhs) { return TRUE; } int32_t rsc = getNumberOfRuleSets(); if (rsc == rhs->getNumberOfRuleSets()) { for (int i = 0; i < rsc; ++i) { if (!streq(getRuleSetName(i), rhs->getRuleSetName(i))) { return FALSE; } } int32_t dlc = getNumberOfDisplayLocales(); if (dlc == rhs->getNumberOfDisplayLocales()) { for (int i = 0; i < dlc; ++i) { const UChar* locale = getLocaleName(i); int32_t ix = rhs->indexForLocale(locale); // if no locale, ix is -1, getLocaleName returns null, so streq returns false if (!streq(locale, rhs->getLocaleName(ix))) { return FALSE; } for (int j = 0; j < rsc; ++j) { if (!streq(getDisplayName(i, j), rhs->getDisplayName(ix, j))) { return FALSE; } } } return TRUE; } } } return FALSE; }
int32_t LocalizationInfo::indexForLocale(const UChar* locale) const { for (int i = 0; i < getNumberOfDisplayLocales(); ++i) { if (streq(locale, getLocaleName(i))) { return i; } } return -1; }
ResTable_config AaptGroupEntry::toParams() const { ResTable_config params; memset(¶ms, 0, sizeof(params)); getMccName(mcc.string(), ¶ms); getMncName(mnc.string(), ¶ms); getLocaleName(locale.string(), ¶ms); getOrientationName(orientation.string(), ¶ms); getDensityName(density.string(), ¶ms); getTouchscreenName(touchscreen.string(), ¶ms); getKeysHiddenName(keysHidden.string(), ¶ms); getKeyboardName(keyboard.string(), ¶ms); getNavigationName(navigation.string(), ¶ms); getScreenSizeName(screenSize.string(), ¶ms); getVersionName(version.string(), ¶ms); return params; }
char * selectTextTable (const char *directory) { char *locale = getLocaleName(); if (locale) { char name[strlen(locale) + 1]; { size_t length = strcspn(locale, ".@"); strncpy(name, locale, length); name[length] = 0; } free(locale); locale = NULL; if (isPosixLocale(name)) { name[0] = 0; } else if (!testTextTable(directory, name)) { char *delimiter = strchr(name, '_'); if (delimiter) { *delimiter = 0; if (!testTextTable(directory, name)) name[0] = 0; } } if (name[0]) { char *textTableName = strdup(name); if (textTableName) return textTableName; logMallocError(); } } return NULL; }
void loadI18NStrings(LauncherProperties * props) { DWORD i=0; DWORD j=0; //read number of locales DWORD numberOfLocales = 0; DWORD numberOfProperties = 0; readNumberWithDebug(props, &numberOfLocales, "number of locales"); if(!isOK(props)) return; if(numberOfLocales==0) { props->status = ERROR_INTEGRITY; return ; } readNumberWithDebug( props, &numberOfProperties, "i18n properties"); if(!isOK(props)) return; if(numberOfProperties==0) { props->status = ERROR_INTEGRITY; return ; } props->i18nMessages = (I18NStrings * ) LocalAlloc(LPTR, sizeof(I18NStrings) * numberOfProperties); props->I18N_PROPERTIES_NUMBER = numberOfProperties; props->i18nMessages->properties = newppChar(props->I18N_PROPERTIES_NUMBER); props->i18nMessages->strings = newppWCHAR(props->I18N_PROPERTIES_NUMBER); for(i=0; isOK(props) && i<numberOfProperties;i++) { // read property name as ASCII char * propName = NULL; char * number = DWORDtoCHARN(i,2); props->i18nMessages->properties[i] = NULL; props->i18nMessages->strings[i] = NULL; propName = appendString(NULL, "property name "); propName = appendString(propName, number); FREE(number); readStringWithDebugA(props, & (props->i18nMessages->properties[i]), propName); FREE(propName); } if(isOK(props)) { DWORD isLocaleMatches; WCHAR * localeName; WCHAR * currentLocale = getLocaleName(); writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Current System Locale : ", 0); writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, currentLocale, 1); if(props->userDefinedLocale!=NULL) { // using user-defined locale via command-line parameter writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[CMD Argument] Try to use locale ", 0); writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, props->userDefinedLocale, 1); FREE(currentLocale); currentLocale = appendStringW(NULL, props->userDefinedLocale); } for(j=0;j<numberOfLocales;j++) { // for all locales in file... // read locale name as UNICODE .. // it should be like en_US or smth like that localeName = NULL; readStringWithDebugW(props, &localeName, "locale name"); if(!isOK(props)) break; isLocaleMatches = (localeName==NULL) ? 1 : searchW(currentLocale, localeName) != NULL; //read properties names and value for(i=0;i<numberOfProperties;i++) { // read property value as UNICODE WCHAR * value = NULL; char * s1 = DWORDtoCHAR(i + 1); char * s2 = DWORDtoCHAR(numberOfProperties); char * s3 = appendString(NULL , "value "); s3 = appendString(s3 , s1); s3 = appendString(s3, "/"); s3 = appendString(s3, s2); FREE(s1); FREE(s2); readStringWithDebugW(props, &value, s3); FREE(s3); if(!isOK(props)) break; if(isLocaleMatches) { //it is a know property FREE(props->i18nMessages->strings[i]); props->i18nMessages->strings[i] = appendStringW(NULL, value); } FREE(value); } FREE(localeName); } FREE(currentLocale); } }