Skip to content

Commit 0238e96

Browse files
committed
1 parent 316ff38 commit 0238e96

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

icu4c/source/common/unicode/locid.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,12 @@ class U_COMMON_API DataLocaleInformation : public UMemory {
12921292
public:
12931293
DataLocaleInformation() = default;
12941294

1295+
/**
1296+
* Initializes a DataLocaleInformation object from another
1297+
* DataLocaleInformation object.
1298+
*
1299+
* @param other The DataLocaleInformation object being copied in.
1300+
*/
12951301
DataLocaleInformation(const DataLocaleInformation& other);
12961302

12971303
virtual ~DataLocaleInformation();

icu4c/source/i18n/measfmt.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ bool MeasureFormat::operator==(const Format &other) const {
447447
// We don't need to check locales if both objects have same cache.
448448
if (cache != rhs.cache) {
449449
UErrorCode status = U_ZERO_ERROR;
450-
const char *localeId = getLocaleID(status);
451-
const char *rhsLocaleId = rhs.getLocaleID(status);
450+
const char *localeId = getLocaleID(ULOC_VALID_LOCALE, status);
451+
const char *rhsLocaleId = rhs.getLocaleID(ULOC_VALID_LOCALE, status);
452452
if (U_FAILURE(status)) {
453453
// On failure, assume not equal
454454
return false;
@@ -569,7 +569,7 @@ UnicodeString &MeasureFormat::formatMeasures(
569569

570570
UnicodeString MeasureFormat::getUnitDisplayName(const MeasureUnit& unit, UErrorCode& status) const {
571571
return number::impl::LongNameHandler::getUnitDisplayName(
572-
getLocale(status),
572+
getLocale(ULOC_VALID_LOCALE, status),
573573
unit,
574574
getUnitWidth(fWidth),
575575
status);
@@ -643,7 +643,7 @@ void MeasureFormat::adoptNumberFormat(
643643
}
644644

645645
UBool MeasureFormat::setMeasureFormatLocale(const Locale &locale, UErrorCode &status) {
646-
if (U_FAILURE(status) || locale == getLocale(status)) {
646+
if (U_FAILURE(status) || locale == getLocale(ULOC_VALID_LOCALE, status)) {
647647
return false;
648648
}
649649
initMeasureFormat(locale, fWidth, nullptr, status);
@@ -662,14 +662,6 @@ const PluralRules &MeasureFormat::getPluralRules() const {
662662
return **pluralRules;
663663
}
664664

665-
Locale MeasureFormat::getLocale(UErrorCode &status) const {
666-
return Format::getLocale(ULOC_VALID_LOCALE, status);
667-
}
668-
669-
const char *MeasureFormat::getLocaleID(UErrorCode &status) const {
670-
return Format::getLocaleID(ULOC_VALID_LOCALE, status);
671-
}
672-
673665
UnicodeString &MeasureFormat::formatMeasure(
674666
const Measure &measure,
675667
const NumberFormat &nf,
@@ -697,7 +689,7 @@ UnicodeString &MeasureFormat::formatMeasure(
697689
UnicodeString formattedNumber;
698690
StandardPlural::Form pluralForm = QuantityFormatter::selectPlural(
699691
amtNumber, nf, **pluralRules, formattedNumber, pos, status);
700-
UnicodeString pattern = number::impl::LongNameHandler::getUnitPattern(getLocale(status),
692+
UnicodeString pattern = number::impl::LongNameHandler::getUnitPattern(getLocale(ULOC_VALID_LOCALE, status),
701693
amtUnit, getUnitWidth(fWidth), pluralForm, status);
702694
// The above handles fallback from other widths to short, and from other plural forms to OTHER
703695
if (U_FAILURE(status)) {

icu4c/source/i18n/tmutfmt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
427427
continue;
428428
}
429429
LocalPointer<MessageFormat> messageFormat(new MessageFormat(
430-
pattern, timeUnitFormatObj->getLocale(errorCode), errorCode), errorCode);
430+
pattern, timeUnitFormatObj->getLocale(ULOC_VALID_LOCALE, errorCode), errorCode), errorCode);
431431
if (U_FAILURE(errorCode)) {
432432
return;
433433
}
@@ -472,7 +472,7 @@ TimeUnitFormat::readFromCurrentLocale(UTimeUnitFormatStyle style, const char* ke
472472
// status is an error code used in resource lookup.
473473
// status does not affect "err".
474474
UErrorCode status = U_ZERO_ERROR;
475-
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_UNIT, getLocaleID(status), &status));
475+
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_UNIT, getLocaleID(ULOC_VALID_LOCALE, status), &status));
476476

477477
LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, nullptr, &status));
478478
ures_getByKey(unitsRes.getAlias(), "duration", unitsRes.getAlias(), &status);
@@ -524,7 +524,7 @@ TimeUnitFormat::checkConsistency(UTimeUnitFormatStyle style, const char* key, UE
524524
MessageFormat** formatters = static_cast<MessageFormat**>(countToPatterns->get(*pluralCount));
525525
if( formatters == nullptr || formatters[style] == nullptr ) {
526526
// look through parents
527-
const char* localeName = getLocaleID(err);
527+
const char* localeName = getLocaleID(ULOC_VALID_LOCALE, err);
528528
CharString pluralCountChars;
529529
pluralCountChars.appendInvariantChars(*pluralCount, err);
530530
searchInLocaleChain(style, key, localeName,
@@ -574,7 +574,7 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
574574
if (U_SUCCESS(status)) {
575575
//found
576576
LocalPointer<MessageFormat> messageFormat(
577-
new MessageFormat(UnicodeString(true, pattern, ptLength), getLocale(err), err), err);
577+
new MessageFormat(UnicodeString(true, pattern, ptLength), getLocale(ULOC_VALID_LOCALE, err), err), err);
578578
if (U_FAILURE(err)) {
579579
return;
580580
}
@@ -644,7 +644,7 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
644644
}
645645
if (pattern != nullptr) {
646646
messageFormat.adoptInsteadAndCheckErrorCode(
647-
new MessageFormat(UnicodeString(true, pattern, -1), getLocale(err), err), err);
647+
new MessageFormat(UnicodeString(true, pattern, -1), getLocale(ULOC_VALID_LOCALE, err), err), err);
648648
}
649649
if (U_FAILURE(err)) {
650650
return;

icu4c/source/i18n/unicode/measfmt.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,6 @@ class U_I18N_API MeasureFormat : public Format {
342342
*/
343343
const PluralRules &getPluralRules() const;
344344

345-
/**
346-
* ICU use only.
347-
* @internal.
348-
*/
349-
Locale getLocale(UErrorCode &status) const;
350-
351-
/**
352-
* ICU use only.
353-
* @internal.
354-
*/
355-
const char *getLocaleID(UErrorCode &status) const;
356-
357345
#endif /* U_HIDE_INTERNAL_API */
358346

359347
private:

0 commit comments

Comments
 (0)