@property
    def regex(self):
        """
        For non-default language always returns regex with langauge prefix.
        For default language returns either '', eigher '^{lang_code}/',
        depending on SOLID_I18N_HANDLE_DEFAULT_PREFIX and request url.

        If SOLID_I18N_HANDLE_DEFAULT_PREFIX == True and default langauge
        prefix is present in url, all other urls will be reversed with default
        prefix.
        Otherwise, all other urls will be reversed without default langauge
        prefix.
        """
        language_code = get_language()
        handle_default_prefix = getattr(settings, 'SOLID_I18N_HANDLE_DEFAULT_PREFIX', False)
        if language_code not in self._regex_dict:
            if language_code != settings.LANGUAGE_CODE:
                regex = '^%s/' % language_code
            elif handle_default_prefix:
                if get_language_from_path() == settings.LANGUAGE_CODE:
                    self.compiled_with_default = True
                    regex = '^%s/' % language_code
                else:
                    self.compiled_with_default = False
                    regex = ''
            else:
                regex = ''
            self._regex_dict[language_code] = re.compile(regex, re.UNICODE)
        elif handle_default_prefix and language_code == settings.LANGUAGE_CODE:
            language_from_path = get_language_from_path()
            regex = None
            if self.compiled_with_default and not language_from_path:
                # default language is compiled with prefix, but now client
                # requests the url without prefix. So compile other urls
                # without prefix.
                regex = ''
                self.compiled_with_default = False
            elif not self.compiled_with_default and language_from_path == settings.LANGUAGE_CODE:
                # default language is compiled without prefix, but now client
                # requests the url with prefix. So compile other urls
                # with prefix.
                regex = '^%s/' % language_code
                self.compiled_with_default = True
            if regex is not None:
                clear_url_caches()
                self._regex_dict[language_code] = re.compile(regex, re.UNICODE)
        return self._regex_dict[language_code]
dataset/ETHPy150Open st4lk/django-solid-i18n-urls/solid_i18n/urlresolvers.py/SolidLocaleRegexURLResolver.regex/original