Problem
i18n_taxonomy does not currently support localized pathauto aliases.

Proposal/solution

  • Alter pathauto's hook_pathauto definition
  • Check whether the vocabulary is localized using i18n_taxonomy_vocabulary_mode()
  • If the vocabulary mode is supported, add alias patterns for all languages (aligning with the way localized node patterns work)
  • In order to avoid breaking pathauto's existing alias update behavior, we exclude terms that belong to localized vocabularies
  • To generate the localized terms, we introduce a new option on the alias bulk update screen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pascalim created an issue. See original summary.

pascalim’s picture

joseph.olstad’s picture

actually, we localize pathauto aliases using the field title which is provided by the title module
all our paths are localized, have been for a long time. Each language that has a translation just using the title token on a pathauto

Make sure language detection is enabled.

Configuration » Regional and language » Languages there are settings for text language detection. By default none of them is enabled.

choose url alias by language
/admin/config/search/path/add

As for pathauto, if using it on a node, you can either use node translation or entity translation , if you're on entity translation you'll need the title module and convert/replace your node title to a field title and entity_translation module and content type configured correctly, if you're using node translation then you won't need the title module or a title_field.

if the above technique is not sufficient for your use case there is always the pathauto_i18n module which I have not used but does localize pathauto in its own way.

*EDIT* is there anyone else that wants to weigh in, it seems to me that there's more than one way to localize pathauto urls. *EDIT* ?

joseph.olstad’s picture

Status: Active » Closed (works as designed)
joseph.olstad’s picture

Component: Taxonomy » Documentation
Category: Bug report » Support request
Status: Closed (works as designed) » Needs review

Just found the documentation in the Site Building guide,

Configure Pathauto to work with language-specific path aliases

is this documentation sufficient?

joseph.olstad’s picture

Ok, so this is specific to taxonomy terms in pathauto, I must have read the issue description too quickly.

If the documentation above is not sufficient to solve the pathauto config with taxonomy terms, you may want to look at a similar type of localization issue for taxonomy terms used with views. There's a patch for the views one, it might inspire a patch for the pathauto use case.

joseph.olstad’s picture

Status: Needs review » Postponed (maintainer needs more info)
anrikun’s picture

Category: Support request » Feature request
Status: Postponed (maintainer needs more info) » Active

I'm reopening this as it is still an issue.
It has to do with Path, not necessarily Pathauto.
When option "Localize. Terms are common for all languages, but their name and description may be localized." is selected and Path is installed, i18n should provide a way to translate URL alias too.

BTW, installing i18n_path has no effect.

anrikun’s picture

Component: Documentation » Taxonomy
bisonbleu’s picture

Just running into this issue.

With Translation mode set to Localize, terms are localized as advertised. But the term's path alias isn't, even when vocab name and term name are properly translated.

joseph.olstad’s picture

there's many ways to configure taxonomy for translation, if you use entity_translation you'll need the title module and will need to enable translation on the title field.
then you'll need to enable and configure the pathauto_i18n module for the aliases which use the title field for alias translations
otherwise if you use content translation there'll be a term for english and a term for the other language and a ttid (translation term id ) been a while , anyhow, there's several options and possibilities, it depends on your use case.

bisonbleu’s picture

Thanks for the quick reply @joseph.olstad. The translating of terms (and vocab name) is working fine with i18n.

The issue I'm having (like others here I think) is with the term's alias. Since the vocab is of type Localized, there is no way for instance to create a pathauto pattern for French terms (like it is possible for content). So I tried with a few tokens listed in the token browser but so far, no luck.

The following look promising but appear to have no effect.:

  • [term:parent:vocabulary:i18n-name]/[term:localized-name]
  • [term:parent:vocabulary:i18n-name]/[term:i18n-name]
bisonbleu’s picture

Status: Active » Closed (works as designed)

OK, I think I found the way to translate term aliases - manually!

On simplytest.me, after the usual multilingual setup (added French) and activating translation on articles I added a Colors taxonomy with Black, White and Red terms which I translated to Noir, Blanc and Rouge. I created dummy English content to which I added a French translation. I can cycle between EN and FR using the Language Switcher block.

When I hover on the Red or Rouge, the alias is the same: colors/red. Looking at the aliases (en/admin/config/search/path) I see that the aliases apply to All languages!

The fix is to simply set the existing alias (colors/red) to English and add a new alias couleurs/rouge for the same system path (taxonomy/term/3) ans set it to French. In the end you get this:

colors/red 	taxonomy/term/3	English
couleurs/rouge 	taxonomy/term/3	French

You can play with this on Simplytest.me. For Drupal 7, set the version to 7.59 before clicking Launch Sandbox.

bisonbleu’s picture

FileSize
133 KB

POC

joseph.olstad’s picture

Category: Feature request » Support request
Status: Closed (works as designed) » Needs review

have you downloaded and enabled the pathauto_i18n module? and configured the path patterns at /admin/config/search/path/patterns?

joseph.olstad’s picture

yeah if you localize the terms, you'd have to probably implement a hook_alter in order to programmatically do what you want to do, there may be other modules or sandbox projects out there to get you closer. Have a look in the pathauto_i18n module to find out which hook_alter you should use, or check the Drupal api or contrib api for pathauto, however check the pathauto_i18n code first.

otherwise, ya if the terms are full entities (entity_translation) using field_title , you can then make use of pathauto_i18n to make a path for each language of the entity just by configuring the patterns at /admin/config/search/path/patterns.

This is by no means the only way, just one of the many ways to do this.

bisonbleu’s picture

Hey Joseph, thanks for pointing out pathauto_i18n. Honestly, I didn't know such a module existed! Or that an i18n module could exist outside of the i18n.module mothership. I'll be sure to try it.

Learn something new everyday... :)

joseph.olstad’s picture

Another really really good tip, for multilingual/bilingual sites, be sure to try out entity_translation_unified_form (your content people will LOVE it) using entity_translation