Skip to content

Language filter

LanguageFilter #

LanguageFilter(language_codes: list[str])

Bases: RapidataFilter

LanguageFilter Class

Can be used to filter who to target based on language codes.

example: LanguageFilter(["en", "de"]) -> will limit the order to be shown to only people who have their phone set to english or german

Parameters:

Name Type Description Default
language_codes list[str]

List of language codes to filter by.

required
Source code in src/rapidata/rapidata_client/filter/language_filter.py
def __init__(self, language_codes: list[str]):
    if not isinstance(language_codes, list):
        raise ValueError("Language codes must be a list")

    # check that all characters in the language codes are lowercase
    if not all([code.islower() for code in language_codes]):
        raise ValueError("Language codes must be lowercase")

    for code in language_codes:
        if not len(code) == 2:
            raise ValueError("Language codes must be two characters long")

    self.languages = language_codes