z_language_data (zotonic_core v1.0.0-rc.17)
Mandatory background read on language tags: [1].
Some quotes from [1]:
The golden rule when creating language tags is to keep the tag as short as possible. Avoid region, script or other subtags except where they add useful distinguishing information. For instance, use 'ja' for Japanese and not 'ja-JP', unless there is a particular reason that you need to say that this is Japanese as spoken in Japan, rather than elsewhere.
The entries in the registry follow certain conventions with regard to upper and lower letter-casing. For example, language tags are lower case, alphabetic region subtags are upper case, and script tags begin with an initial capital. This is only a convention!
Note that we use lower case subtags in subtag identifiers and URLs.
Language+extlang combinations are provided to accommodate legacy language tag forms, however, there is a single language subtag available for every language+extlang combination. That language subtag should be used rather than the language+extlang combination, where possible. For example, use 'yue' rather than 'zh-yue' for Cantonese, and 'afb' rather than 'ar-afb' for Gulf Arabic, if you can.
Language identifiers can have the following forms: - language; - language-extlang; - language-region; - language-script; It is discouraged to use language-script-region, but it is possible if required. For a list of language, region and script codes, see [2]. [1] http://www.w3.org/International/articles/language-tags/ [2] http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry [3] http://www.loc.gov/standards/iso639-2/php/code_list.php [4] https://en.wikipedia.org/wiki/UN_M49 [5] https://standaarden.overheid.nl/diwoo/metadata/doc/0.9.0/diwoo-metadata-lijsten_xsd_Simple_Type_diwoo_scw_talen
Summary
Functions
-spec codes_atom() -> [atom()].
-spec codes_bin() -> [binary()].
-spec fallback(z_language:language()) -> [z_language:language_code()].
-spec is_language(z_language:language()) -> boolean().
-spec language_names_en() -> [LanguageName] when LanguageName :: binary().
-spec languages_list() -> [{binary(), proplists:proplist()}].
-spec languages_map_flat() -> #{z_language:language_code() | binary() => map()}.
-spec to_language_atom(z_language:language()) -> {ok, atom()} | {error, not_a_language}.