Intl::LanguageTaggish
A role to be implemented by different representations of a language/locale identifier.
It provides for the following three methods/attributes:
language
The language, generally in ISO 639 format (as either a Str or something that coerces accordingly)region
The region, generally in ISO 3166/UN M.49 format (as either a Str or something that coerces accordingly)bcp47
A 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