# 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)

*** ** * ** ***


```
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 functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)(pattern: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, locale: https://developer.android.com/reference/java/util/Locale.html, arguments: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>)` Formats the specified pattern using the given locale and arguments. |

## Public functions

### format

```
fun format(pattern: String, locale: Locale, arguments: Map<String, Any>): String
```

Formats the specified pattern using the given locale and arguments.

Implementations should ignore extra keys in `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)` is missing from `https://developer.android.com/reference/kotlin/androidx/a2ui/model/catalog/functions/A2uiMessageFormatter#format(kotlin.String,java.util.Locale,kotlin.collections.Map)`, the implementation should throw an exception.

| Parameters |
|---|---|
| `pattern: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the message format pattern in ICU MessageFormat syntax |
| `locale: https://developer.android.com/reference/java/util/Locale.html` | the locale to use for formatting |
| `arguments: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | the map of arguments to replace in the pattern |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the formatted string |