Intl::LanguageTaggish

A role modeling behaviors of a Language Tag

Intl::LanguageTaggish

A role to be implemented by different representations of a language/locale identifier. It provides for the following three methods/attributes:

  • languageThe language, generally in ISO 639 format (as either a Str or something that coerces accordingly)

  • regionThe region, generally in ISO 3166/UN M.49 format (as either a Str or something that coerces accordingly)

  • bcp47A BCP-47 representation of the tag, to the extent possible (as a Str). May be lossy.

Unless you are a lower-level internationalization developer, you probably do not want to use this module, and should instead look at Intl::LanguageTag, which is a module that provides an implementation of this role (following BCP-47).

Raison dโ€™รชtre

While there are not many language tag standards, there are several in common use. This role aims to define some common features to aid their interaction.

A bcp47 method should provide conversion into a BCP-47-compliant string. For example, Apple allows "English" or "Spanish" as valid identifiers for its .lproj identifiers. So a theoretical AppleLProj class that does LanguageTaggish would output English for .language, but for bcp47, would output en.

It is expected that classes implementing LanguageTaggish will add additional methods and attributes. In keeping with tradition established by other language tag frameworks (in particular ICU), requested values not present should return the empty string.The role handles this by default via its FALLBACK method.

In addition, each LanguageTaggish implementor is expected to also provide a method COERCE that should provide a best attempt to convert from some other LanguageTaggish object (normally by using .bcp47 first).

Version history

  • v0.2 - Added X::Intl::LanguageTag as a role for exceptions

  • v0.1 - Initial version

Intl::LanguageTaggish v0.2

A role modeling behaviors of a Language Tag

Authors

  • Matthew Stephen Stuckwisch

License

Artist-2.0

Dependencies

Test Dependencies

Provides

  • Intl::LanguageTaggish
  • X::Intl::LanguageTag

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.

Built with Podlite โ€” the markup and publishing tools behind this site.