lang_tags v0.1.0 LangTags.Tag
Tags registered according to the rules in RFC3066
Please note that this tags appears in records whose type is either ‘grandfathered’ or ‘redundant’ and contains a tag registered under RFC3066.
For more information, see section 2.2.8
Summary
Functions
For grandfathered or redundant tags, returns a date string reflecting the date the tag was added to the registry
For grandfathered or redundant tags, returns a date string reflecting the deprecation date if the tag is deprecated
Returns a list of tag descriptions for grandfathered or redundant tags, otherwise returns an empty list
Find a subtag of the given type from those making up the tag
Format a tag according to the case conventions defined in RFC 5646 section 2.1.1
Returns true if the tag is grandfathered, otherwise returns false
Shortcut for find/2 with a language filter
Creates a new tag as a map
If the tag is listed as deprecated or redundant it might have a preferred value. This method returns a tag as a map if so
Returns true if the tag is redundant, otherwise returns false
Shortcut for find/2 with a region filter
Shortcut for find/2 with a script filter
Returns a list of subtags making up the tag, as Subtag maps
Returns “grandfathered” if the tag is grandfathered, “redundant” if the tag is redundant, and “tag” if neither
Returns true if the tag is valid, false otherwise
Functions
For grandfathered or redundant tags, returns a date string reflecting the date the tag was added to the registry.
Examples
iex> LangTags.Tag.added("cel-gaulish")
"2001-05-25"
For grandfathered or redundant tags, returns a date string reflecting the deprecation date if the tag is deprecated.
Examples
iex> LangTags.Tag.deprecated("art-lojban")
"2003-09-02"
iex> "zh-cmn-Hant" |> LangTags.Tag.new() |> LangTags.Tag.deprecated()
"2009-07-29"
Returns a list of tag descriptions for grandfathered or redundant tags, otherwise returns an empty list.
Examples
iex> LangTags.Tag.descriptions("art-lojban")
["Lojban"]
Find a subtag of the given type from those making up the tag.
Examples
iex> LangTags.Tag.find("az-arab", "script")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Arabic"],
"Subtag" => "arab", "Type" => "script"}, "Subtag" => "arab"}
Format a tag according to the case conventions defined in RFC 5646 section 2.1.1.
Examples
iex> LangTags.Tag.format("en-gb-oed")
"en-GB-oed"
iex> "en-gb" |> LangTags.Tag.new() |> LangTags.Tag.format()
"en-GB"
Returns true if the tag is grandfathered, otherwise returns false
Examples
iex> LangTags.Tag.grandfathered?("zh-xiang")
true
iex> LangTags.Tag.grandfathered?("az-Arab")
false
Shortcut for find/2 with a language filter
Examples
iex> LangTags.Tag.language("az-arab")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Azerbaijani"],
"Scope" => "macrolanguage", "Subtag" => "az", "Type" => "language"},
"Subtag" => "az"}
Creates a new tag as a map
Examples
iex> LangTags.Tag.new("en-gb-oed")
%{"Record" => %{"Added" => "2003-07-09", "Deprecated" => "2015-04-17",
"Description" => ["English, Oxford English Dictionary spelling"],
"Preferred-Value" => "en-GB-oxendict", "Tag" => "en-gb-oed",
"Type" => "grandfathered"}, "Tag" => "en-gb-oed"}
If the tag is listed as deprecated or redundant it might have a preferred value. This method returns a tag as a map if so.
Examples
iex> LangTags.Tag.preferred("i-klingon")
%{"Tag" => "tlh"}
iex> "zh-cmn-Hant" |> LangTags.Tag.new() |> LangTags.Tag.preferred()
%{"Tag" => "cmn-hant"}
Returns true if the tag is redundant, otherwise returns false
Examples
iex> LangTags.Tag.redundant?("az-Arab")
true
iex> LangTags.Tag.redundant?("zh-xiang")
false
Shortcut for find/2 with a region filter
Examples
iex> LangTags.Tag.region("en-gb-oeb")["Record"]["Description"] == ["United Kingdom"]
true
Shortcut for find/2 with a script filter
Examples
iex> LangTags.Tag.script("az-arab")
%{"Record" => %{"Added" => "2005-10-16", "Description" => ["Arabic"],
"Subtag" => "arab", "Type" => "script"}, "Subtag" => "arab"}
Returns a list of subtags making up the tag, as Subtag maps.
Note that if the tag is grandfathered the result will be an empty list
Examples
iex> LangTags.Tag.subtags("en-gb-oed")
[]
iex> LangTags.Tag.subtags("az-arab")
LangTags.Tag.subtags("az-arab")
Returns “grandfathered” if the tag is grandfathered, “redundant” if the tag is redundant, and “tag” if neither.
For a definition of grandfathered and redundant tags, see RFC 5646 section 2.2.8.
Examples
iex> LangTags.Tag.type("art-lojban")
"grandfathered"
iex> LangTags.Tag.type("az-Arab")
"redundant"
Returns true if the tag is valid, false otherwise.