diff --git a/icu4c/source/i18n/messageformat2_formatter.cpp b/icu4c/source/i18n/messageformat2_formatter.cpp index 2d93d1368700..6fd383ebce22 100644 --- a/icu4c/source/i18n/messageformat2_formatter.cpp +++ b/icu4c/source/i18n/messageformat2_formatter.cpp @@ -83,7 +83,7 @@ namespace message2 { MessageFormatter::Builder& MessageFormatter::Builder::setErrorHandlingBehavior( - MessageFormatter::Builder::UMFErrorHandlingBehavior type) { + MessageFormatter::UMFErrorHandlingBehavior type) { switch (type) { case U_MF_STRICT: { signalErrors = true; diff --git a/icu4c/source/i18n/unicode/messageformat2.h b/icu4c/source/i18n/unicode/messageformat2.h index f52d50188280..bfbb8b5750ce 100644 --- a/icu4c/source/i18n/unicode/messageformat2.h +++ b/icu4c/source/i18n/unicode/messageformat2.h @@ -139,6 +139,31 @@ namespace message2 { */ const MFDataModel& getDataModel() const; + /** + * Used in conjunction with the + * MessageFormatter::Builder::`setErrorHandlingBehavior()` method. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + typedef enum UMFErrorHandlingBehavior { + /** + * Suppress errors and return best-effort output. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + U_MF_BEST_EFFORT = 0, + /** + * Signal all MessageFormat errors using the UErrorCode + * argument. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + U_MF_STRICT + } UMFErrorHandlingBehavior; + /** * The mutable Builder class allows each part of the MessageFormatter to be initialized * separately; calling its `build()` method yields an immutable MessageFormatter. @@ -171,29 +196,6 @@ namespace message2 { void clearState(); public: - /** - * Used in conjunction with the `setErrorHandlingBehavior()` method. - * - * @internal ICU 76 technology preview - * @deprecated This API is for technology preview only. - */ - typedef enum UMFErrorHandlingBehavior { - /** - * Suppress errors and return best-effort output. - * - * @internal ICU 76 technology preview - * @deprecated This API is for technology preview only. - */ - U_MF_BEST_EFFORT = 0, - /** - * Signal all MessageFormat errors using the UErrorCode - * argument. - * - * @internal ICU 76 technology preview - * @deprecated This API is for technology preview only. - */ - U_MF_STRICT - } UMFErrorHandlingBehavior; /** * Sets the locale to use for formatting. * diff --git a/icu4c/source/test/intltest/messageformat2test.cpp b/icu4c/source/test/intltest/messageformat2test.cpp index ace1bc548a5d..7b49cf56a1d8 100644 --- a/icu4c/source/test/intltest/messageformat2test.cpp +++ b/icu4c/source/test/intltest/messageformat2test.cpp @@ -75,21 +75,21 @@ void TestMessageFormat2::testFormatterAPI() { // if there's a syntax error UnicodeString pattern = "{{}"; MessageFormatter::Builder mfBuilder(errorCode); - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_BEST_EFFORT); // This shouldn't matter, since there's a syntax error + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); // This shouldn't matter, since there's a syntax error mfBuilder.setPattern(pattern, parseError, errorCode); MessageFormatter mf = mfBuilder.build(errorCode); U_ASSERT(errorCode == U_MF_SYNTAX_ERROR); /* Parsing is done when setPattern() is called, - so setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT) or setSuppressErrors must be called + so setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT) or setSuppressErrors must be called _before_ setPattern() to get the right behavior, and if either method is called after setting a pattern, setPattern() has to be called again. */ // Should get the same behavior with strict errors errorCode.reset(); - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); // Force re-parsing, as above comment mfBuilder.setPattern(pattern, parseError, errorCode); mf = mfBuilder.build(errorCode); @@ -99,7 +99,7 @@ void TestMessageFormat2::testFormatterAPI() { pattern = "{{{$x}}}"; errorCode.reset(); // Check that a pattern with a resolution error gives fallback output - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_BEST_EFFORT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); mfBuilder.setPattern(pattern, parseError, errorCode); mf = mfBuilder.build(errorCode); U_ASSERT(U_SUCCESS(errorCode)); @@ -108,7 +108,7 @@ void TestMessageFormat2::testFormatterAPI() { U_ASSERT(result == "{$x}"); // Check that we do get an error with strict errors - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); mf = mfBuilder.build(errorCode); U_ASSERT(U_SUCCESS(errorCode)); result = mf.formatToString(MessageArguments(), errorCode); @@ -118,7 +118,7 @@ void TestMessageFormat2::testFormatterAPI() { errorCode.reset(); pattern = "hello"; mfBuilder.setPattern(pattern, parseError, errorCode); - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_BEST_EFFORT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); mf = mfBuilder.build(errorCode); U_ASSERT(U_SUCCESS(errorCode)); result = mf.formatToString(MessageArguments(), errorCode); @@ -126,7 +126,7 @@ void TestMessageFormat2::testFormatterAPI() { U_ASSERT(result == "hello"); // Check that behavior is the same with strict errors - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); mf = mfBuilder.build(errorCode); U_ASSERT(U_SUCCESS(errorCode)); result = mf.formatToString(MessageArguments(), errorCode); @@ -286,7 +286,7 @@ void TestMessageFormat2::testAPICustomFunctions() { MessageFormatter::Builder mfBuilder(errorCode); UnicodeString result; // This fails, because we did not provide a function registry: - MessageFormatter mf = mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT) + MessageFormatter mf = mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT) .setPattern("Hello {$name :person formality=informal}", parseError, errorCode) .setLocale(locale) diff --git a/icu4c/source/test/intltest/messageformat2test_utils.h b/icu4c/source/test/intltest/messageformat2test_utils.h index 8ced63372090..c4ad251c7f48 100644 --- a/icu4c/source/test/intltest/messageformat2test_utils.h +++ b/icu4c/source/test/intltest/messageformat2test_utils.h @@ -230,7 +230,7 @@ class TestUtils { } // Initially, set error behavior to strict. // We'll re-run to check for errors. - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_STRICT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); MessageFormatter mf = mfBuilder.build(errorCode); UnicodeString result; @@ -279,7 +279,7 @@ class TestUtils { // Re-run the formatter if there was an error, // in order to get best-effort output errorCode.reset(); - mfBuilder.setErrorHandlingBehavior(MessageFormatter::Builder::U_MF_BEST_EFFORT); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); mf = mfBuilder.build(errorCode); if (U_SUCCESS(errorCode)) { result = mf.formatToString(MessageArguments(testCase.getArguments(), errorCode), errorCode);