Class

Locale

A Locale object represents a specific geographical, political, or cultural region.

Source set: Common
public class Locale

A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation— the number should be formatted according to the customs and conventions of the user's native country, region, or culture.

Properties

language

Source set: Common
public val language: String

The ISO 639 compliant language code.

script

Source set: Common
public val script: String

The ISO 15924 compliant 4-letter script code.

region

Source set: Common
public val region: String

The ISO 3166 compliant region code.

Functions

toLanguageTag

Source set: Common
public fun toLanguageTag(): String

Returns a IETF BCP47 compliant language tag representation of this Locale.

Return

A IETF BCP47 compliant language tag.

Members

Companion

Source set: Common
public companion object

Properties

current

Source set: Common
@Deprecated(
            "Locale.current is not backed by snapshot state and does not notify readers on updates. " +
                "In @Composable functions, use LocalLocale.current instead. Outside composables, " +
                "pass the current locale explicitly from an observable state source.",
            replaceWith =
                ReplaceWith("LocalLocale.current", "androidx.compose.ui.platform.LocalLocale"),
        )
        public val current: Locale

Returns a Locale object which represents current locale

Source set: JvmAndAndroid
public class Locale(public val platformLocale: JavaLocale)

Properties

language

Source set: JvmAndAndroid
public val language: String

script

Source set: JvmAndAndroid
public val script: String

region

Source set: JvmAndAndroid
public val region: String

Functions

toLanguageTag

Source set: JvmAndAndroid
public fun toLanguageTag(): String

Members

Companion

Source set: JvmAndAndroid
public actual companion object

Properties

current

Source set: JvmAndAndroid
@Deprecated(
            """
                This method of accessing locale isn't backed by snapshot state, meaning
                that updates to the locale won't notify any readers of this API. To correctly
                read and observe the current locale for situations where it may change, you
                should read from the composition local LocalLocale.
                If you are in a composable function, call LocalLocale.current instead.
                If you are not in a composable function, pass through the locale down to this usage
                from an observable source, and ensure that the usage is invalidated correctly if
                the locale changes.
            """,
            replaceWith =
                ReplaceWith("LocalLocale.current", "androidx.compose.ui.platform.LocalLocale"),
        )
        public val current: Locale

Content updated: