# A2uiMessageFormatter

Artifact: [androidx.a2ui:a2ui-model](https://developer.android.com/jetpack/androidx/releases/a2ui) [View Source](https://cs.android.com/search?q=file:androidx/a2ui/model/catalog/functions/A2uiPluralizeFunction.kt+class:androidx.a2ui.model.catalog.functions.A2uiMessageFormatter) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

*** ** * ** ***


```
public fun interface A2uiMessageFormatter
```

<br />

*** ** * ** ***

Interface to format messages with arguments using the ICU MessageFormat syntax.

The implementation of this interface should be provided by the platform (e.g., using `https://developer.android.com/reference/android/icu/text/MessageFormat.html` or `com.ibm.icu.text.MessageFormat`).

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html pattern, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Locale.html locale, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html> arguments )` Formats the specified pattern using the given locale and arguments. |

## Public methods

### format

```
abstract @NonNull String format(
    @NonNull String pattern,
    @NonNull Locale locale,
    @NonNull Map<@NonNull String, @NonNull Object> arguments
)
```

Formats the specified pattern using the given locale and arguments.

Implementations should ignore extra keys in `https://developer.android.com/reference/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)` that are not present in the `https://developer.android.com/reference/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)`. If a key required by the `https://developer.android.com/reference/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)` is missing from `https://developer.android.com/reference/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)`, the implementation should throw an exception.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html pattern` | the message format pattern in ICU MessageFormat syntax |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Locale.html locale` | the locale to use for formatting |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html> arguments` | the map of arguments to replace in the pattern |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | the formatted string |