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
public val language: String
The ISO 639 compliant language code.
script
public val script: String
The ISO 15924 compliant 4-letter script code.
region
public val region: String
The ISO 3166 compliant region code.
Functions
toLanguageTag
public fun toLanguageTag(): String
Returns a IETF BCP47 compliant language tag representation of this Locale.
Return
A IETF BCP47 compliant language tag.
Members
Companion
public companion object
Properties
current
@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
public class Locale(public val platformLocale: JavaLocale)
Properties
language
public val language: String
script
public val script: String
region
public val region: String
Functions
toLanguageTag
public fun toLanguageTag(): String
Members
Companion
public actual companion object
Properties
current
@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