- LocalUResourceBundlePointer latnSymbols(
- ures_getByKeyWithFallback(numberElementsRes.getAlias(), gLatn, NULL, &status));
- ures_getByKeyWithFallback(latnSymbols.getAlias(), gSymbols, latnSymbols.getAlias(), &status);
-
- UBool kMonetaryDecimalSet = FALSE;
- UBool kMonetaryGroupingSet = FALSE;
- for(int32_t i = 0; i<kFormatSymbolCount; i++) {
- if ( gNumberElementKeys[i] != NULL ) {
- UErrorCode localStatus = U_ZERO_ERROR;
- if ( !isLatn ) {
- sym = ures_getStringByKeyWithFallback(nonLatnSymbols.getAlias(),
- gNumberElementKeys[i], &len, &localStatus);
- // If we can't find the symbol in the numbering system specific resources,
- // use the "latn" numbering system as the fallback.
- if ( U_FAILURE(localStatus) ) {
- localStatus = U_ZERO_ERROR;
- sym = ures_getStringByKeyWithFallback(latnSymbols.getAlias(),
- gNumberElementKeys[i], &len, &localStatus);
- }
- } else {
- sym = ures_getStringByKeyWithFallback(latnSymbols.getAlias(),
- gNumberElementKeys[i], &len, &localStatus);
- }
-
- if ( U_SUCCESS(localStatus) ) {
- setSymbol((ENumberFormatSymbol)i, UnicodeString(TRUE, sym, len));
- if ( i == kMonetarySeparatorSymbol ) {
- kMonetaryDecimalSet = TRUE;
- } else if ( i == kMonetaryGroupingSeparatorSymbol ) {
- kMonetaryGroupingSet = TRUE;
- }
- }
+ // Set locale IDs
+ // TODO: Is there a way to do this without depending on the resource bundle instance?
+ U_LOCALE_BASED(locBased, *this);
+ locBased.setLocaleIDs(
+ ures_getLocaleByType(
+ numberElementsRes.getAlias(),
+ ULOC_VALID_LOCALE, &status),
+ ures_getLocaleByType(
+ numberElementsRes.getAlias(),
+ ULOC_ACTUAL_LOCALE, &status));
+
+ // Now load the rest of the data from the data sink.
+ // Start with loading this nsName if it is not Latin.
+ DecFmtSymDataSink sink(*this);
+ if (uprv_strcmp(nsName, gLatn) != 0) {
+ CharString path;
+ path.append(gNumberElements, status)
+ .append('/', status)
+ .append(nsName, status)
+ .append('/', status)
+ .append(gSymbols, status);
+ ures_getAllItemsWithFallback(resource.getAlias(), path.data(), sink, status);
+
+ // If no symbols exist for the given nsName and resource bundle, silently ignore
+ // and fall back to Latin.
+ if (status == U_MISSING_RESOURCE_ERROR) {
+ status = U_ZERO_ERROR;
+ } else if (U_FAILURE(status)) {
+ return;