Show path aliases to nodes in other languages

Events happening in the community are now at Drupal community events on www.drupal.org.
deviantintegral's picture

I'm encountering an issue with URL's to nodes in a different language than the user's current language. Currently, the site is set up with English as the default language, and French in a path prefix of /fr. On the home page, there is a view of all book nodes, some in French and some in English. However, if your current language is English, the French bookURL's are set to fr/node/. If you switch to French, all English books are shown as node/.

I've found out that if I insert the appropriate paths into the url_alias table I can make things work as expected. For example:

INSERT INTO url_alias (src, dst, language) SELECT src, CONCAT('fr/', dst), 'en' FROM url_alias WHERE src LIKE 'node%' AND language = 'fr';

seems to work decently.

I've also played with a series of patches to Pathauto and core, but none of them seem to address this issue exactly.

Am I approaching this the wrong way? Is there another way to make Drupal look for alternate language URL's before falling back to no path alias at all? Or, is it best if I turn the above concept into a module or patch to PathAuto?

Thanks for any insights.

Comments

views problem

pasqualle's picture

inserting a language prefix into dst column is absolutely wrong. the language prefix should not be part of the alias..
Drupal should use the correct alias with correct language prefix automatically.

The problem is that the node:link field in views does not add a language parameter to l() function. see: http://views.doc.logrus.com/views__handler__field__node__link_8inc-sourc...
Without language parameter every link linking to a content in different language than current (or language neutral) will not find the url alias. see: http://api.drupal.org/api/function/drupal_lookup_path/6

You should filter the view by current language or you need to create a new views handler for language aware node links..

Is your issue that you want

jmlavarenne's picture

Is your issue that you want to have a language prefix for English also?

If so, go to admin/settings/language/edit/en and make sure English has the en prefix.

Then go to admin/settings/language/configure and choose Path prefix with language fallback.

We don't want a language

deviantintegral's picture

We don't want a language prefix for English. As is, the requirements are rather specific. We're using the i18npath module so that users can omit the path prefix entirely as marketing wants to advertise all sites regardless of languages as example.com/[dealer].

As well, they want the home page to contain a view of all dealers regardless of language.

I think the solution is to write a new views handler, since from the requirements we can't just filter the view to the current language. I'll investigate and post my results. Thanks!

i18npath?

pasqualle's picture

where is this i18npath module?

Whoops - meant

I've submitted a patch

deviantintegral's picture

I've submitted a patch against Views over here: #564536: Provide node language for rendered links.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: