From: Younies Mahmoud Date: Wed, 11 Mar 2020 22:11:23 +0000 (+0100) Subject: add usage to number formatter settings header X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01785739fe2c1221df212efa8ca163fa135637d2;p=icu add usage to number formatter settings header --- diff --git a/icu4c/source/i18n/unicode/numberformatter.h b/icu4c/source/i18n/unicode/numberformatter.h index 88ff2d7c6a4..5e13d594ec3 100644 --- a/icu4c/source/i18n/unicode/numberformatter.h +++ b/icu4c/source/i18n/unicode/numberformatter.h @@ -1512,6 +1512,11 @@ class U_I18N_API NumberFormatterSettings { * * Pass this method any instance of {@link MeasureUnit}. For units of measure: * + *

+ * If the `usage` is correctly set, the output unit **will be changed** + * according to the `usage`, `locale` and `unit` values. + *

+ * *
      * NumberFormatter::with().unit(MeasureUnit::getMeter())
      * 
@@ -2041,6 +2046,52 @@ class U_I18N_API NumberFormatterSettings { */ Derived scale(const Scale &scale) &&; + /** + * Specifies the usage of the unit ("length-person", "length-road", + * "mass-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" + *

+ * + *

+ * If the input usage is not exist (e.g. length-dinosaur) or is + * misspelled, the output unit **will not change**. + *

+ * + * Pass this method a `StringPiece` that represents the usage of + * the unit. For example: + * + *
+     * NumberFormatter::with().usage("length-person")
+     * 
+ * + * @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 /**