Locale

world.locale$package.Locale
object Locale

Factory, parsing, composition, and negotiation for Locale.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Locale.type

Members list

Type members

Classlikes

sealed abstract class Invalid(message: String) extends WorldError

Why a tag was refused, each case carrying the offending subtag.

Why a tag was refused, each case carrying the offending subtag.

Attributes

Companion
object
Supertypes
class WorldError
class TypedError
trait NoStackTrace
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Language
class Region
class Script
class Syntax
class Variant
object Invalid

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Invalid.type

Value members

Concrete methods

def apply(language: Language): Locale
def apply(language: Language, region: Region): Locale
def apply(language: Language, script: Script): Locale
def apply(language: Language, script: Script, region: Region): Locale
def negotiate(preferences: String, supported: Seq[Locale]): Option[Locale]

Resolves an Accept-Language header against a supported set by the RFC 4647 Lookup scheme: ranges are parsed, zero-quality entries dropped, and the rest tried in weight order. None when nothing matches. A caller that has already parsed the header feeds the Seq overload.

Resolves an Accept-Language header against a supported set by the RFC 4647 Lookup scheme: ranges are parsed, zero-quality entries dropped, and the rest tried in weight order. None when nothing matches. A caller that has already parsed the header feeds the Seq overload.

Attributes

def negotiate(preferences: Seq[String], supported: Seq[Locale]): Option[Locale]

The same Lookup over ranges the caller has already ordered by preference, for a server that parses the wire grammar itself. Order carries the weighting, and dropping zero-quality ranges is the caller's.

The same Lookup over ranges the caller has already ordered by preference, for a server that parses the wire grammar itself. Order carries the weighting, and dropping zero-quality ranges is the caller's.

Attributes

def parse(tag: String): Either[Invalid, Locale]

Parses and canonicalises a BCP 47 tag, private-use tags (x-...) included, so a genuinely unregistered context is nameable without pretending registration.

Parses and canonicalises a BCP 47 tag, private-use tags (x-...) included, so a genuinely unregistered context is nameable without pretending registration.

Extension and private-use subtags are preserved but not interpreted. The registry's grandfathered irregular tags are refused.

Attributes

Givens

Extensions

Extensions

extension (l: Locale)
def language: Option[Language]

The primary language, where the tag carries one. A private-use tag does not, and nothing is substituted for it.

The primary language, where the tag carries one. A private-use tag does not, and nothing is substituted for it.

Attributes

Adds the most likely script and region where absent, per UTS 35. Identity where the data holds no answer.

Adds the most likely script and region where absent, per UTS 35. Identity where the data holds no answer.

Attributes

The shortest tag that maximises to the same thing, per UTS 35. Identity for a tag with no language to shorten towards.

The shortest tag that maximises to the same thing, per UTS 35. Identity for a tag with no language to shorten towards.

Attributes

def region: Option[Region]
def script: Option[Script]
def value: String

The canonical BCP 47 tag.

The canonical BCP 47 tag.

Attributes

def variants: Vector[String]