LocalizedStringBuilder

A builder class for creating a composite LocalizedString by combining multiple parameter values with customizable formatting options.

Parameter values are checked, if they are LocalizedString and the locale is applied when creating a new string.

The Any.toString or LocalizedString.toString method of the parameters is evaluated on each call of toString or build

This class implements the LocalizedString interface, allowing for locale-dependent string representations.

Strings or localized strings are appended to a mutable list and can be joined into a single string representation with configurable separators, prefixes, postfixes, truncation, limits, and transformation functions.

Parameters

parameters

The initial strings or localized strings to include in the builder.

Constructors

Link copied to clipboard
constructor(value: CharSequence)
constructor(value: LocalizedString)
constructor()

Creates a LocalizedStringBuilder instance

Properties

Link copied to clipboard
var limit: Int

If the collection could be huge, you can specify a non-negative value of limit, in which case only the first limit elements will be appended, followed by the truncated string (which defaults to "...").

Link copied to clipboard

Used postfix of the generated string. Default "".

Link copied to clipboard

Used prefix of the generated string. Default "".

Link copied to clipboard

Used separator between the parameters. Default "".

Link copied to clipboard
var transform: (Any) -> Any?

Transforms objects before creating the string

Link copied to clipboard

String appended when to many elements are added.

Functions

Link copied to clipboard
Link copied to clipboard

Build the new LocalizedString with the current parameters.

Link copied to clipboard
open operator fun invoke(): String
open operator fun invoke(locale: Locale?): String

Shortcut for toString

Link copied to clipboard

Combines the two LocalizedString into one

Combines the LocalizedString and the String into a LocalizedString

Link copied to clipboard
operator fun plusAssign(other: LocalizedString)
operator fun plusAssign(other: CharSequence)
Link copied to clipboard
open override fun toString(): String

Returns the string value based on the currently set Locale in de.comahe.i18n4k.i18n4k (de.comahe.i18n4k.config.I18n4kConfig.locale)

open override fun toString(locale: Locale?): String

Returns the string value based on the given Locale.