Hi Roberto,
I'm not sure if this is a feature request or a support request.
While most of my url aliases are localized, some are not. For example, I would like to have a localized download page with links such as 'www.domain.com/download' and 'de.domain.com/download'. These two links should point to separate pages that are translations of each other.
I don't know how to accomplish this. The english and german download pages cannot both have the same URL alias 'download'.
Is this even possible, or would this require some localization support in the path module?

Comments

Roberto Gerola’s picture

> Is this even possible, or would this require some localization support in the path module?
No, you cannot do it in this manner.
Regardless of the current hostname, one alias can point to only one page.
If there are two pages, which should be displayed ?

It could be possible to implement this feature with a little module
that register the callback and make a dispatch basing on the current language,
if you want, but it would be a very special feature.

Bodo Maass’s picture

Wouldn't it be better to group url aliases by locale?
There will always be some aliases that are the same in several languages, especially with anglicisms used in the non-english language ('download', 'info', 'news', ...). Names are another thing that will have the same alias regardless of language.

I realize that the 'switch by hostname' approach is not entirely consistent with the drupal design of considering this a single site with one single set of aliases. But an industrial-strength localization effort should address these kind of questions.

If we are going to allow the same alias for different localized pages, this will require some changes in the user interface, as it needs to be aware of this. So in my view one solution would be to add a language attribute to each alias, as this would resolve the problem of entering duplicate aliases.

Roberto Gerola’s picture

Ok. It could work, but only with 'switch by hostname' approach.
One of the first version of localizer, simply translated the content of a node, without
changing the url, and this approach received some strong critics.
The main problem was that reading the lcoale only from the session could work well
with search engines.

So, in fact you could have the same alias pointing to different localized content.

But what you are proposing could work well
Assigning a locale also to an url alias and using it in conjunction with the a
"localized" hostname can have a sense without breaking the search engine
compatibility.

I'll see what I can do. But I suspect that I have to rewrite the path module.

Roberto Gerola’s picture

Sorry, a typing mistake :
"The main problem was that reading the locale only from
the session couldn't work well with the search engines, and it
must explicitly present in the url in some form."

Bodo Maass’s picture

Locale-specific aliases are not limited to the 'switch by hostname' approach. All that matters is that the language is specified somewhere in the URL.
As you just pointed out, getting the language from the session is bad for search engines. We want exactly one url to promote each given page in a consistent manner.

But for the problem of aliases, it does not matter if I get the language from de.domain.com/myname or www.domain.com/de/myname. In both cases, I want the page for 'myname' to be available in different languages, but with the same alias.

If I don't use 'switch by hostname', I can cheat and simply use aliases such as 'de/myname' and 'en/myname'. In fact, this is what I did on my current site with i18n. But it is inconsistent, because usually the language does not need to be part of the alias, only in this case where duplicates need to be deambiguated. I would prefer a cleaner approach where the alias mechanism takes care of that.

Roberto Gerola’s picture

I try to write an example to be sure to have understood correctly.
Suppose that we can specify a locale for each alias target in this manner :

Alias : myalias
For English locale points to : /node/1
For German locale points to : /node/2

With 'switch by hostname' approach I have the same path pointing
to two different nodes, but they are yet distinguishable due to the hostname :

www.mysite.com/myalias -> points to : /node/1
de.mysite.com/myalias -> points to : /node/2

Without 'switch by hostname', I have only one link :

www.mysite.com/myalias

that have to work for both languages, and can work for a human being
because the language is stored in session

But for a crawler, it can't work, because the locale is not present
in the url in any form, neither in hostname.
So the crawler will receive only one version of the page, tipically that
in the default language.
It can work for human beings, but we must be aware that it couldn't work for
search engines.

Have I understood correctly what you mean ?

Thanks

Bodo Maass’s picture

Hi Roberto,

You understood me correctly (mostly).

> www.mysite.com/myalias -> points to : /node/1
> de.mysite.com/myalias -> points to : /node/2

Yes, this is exactly what I want.

> Without 'switch by hostname', I have only one link :
> www.mysite.com/myalias

This is conceivable, but as a site design it does not make any sense. As a designer of a multi-language site I have the following options:

1. switch by hostname, as above

2. switch by path:
www.domain.com/en/myalias -> /node/1
www.domain.com/de/myalias -> /node/2

3. switch by different aliases:
www.domain.com/myEnglishAlias -> /node/1
www.domain.com/myGermanAlias -> /node/2

Obviously the localized-alias feature is only useful for options 1 or 2. So perhaps we make this feature optional, like an extra module or something like that, so that people who want to use it, can, but the others are unaffected by it.

Roberto Gerola’s picture

But the solution 2 :
www.domain.com/en/myalias -> /node/1
www.domain.com/de/myalias -> /node/2

Is already available.

You have to add the two aliases by hand but it
already works with localizer.

Bodo Maass’s picture

Yes, solution 2 is already possible, but requires managing localized aliases by hand.

What remains impossible is solution 1, using switch-by-hostname. The most attractive prospect of solution 1 is that it makes the urls shorter and is therefore better for search engines. So this is the solution I would prefer.

And once we have support for solution 1, it is trivial to switch between solutions 1 and 2 without touching the aliases by hand.

Roberto Gerola’s picture

Yes.
All clear now.
I agree with your proposal.
I see what I have to do to implement it.

Thanks

Roberto Gerola’s picture

Assigned: Unassigned » Roberto Gerola
Category: support » feature
sun’s picture

Title: switch by hostname and duplicate aliases across locales » Multilingual path alias support
Version: 4.7.x-2.6 » 5.x-1.x-dev