A LanguageConverter supports converting an alpha3 language code with an alpha2 country code and a script code into a custom code
Set of possible custom codes
Convert an alpha3 language code with an alpha2 country code and a script code into a custom code
Parameters: |
|
---|---|
Returns: | the corresponding custom code |
Return type: | string |
Raise: |
A LanguageConverter able to reverse a custom code into a alpha3 ISO-639-3 language code, alpha2 ISO-3166-1 country code and ISO-15924 script code
Reverse a custom code into alpha3, country and script code
Parameters: | code (string) – custom code to reverse |
---|---|
Returns: | the corresponding alpha3 ISO-639-3 language code, alpha2 ISO-3166-1 country code and ISO-15924 script code |
Return type: | tuple |
Raise: | LanguageReverseError |
A LanguageEquivalenceConverter is a utility class that allows you to easily define a LanguageReverseConverter by only specifying the dict from alpha3 to their corresponding symbols.
You must specify the dict of equivalence as a class variable named SYMBOLS.
If you also set the class variable CASE_SENSITIVE to True then the reverse conversion function will be case-sensitive (it is case-insensitive by default).
Example:
class MyCodeConverter(babelfish.LanguageEquivalenceConverter):
CASE_SENSITIVE = True
SYMBOLS = {'fra': 'mycode1', 'eng': 'mycode2'}
A CountryConverter supports converting an alpha2 country code into a custom code
Set of possible custom codes
Convert an alpha2 country code into a custom code
Parameters: | alpha2 (string) – ISO-3166-1 language code |
---|---|
Returns: | the corresponding custom code |
Return type: | string |
Raise: | CountryConvertError |
A CountryConverter able to reverse a custom code into a alpha2 ISO-3166-1 country code
Reverse a custom code into alpha2 code
Parameters: | code (string) – custom code to reverse |
---|---|
Returns: | the corresponding alpha2 ISO-3166-1 country code |
Return type: | string |
Raise: | CountryReverseError |
Manager for babelfish converters behaving like a dict with lazy loading
Loading is done in this order:
The entry point where to look for converters
Internal converters with entry point syntax
Registered converters with entry point syntax
Loaded converters
Register a converter
Parameters: | entry_point (string) – converter to register (entry point syntax) |
---|---|
Raise: | ValueError if already registered |
Unregister a converter
Parameters: | entry_point (string) – converter to unregister (entry point syntax) |
---|