Felipe,

Sorry, I'm quite busy these days.

Here is the beginning of something, but I'd prefer to avoid the 'myurl' function. I'm not a dev' so you'll probably jump looking at that.

The base idea was to use only 'mypatterns' for obtainning the same results we handwritten previously, including the ordering observation you did. However, I cannot currently figure how to modify the url call, that's why I had to use 'myurl'.

The following mess mostly butchered url and patterns functions normally used.

It needs testing and that's quite raw but I'll take a look this week-end probably. The don't think I handled 'prefix' variable how it should be but that's for waiting ;)

# urls.py

from django.conf.urls import patterns, include, url
from django.utils.translation import ugettext_lazy as _
from django.conf.urls.i18n import i18n_patterns
from imbadwithnamestoo.utils import mypatterns, myurl

urlpatterns = patterns('',
    #
)
urlpatterns += mypatterns('',
    myurl(_(r'^suporte/'), include('WebSuporte.urls') ),
)


# imbadwithnamestoo.utils

from django.conf import settings
from django.conf.urls import url
from django.utils.translation import activate, deactivate
from django.utils.translation import ugettext


def myurl(regex, view, kwargs=None, name=None, prefix=''):
    return (regex, view, kwargs, name, prefix)

def mypatterns(prefix, *args):
    pattern_list = []
    for t in args:
        # dealing with include or others
        regex, view, kwargs, name, prefix = t

        languages = [lang[0] for lang in settings.LANGUAGES]

        if isinstance(view, (list,tuple)):
            # For include(...) processing.
            for lang in languages:
                activate(lang)
                translated_regex = ugettext(regex)
pattern_list.append(url(translated_regex, view, kwargs, None, prefix))
                deactivate()
            pattern_list.append(url(regex, view, kwargs, name, prefix))
        else:
            pattern_list.append(url(regex, view, kwargs, name, prefix))
            for lang in languages:
                activate(lang)
                translated_regex = ugettext(regex)
pattern_list.append(url(translated_regex, view, kwargs, None, prefix))
                deactivate()

    return pattern_list

Regards,
Michel

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53053AD7.6000105%40yahoo.fr.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to