> I've been reading about django-localeurl and it looks pretty solid. I
> have an idea for a variation on it where the locale is encoded as a
> subdomain instead of as the first part of the path.
>
> I'm preparing to branch localeurl to support this functionality but I
> wanted to check in with you guys and see if this made sense.
As the author of localeurl: this make a lot of sense. I would love to
see this functionality in the localeurl application itself. Would you
consider contributing it instead of branching?
> I hope this is the right place to discuss this. I couldn't find a
> discussion group for localeurl specifically.
There isn't one. I did set-up one when I started the project, but I
thought there would be too little traffic. Maybe (if Marcin doesn't
mind) I could point to this list as 'the' discussion list.
> I'm also nursing some wacky ideas for how to support translated URLs
> (I mean, translations of the actual URLs so the words in them
> correspond the active locale). I haven't been able to find any
> discussion on how people do this, so it's either a bad idea or a
> really hard problem or both. Still, if anybody's interested, drop me a
> line. I can share my crackpot schemes. :)
Sounds interesting, what do you mean exactly? Something like
'category/1' versus 'kategorie/1'?
Regards,
Joost
--
Joost Cassee
http://joost.cassee.net
> I'm also nursing some wacky ideas for how to support translated URLs
> (I mean, translations of the actual URLs so the words in them
> correspond the active locale). I haven't been able to find any
> discussion on how people do this, so it's either a bad idea or a
> really hard problem or both. Still, if anybody's interested, drop me a
> line. I can share my crackpot schemes. :)
What I really dislike about localeurl is that it requires
monkey-patching urlresolvers.reverse(). Malcolm Tredinnick dropped a
remark the other day on django-developers:
On 17 sep, 02:14, Malcolm Tredinnick <malc...@pointy-stick.com> wrote:
> You can already put any object you like that has a resolve() method into
> urlpatterns(). That object can see every single pattern that passes
> through if it is matched for the pattern ''. We have to *some* kind of
> root object and it happens to be RegexURLResolver.
So here is my idea: localeurl could be based on some class pretending to
be a RegexPattern / RegexURLResolver combination. Not sure yet how that
would work, but this would fit in with other special URL mangling
functionality.
This could work something like this:
urls.py:
urlpatterns = patterns(
localepatterns(
url(...),
),
url(...),
)
Locale dependent paths would go into localepatterns. This would also
make the LOCALE_INDEPENDENT_PATHS obsolete.
Agreed: in *any* part of the URL, though. :-)
> 2. The structure of the site should be presented to me entirely in my
> language or not at all. I don't want to visit the English version of a
> German website and have to suffer German words in the URLs. Of course,
> I assume this is something the non-English-speaking majority out there
> has to suffer a lot more than I do.
Again, agreed: the keyword is "entirely".
> 3. Every resource on a page should have a URL that represents it. This
> conflicts with #1 because it means the language will probably have to
> appear in at least some of the URLs because there are no other tell-
> tales to distinguish the URL in language A from the URL in language B
> (The home page of a site is the most obvious example of this)
Not necessarily, see below.
> The best solution I can think of, from my point of view, stores the
> language code in a subdomain the way wikipedia does. Attempting to
> load the site without a language subdomain either prompts you to chose
> a language or choses one for you the way Django already does and
> redirects you to the appropriate subdomain.
I can think of another one: use a different domain name altogether,
without specifying the language at all.
> URLs should use only language of the active locale. All the words of
> the URL, whether they come from the URL pattern or from the slug of an
> object, should be locale-appropriate.
Again, agreed, with emphasis on "All". :-)
> Here's the URLs that point to the English and German versions of some
> imaginary resource:
> en.mysite.com/category/frogs/
> de.mysite.com/kategorie/frösche/
But notice how "mysite" and "com" are still English language words. :-)
I'd go with these:
www.mysite.com/category/frogs/
www.meinewebsite.de/kategorie/frosche/ (the umlaut should be escaped, or
substituted)
Yes, I know the whole country vs. language distinction: alas, top level
domains denote countries, that's what we have to work with.
Technically speaking, adding third level domains implies changing DNS
anyway, and domain names are fairly inexpensive these days.
> (An interesting side-question: In
> German, are nouns capitalized when they appear in URLs?)
Best practices suggest that URLs elements should not be capitalized, for
easier typing and spelling. Where that criterion conflicts with language
rules, I would still stick to it, but that's a fairly subjective choice.
> The biggest issue has to do with a fourth ideal which I didn't list
> above: Every resource with a URL should know what it's equivalent is
> in every other available locale (i.e. There should be a "switch
> language" widget on every page of the site that does The Right
> Thing(tm)). This isn't so bad for resources that are for specific
> Model instances. That's what django-multilingual is all about, right?
> The problem is dealing with resources that are lists of objects, or in
> some other way don't correspond neatly to a single object in the db.
Yes, that's a problem that should be solved too.
Let's also make use of content negotiation, where available. The browsers
have a preferred language setting, that makes them send a header with the
user preferred language in it.
However, the user of an English-preferring browser may actually want to
read the German version of a site, and we should allow for that. The
"switch language" widget should override content negotiation, possibly
via a cookie or, uglier, via a query string param.
--
Nicola Larosa - http://www.tekNico.net/
TV is all about instilling a desire in you to buy something. Instead,
why not take stock of the good things you already have, and say
"thanks." Then say "no thanks" to the nonsense on TV and let the
falling ratings work the change. - John Schettler, January 2008
> That's a fair point. I don't see why a domain-based language selector
> couldn't support any arbitrary variation of domains, be it via
> subdomains or TLDs or via an entirely different domain. I wonder if it
> would make sense to use Django's contrib.site app here.
I was also wondering what the interaction with contrib.sites would be.
> I know this inspires an obvious question: how do we get new users to
> arrive at the locale-neutral domain?
From Google? Isn't that precisely what you would *not* want? If a user
searched for 'küche' you would want them to arrive at your German site.
Users would only come to the locale-neutral domain by typing it in.
> Thanks for all the feedback. I feel like I'm getting a lot closer to
> being able to define at least my own personal best practice for this.
> I hope it's at least interesting to others.
It is interesting and I am looking forward to your implementation. Would
you like to get svn access to develop something in a branch at the
django-localeurl project location?