localized_fields/value.py
def translate(self, language: Optional[str] = None) -> Optional[str]:
        """Gets the value in the specified language (or active language).

        Arguments:
            language:
                The language to get the value in. If not specified,
                the currently active language is used.

        Returns:
            The value in the specified (or active) language. If no value
            is available in the specified language, the value is returned
            in one of the fallback languages.
        """

        target_language = (
            language or translation.get_language() or settings.LANGUAGE_CODE
        )

        fallback_config = getattr(settings, "LOCALIZED_FIELDS_FALLBACKS", {})

        target_languages = fallback_config.get(
            target_language, [settings.LANGUAGE_CODE]
        )

        for lang_code in [target_language] + target_languages:
            value = self.get(lang_code)
            if value:
                return value or None

        return None
Gets the value in the specified language (or active language).

        Arguments:
            language:
                The language to get the value in. If not specified,
                the currently active language is used.

        Returns:
            The value in the specified (or active) language. If no value
            is available in the specified language, the value is returned
            in one of the fallback languages.
        
Gets the value in the specified language (or active language).
Gets the value in the specified language ( or active language ) .
def translate(self, language: Optional[str] = None) -> Optional[str]:
        target_language = (
            language or translation.get_language() or settings.LANGUAGE_CODE
        )
        fallback_config = getattr(settings, "LOCALIZED_FIELDS_FALLBACKS", {})
        target_languages = fallback_config.get(
            target_language, [settings.LANGUAGE_CODE]
        )
        for lang_code in [target_language] + target_languages:
            value = self.get(lang_code)
            if value:
                return value or None
        return None
def translate ( self , language : Optional [ str ] = None ) -> Optional [ str ] : target_language = ( language or translation . get_language ( ) or settings . LANGUAGE_CODE ) fallback_config = getattr ( settings , "LOCALIZED_FIELDS_FALLBACKS" , { } ) target_languages = fallback_config . get ( target_language , [ settings . LANGUAGE_CODE ] ) for lang_code in [ target_language ] + target_languages : value = self . get ( lang_code ) if value : return value or None return None
Gets the value in the specified language (or active language).
Gets the value in the specified language ( or active language ) .
"""Gets the value in the specified language (or active language).

        Arguments:
            language:
                The language to get the value in. If not specified,
                the currently active language is used.

        Returns:
            The value in the specified (or active) language. If no value
            is available in the specified language, the value is returned
            in one of the fallback languages.
        """
The value in the specified (or active) language. If no value
is available in the specified language, the value is returned
in one of the fallback languages.
The value in the specified ( or active ) language . If no value is available in the specified language the value is returned in one of the fallback languages .
self
language
Optional[str]
The language to get the value in. If not specified,
the currently active language is used.
The language to get the value in . If not specified the currently active language is used .