Skip to content

Commit

Permalink
Merge pull request unicode-org#8 from younies/units_router_younies
Browse files Browse the repository at this point in the history
Add Todo for Hugo
  • Loading branch information
younies committed Mar 21, 2020
2 parents f930f67 + 910e22c commit 94d9bcf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
52 changes: 52 additions & 0 deletions icu4c/source/i18n/unicode/numberformatter.h
Expand Up @@ -1512,6 +1512,9 @@ class U_I18N_API NumberFormatterSettings {
*
* Pass this method any instance of {@link MeasureUnit}. For units of measure:
*
* NOTE: If the `usage` is set, the output unit **will be changed**
* according to the `usage`, `locale` and `unit` values.
*
* <pre>
* NumberFormatter::with().unit(MeasureUnit::getMeter())
* </pre>
Expand Down Expand Up @@ -2041,6 +2044,45 @@ class U_I18N_API NumberFormatterSettings {
*/
Derived scale(const Scale &scale) &&;

/**
* Specifies the usage of the unit ("person", "road", "person" ...etc.)
*
* NOTE: `usage` will change the output unit depending on the `Locale`
* and the unit value.
* For Example:
* Locale: en_US
* Usage : length-person
* Unit : Meter
*
* If the unit value is 0.25, the output will be "10 inches."
* If the unit value is 1.50, the output will be
* "4 feet and 11 inches"
*
* NOTE: If the input usage is not exist (e.g. "dance") or is misspelled,
* the usage will be **fall backed** to the "default" usage.
*
* Pass this method a `StringPiece` that represents the usage of
* the unit. For example:
*
* <pre>
* NumberFormatter::with().usage("person")
* </pre>
*
* @param usage The unit `usage`.
* @return The fluent chain.
* @draft ICU 67
*/
Derived usage(StringPiece usage) const &;

/**
* Overload of usage() for use on an rvalue reference.
*
* @param usage The unit `usage`.
* @return The fluent chain.
* @draft ICU 67
*/
Derived usage(StringPiece usage) &&;

#ifndef U_HIDE_INTERNAL_API

/**
Expand Down Expand Up @@ -2570,6 +2612,16 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
inline StringClass toDecimalNumber(UErrorCode& status) const;
#endif // U_HIDE_DRAFT_API

#ifndef U_HIDE_DRAFT_API
/**
* Gets the resolved output unit.
*
* @return `MeasureUnit`.
* @draft ICU 67
*/
MeasureUnit getOutputUnit(UErrorCode& status) const;
#endif // U_HIDE_DRAFT_API

#ifndef U_HIDE_INTERNAL_API

/**
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/i18n/unitsrouter.h
Expand Up @@ -53,6 +53,7 @@ class U_I18N_API UnitsRouter {
MaybeStackVector<ConverterPreference> converterPreferences_;
};

// TODO(hugo): Add a comment.
void U_I18N_API getUnitsData(const char *outputRegion, const char *usage, const MeasureUnit &inputUnit,
CharString &category, MeasureUnit &baseUnit,
MaybeStackVector<ConversionRateInfo> &conversionInfo,
Expand Down

0 comments on commit 94d9bcf

Please sign in to comment.