MessageFormat


public final class MessageFormat


Summary

Public methods

static final @NonNull String
format(
    @NonNull Context context,
    int id,
    @NonNull Map<@NonNull String, @NonNull Object> namedArguments
)

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

static final @NonNull String
format(
    @NonNull Context context,
    @NonNull Locale locale,
    @NonNull String msg,
    @NonNull Map<@NonNull String, @NonNull Object> namedArguments
)

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

Public methods

format

public static final @NonNull String format(
    @NonNull Context context,
    int id,
    @NonNull Map<@NonNull String, @NonNull Object> namedArguments
)

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
@NonNull Context context

Android context object

int id

Android string resource ID representing ICU-MessageFormat-syntax string

@NonNull Map<@NonNull String, @NonNull Object> namedArguments

map of argument name to argument value

format

public static final @NonNull String format(
    @NonNull Context context,
    @NonNull Locale locale,
    @NonNull String msg,
    @NonNull Map<@NonNull String, @NonNull Object> namedArguments
)

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
@NonNull Context context

Android context object. Used to retrieve user preferences.

@NonNull Locale locale

Locale for number formatting and plural selection etc.

@NonNull String msg

an ICU-MessageFormat-syntax string

@NonNull Map<@NonNull String, @NonNull Object> namedArguments

map of argument name to argument value