AssemblyLine.language
get_tuplesβ
def get_tuples(lang_codes: List[str],
languages_path: Optional[str] = None) -> List[Tuple[str, str]]
Returns a list of tuples representing the language name, followed by language ISO 639-1 code.
It will use the native_name value from the languages.yml file if available, otherwise it will use the English name from pycountry. If neither is present, it will use the language code itself.
Arguments:
lang_codes
- a list of ISO 639-1 language codes (e.g. ['en', 'es'])languages_path
- the path to the languages.yml file (defaults to data/sources/languages.yml)
Returns:
A list of tuples representing the language name, followed by language ISO 639-1 code.
get_language_list_dropdownβ
def get_language_list_dropdown(lang_codes: List[str],
current: str = "",
languages_path: Optional[str] = None,
event_name="al_change_language",
icon="fa-solid fa-language") -> str
Get a Bootstrap 5 dropdown menu for language selection that can be added to navigation bar.
Arguments:
lang_codes
- a list of ISO 639-1 language codes (e.g. ['en', 'es'])current
- the current language codelanguages_path
- the path to the languages.yml file (defaults to data/sources/languages.yml)event_name
- the name of the event to trigger when the language is changedicon
- the name of the icon to use for the dropdown menu (defaults to fa-solid fa-language)
Returns:
A string containing the HTML for a dropdown menu for language selection.
get_language_list_dropdown_itemβ
def get_language_list_dropdown_item(language: Tuple[str, str],
link: bool = True,
event_name="al_change_language") -> str
Given an ordered tuple, returns a link to the current interview with lang=language code and the link title given in the first part of the tuple.
Arguments:
language
- a tuple containing the language name and language codelink
- whether to return a link or just the textevent_name
- the name of the event to trigger when the language is changed
Returns:
str
- A string containing the HTML for a dropdown menu item for language selection.
get_language_listβ
def get_language_list(languages: Optional[List[Tuple[str, str]]] = None,
current="",
lang_codes: Optional[List[str]] = None,
languages_path: Optional[str] = None,
event_name="al_change_language") -> str
Given a list of language codes, returns a Bootstrap-formatted unordered inline list. The current language will not be a link.
Deprecated behavior: instead of a list of language codes, you can provide list of tuples containing the language name and language code. This is deprecated and may be removed in a future version.
Arguments:
languages
- a list of tuples containing the language name and language code (deprecated)current
- the current language codelang_codes
- a list of ISO 639-1 language codes (e.g. ['en', 'es'])languages_path
- the path to the languages.yml file (defaults to data/sources/languages.yml)event_name
- the name of the event to trigger when the language is changed
Returns:
A string containing the HTML for an unordered inline list of language selection.
get_language_list_itemβ
def get_language_list_item(language,
link=True,
event_name="al_change_language") -> str
Given an ordered tuple, returns a link to the current interview with lang=language code and the link title given in the first part of the tuple.
Arguments:
language
- a tuple containing the language name and language codelink
- whether to return a link or just the textevent_name
- the name of the event to trigger when the language is changed
Returns:
str
- A string containing the HTML for an unordered inline list item for language selection.