Language
language_to_alpha2
matches ISO 639-1, ISO 639-2 language codes and IETF language tags to an ISO-3361-1 Alpha-2 country code.
It is important to note that while IETF language tags will always be unambiguous, ISO codes may not be. For instance,
the code ES
can produce a list of country codes corresponding to all countries where Spanish is spoken.
Ambiguous countries are returned as list by default!
If it is not desired that ambiguous country codes are being returned as a list, the option allow_ambiguous=False
can be
passed as a parameter. This will restrict the output to a single, unambiguous country code.
I case matching ambiguous countries is not turned off the function either returns a string (uambiguous) or a list (ambiguous), you code must be able to handle the different types.
Usage Example
Basic Usage | |
---|---|
Different Inputs | |
---|---|