dateparser/languages/locale.py
def translate(self, date_string, keep_formatting=False, settings=None):
        """
        Translate the date string to its English equivalent.

        :param date_string:
            A string representing date and/or time in a recognizably valid format.
        :type date_string: str|unicode

        :param keep_formatting:
            If True, retain formatting of the date string after translation.
        :type keep_formatting: bool

        :return: translated date string.
        """
        date_string = self._translate_numerals(date_string)
        if settings.NORMALIZE:
            date_string = normalize_unicode(date_string)
        date_string = self._simplify(date_string, settings=settings)
        dictionary = self._get_dictionary(settings)
        date_string_tokens = dictionary.split(date_string, keep_formatting)

        relative_translations = self._get_relative_translations(settings=settings)

        for i, word in enumerate(date_string_tokens):
            word = word.lower()
            for pattern, replacement in relative_translations.items():
                if pattern.match(word):
                    date_string_tokens[i] = pattern.sub(replacement, word)
            else:
                if word in dictionary:
                    date_string_tokens[i] = dictionary[word] or ''
        if "in" in date_string_tokens:
            date_string_tokens = self._clear_future_words(date_string_tokens)

        return self._join(list(filter(bool, date_string_tokens)),
                          separator="" if keep_formatting else " ", settings=settings)
def translate(self, date_string, keep_formatting=False, settings=None):
        date_string = self._translate_numerals(date_string)
        if settings.NORMALIZE:
            date_string = normalize_unicode(date_string)
        date_string = self._simplify(date_string, settings=settings)
        dictionary = self._get_dictionary(settings)
        date_string_tokens = dictionary.split(date_string, keep_formatting)

        relative_translations = self._get_relative_translations(settings=settings)

        for i, word in enumerate(date_string_tokens):
            word = word.lower()
            for pattern, replacement in relative_translations.items():
                if pattern.match(word):
                    date_string_tokens[i] = pattern.sub(replacement, word)
            else:
                if word in dictionary:
                    date_string_tokens[i] = dictionary[word] or ''
        if "in" in date_string_tokens:
            date_string_tokens = self._clear_future_words(date_string_tokens)

        return self._join(list(filter(bool, date_string_tokens)),
                          separator="" if keep_formatting else " ", settings=settings)
def translate ( self , date_string , keep_formatting = False , settings = None ) : date_string = self . _translate_numerals ( date_string ) if settings . NORMALIZE : date_string = normalize_unicode ( date_string ) date_string = self . _simplify ( date_string , settings = settings ) dictionary = self . _get_dictionary ( settings ) date_string_tokens = dictionary . split ( date_string , keep_formatting ) relative_translations = self . _get_relative_translations ( settings = settings ) for i , word in enumerate ( date_string_tokens ) : word = word . lower ( ) for pattern , replacement in relative_translations . items ( ) : if pattern . match ( word ) : date_string_tokens [ i ] = pattern . sub ( replacement , word ) else : if word in dictionary : date_string_tokens [ i ] = dictionary [ word ] or '' if "in" in date_string_tokens : date_string_tokens = self . _clear_future_words ( date_string_tokens ) return self . _join ( list ( filter ( bool , date_string_tokens ) ) , separator = "" if keep_formatting else " " , settings = settings )
Translate the date string to its English equivalent.

        :param date_string:
            A string representing date and/or time in a recognizably valid format.
        :type date_string: str|unicode

        :param keep_formatting:
            If True, retain formatting of the date string after translation.
        :type keep_formatting: bool

        :return: translated date string.
Translate the date string to its English equivalent .