Module Iso639.Lang_or_family
Individual and collective languages as a unified type.
This module defines an abstract denotation of language codes of ISO 639-3 and ISO 639-5 and provides conversions to and from 2- and 3-letter codes defined in parts 1, 2, 3, and 5 of the standard.
If you only want to represent individual languages, consider using the Lang module instead.
type tThis type represents an individual language or macrolanguage from ISO 639-3 or a language group from ISO 639-5.
Basic Operations
val equal : t -> t -> boolequal lang1 lang2is true iflang1andlang2refer to the same individual, macro-, or collective language.
val compare : t -> t -> intTotal order corresponding to lexicographic order of codes within ISO 639-3 and ISO 639-5. The order of elements belonging to different parts of the standard is left unspecified for now, and may change between versions until this notice is removed.
val pp : Stdlib.Format.formatter -> t -> unitpp ppf langprints the ISO 639-3 or 639-5 language code onppf.
val scope : t -> [> `Individual | `Macro | `Collective | `Special ]scope langis`Individual,`Macro, or`Specialiflangcorresponds to an individual language, macro language, or special language code from ISO 639-3, and`Collectiveiflangcorresponds to a language group or family form ISO 693-5.
val to_int : t -> intAn injective mapping to 16 bit integers. The result can be used for serialization, but note that the representation may change between versions until this notice is removed. An alternative for permanent storge or operability between versions, is to use
to_part3orto_part5or both.
val of_int_exn : int -> tof_int_exnis the partial inverse ofto_int.- raises Invalid_argument
if the argument is out of range.
val of_int_unsafe : int -> tAn unchecked variant of
of_int_exn. Integers which do not represent ISO language codes are mapped to subterranean languages which at runtime tend to erupt through the logic of the program in unpredictable ways.
Language Code Conversions
val of_string : string -> t optionof_string sis the language or language family represented by the ISO 639-3 or 639-5 language codes.
val to_string : t -> stringto_string langis the ISO 639-3 language code oflangiflangis an individual or macrolanguage and the 639-5 language code oflangiflangis a language group or family.
val is_iso639p1 : t -> boolis_iso639p1 langis true ifflangis represented in ISO 639-1.
val to_iso639p1 : t -> string optionto_iso639p1 langis the two-letter ISO 639-2 code forlangif it exists.
val of_iso639p1 : string -> t optionof_iso639p1 sis the language represented by the ISO 639-1 language codes.
val is_iso639p2 : t -> boolis_iso639p2 langis true ifflangis represented in ISO 639-2.
val to_iso639p2t : t -> string optionto_part3t_string langis the three-letter ISO 639-2T code forlang.
val to_iso639p2b : t -> string optionto_part3b_string langis the three-letter ISO 639-2B code forlang.
val of_iso639p2 : string -> t optionof_iso639p2 sis the language represented by the ISO 639 part 2T or 2B language codes.
val is_iso639p3 : t -> boolis_iso639p3 langis true ifflangis represented in ISO 639-3, i.e. an individual language or macro language.
val to_iso639p3 : t -> string optionto_iso639p3 langis the three-letter ISO 639-3 code forlang. The result coincides with the ISO 639-2 code if it exist, and may clash with an ISO 639-5 code for a language group.
val of_iso639p3 : string -> t optionof_string sis the language represented by the ISO 639-3 language codes.
val is_iso639p5 : t -> boolis_iso639p3 langis true ifflangis represented in ISO 693-5, i.e. a language family or group.
val to_iso639p5 : t -> string optionto_iso639p5 langis the three-letter ISO 639-5 code forlang. The result coincides with the ISO 639-2 code if it exist, and may clash with an ISO 639-3 code for an individual language or macrolanguage.
val of_iso639p5 : string -> t optionof_string sis the language family or group represented by the ISO 639-5 codes.