Allow translation of postman URLs

Issue #75 resolved
Meiyer created an issue

Our app uses non-English URLs for all functions, and combining those with the URLs of postman looks weird. It would be great if the (textual part of the) URLs could be translated as well, so instead of /briefen/trash we would have /briefen/papierkorb, and instead of /listy/write we would have /listy/napisz.

Comments (5)

  1. Patrick Samson repo owner
    • changed status to open

    Is it just one constant language, or does it vary according to the language of the user? In the former case, you could make your own copy of postman.urls and change the words. Something like:

    url(r'^briefen/', include((my_postman_patterns, 'postman'), namespace='postman'))
    

    Otherwise, does the following sample fulfill your need?

    from django.utils.translation import ugettext_lazy as _
    urlpatterns = [
    ...
        url(_(r'^trash/(?:(?P<option>')+_(OPTIONS)+')/)?$', TrashView.as_view(), name='trash'),
        url(_(r'^write/(?:(?P<recipients>[^/#]+)/)?$'), WriteView.as_view(), name='write'),
    ...
    ]
    

    Any other ideas?

  2. Meiyer reporter

    It should vary according to the language of the user. So the second code snippet is actually what I’m asking for – if postman defines its URLs like this, it will be possible to localise them in postman’s django.po.

    (You could also limit the localisation to the textual part of the URL, that is the trash and write words in your example.)

  3. Patrick Samson repo owner

    Implemented, see the last commit.

    The writing of my sample in my previous comment was wrong, there is no other way than to localize the whole string. So we can't isolate one single word like trash.

    Please experiment. I prefer to wait for a feedback before an official release. For now, only the FR language file is filled. It will take a while for the other languages. You can contribute on transifex, or give your translations here.

  4. Log in to comment