MessageFormat


class MessageFormat


Summary

Public companion functions

String
format(context: Context, id: Int, namedArguments: Map<StringAny>)

Formats a message pattern from Android resource for the default locale with a variable number of name/value pair arguments.

String
format(
    context: Context,
    locale: Locale,
    msg: String,
    namedArguments: Map<StringAny>
)

Formats a message pattern string with a variable number of name/value pair arguments.

Public companion functions

format

fun format(context: Context, id: Int, namedArguments: Map<StringAny>): String

Formats a message pattern from Android resource for the default locale with a variable number of name/value pair arguments. Creates an ICU MessageFormat for Locale.getDefault() and pattern, and formats with the arguments.

Parameters
context: Context

Android context object

id: Int

Android string resource ID representing ICU-MessageFormat-syntax string

namedArguments: Map<StringAny>

map of argument name to argument value

format

fun format(
    context: Context,
    locale: Locale = Locale.getDefault(),
    msg: String,
    namedArguments: Map<StringAny>
): String

Formats a message pattern string with a variable number of name/value pair arguments. Creates an ICU MessageFormat for the locale and pattern, and formats with the arguments.

Parameters
context: Context

Android context object. Used to retrieve user preferences.

locale: Locale = Locale.getDefault()

Locale for number formatting and plural selection etc.

msg: String

an ICU-MessageFormat-syntax string

namedArguments: Map<StringAny>

map of argument name to argument value