Search code examples
phpdrupalubercartlanguage-switching

Drupal 6+Ubercart Language Switcher Mystery (Catalog OK, Product OK, Category NOT OK)


I am using a Drupal 6.32 + Ubercart 6.x-2.13 installation with all of the latest updates in terms of internationalization.

I am having a problem with the Language Switcher.

The Language Switcher is only working 66% of the time

The website in question is www.holistichorsecare.com and it works most of the time.

Main Catalog Page -> OK

If you go to Catalog:

www.holistichorsecare.com/catalog

(switch)

www.holistichorsecare.com/zh/catalog

The Language Switcher works just fine.

Product Page -> OK

If you choose any given product

www.holistichorsecare.com/products/aromadog-arf-ritis-pain-relief-1oz

(switch)

www.holistichorsecare.com/zh/products/aromadog-arf-ritis-pain-relief-1oz

The Language Switcher works just fine.

Categories View Page -> NOT OK

But if you are in the category browse of the website for a particular type, (say Dogs), the Language Switcher does not work the way I want it to. The translation is not working 100% correctly - or I have set up translation incorrectly.

www.holistichorsecare.com/products/catalog/dogs

(switch)

www.holistichorsecare.com/zh/products/catalog/dogs

>>THIS IS NOT WHAT I AM EXPECTING BECAUSE I HAVE A TRANSLATED TAXONOMY<<

What I am expecting to see is this:

www.holistichorsecare.com/zh/products/catalog/護犬系列

My Translated (Ubercart) Taxonomy

In the catalog taxonomy, I have:

1) Set Dogs to English

2) Set 護犬系列 to Traditional Chinese

3) Set the translation for 護犬系列 to Dogs

So what I want to happen when I use the Language Switcher is to see the "護犬系列" catalog in the (zh) context, not the "dogs" catalog in the (zh) context.

Confused & Frustrated

I've been working on this for several days now, without any luck at all, so I'm reaching out to the Drupal/Ubercart community for advice.

Does anyone have any for me? I think this might be a (catalog) taxonomy translation problem, but toying with the taxonomy in a million different ways has not proved fruitful and now I'm totally confused and frustrated.

Edit

I am now convinced that this is actually a locale.module / Language Switcher problem and that's where I think the energy needs to be directed. I realize that the Language Switcher project may have had little to do with the Ubercart project, which may have resulted in the emergence of this situation - which is probably fairly limited to multilingual Ubercart installations.

I have reached out to some prominent people in the locale.module world and I hope they can see clear to helping here, or at least assisting in the creation of a uc_language_switcher module (or even block code) that is Ubercart specific.

Still, any help or suggestions gratefully accepted.

g.


Solution

  • I have experienced this as well, and it's a tricky one to solve. If you're using the basic taxonomy pages and have a simple term structure, you may find some luck by implementing hook_alter_translation_link() in a custom module to modify the URL provided to the language siwtcher. See i18n_alter_translation_link() for an example on doing so.

    In this hook, you'll have to parse the URL to load the term and then find its translation so that you can return the modified link. What makes this potentially problematic is that parsing the URL means if you use Views with term name translation, you'll need to parse the name to get the term ID yourself.

    On the site I was working on, I had a taxonomy with parent/child terms and was using a View with a taxonomy term argument to construct the catalog. The View term argument was configured to use term name translation and replace spaces with dashes, so parsing the URL ended up being difficult.