following the advice on this issue #268791: best practice to make a view multilingual
I ended up creating two displays one for English language nodes (using FILTER > "Node translation: Language = English )
with path "en/viewspage"

and a separate one for Greek language nodes (using FILTER > "Node translation: Language = Greek)
with path "viewspage"

both working correctly
"en/viewspage" displays english nodes,
"el/viewspage" displays greek nodes

BUT
the "Language Switcher" block does not know / understand how to reference them correctly

English Flag links to "en/viewspage" which displays correctly
but
Greek Flag links to "el/en/viewspage" and leads to where there are English nodes displayed but interface language is Greek

Anybody has ever found a solution to this ?
Am I doing something wrong ?
what is the stardard way of approaching this ?

Comments

merlinofchaos’s picture

Doesn't the 'current site language' version of the filter play nicely with the language switcher?

giorgosk’s picture

merlin

I tried "Current user's language" for either "page display" (for each language) but no luck still the same behaviour

I assume that is what you are referring to when you say 'current site language'

giorgosk’s picture

Can I at least override this behaviour at the theme level ?

we used to be able to do it with phptemplate_i18n_link on D5 http://www.drupal.org/node/245466
how is this done on D6 ?

giorgosk’s picture

I ended up creating my own "language switcher" block inside page.tpl.php
using this code and changing the href of the multilingual views in an ugly way

  //ugly changes for specific multilingual views
  if ($links['el']['href']=="en/viewspage"){
	$links['el']['href']="viewspage";
  }else if ($links['en']['href']=="viewspage"){
	$links['en']['href']="en/viewspage";
  }

//before 
translation_translation_link_alter()

Providing in essence a way to map a relation between the two views

I understand that there is no mapping between one view (filtered by language) and another one (filtered by a different language)

how should this be handled ? should that be implemented in views ? or in i18n module ? where should I file a feature request ?

Bensbury’s picture

It could be the following because I have been doing this:

English is the defualt language and so it doesn't switch properly.
When you add the _en to the language prefix is screws up the switch.

So what I did was remove the langauage prefix and register the views as ......site/viewname
Otherwise it was forcing me to name it .....site/en/viewname (which was messing it up).

Then I use the current language filter to filter my views.

After that is done I went back and turned the _prefix back on.

Mysterious the view responds to site/viewname, site/en/viewname (which switches to the default) and my other language site/ja/viewname.

If that makes sense and is the kind of thing you are trying to do it works for me.

Best of luck

giorgosk’s picture

Status: Active » Fixed

egeos,

I followed your advice (which is probably what Merlin was suggesting, but could not make it work then)
and I ended up with this setup

One view page display with filter "Language = Current user's language "
(before I had setup 2 page displays - one for each language)

path set to "viewspage"
therefore the views can be accessed at "site/viewspage" for english version
and "site/el/viewspage" for the Greek version

apparently the "site/en/viewspage" leads to "page not found"
but at least the "language switcher" works properly without tweaking

therefore it is a workable solution to my problem
thanks Merlin and egeos

Bensbury’s picture

If you turn the language prefix for english back on in the language settings then site/en/viewspage should work.

Check out: labs.yoroshiku.tv/graphnetwork

All the sections are views...
If you look at the works section you will see that:

http://lab.yoroshiku.tv/graphnetwork/works/2008/all

http://lab.yoroshiku.tv/graphnetwork/en/works/2008/all

http://lab.yoroshiku.tv/graphnetwork/ja/works/2008/all

All display with the default also being in English.

Because the Works link from the menu sets the url to :

http://lab.yoroshiku.tv/graphnetwork/en/works/2008/all for English
or
http://lab.yoroshiku.tv/graphnetwork/ja/works/2008/all for Japanese

However when you use the language switcher inside the Works section
the naughty language switcher does:

http://lab.yoroshiku.tv/graphnetwork/works/2008/all - for English

http://lab.yoroshiku.tv/graphnetwork/ja/works/2008/all for Japanese

Sooooooooooooo you can see it working!

Now I had the same problem as you because when I added an en for my default language prefix it forced me to have en in the views path.

So I turned it off and made the view as just 'graphnetwork/works'

This worked fine but I couldn't target the language from the link (I think......or did it for consistency) :(
So I once I made it I went back to the default language prefix and turned it back to en.

Then everything worked as it does in the examples in the links.

If that is the kind of thing you are trying to achieve then it should work for you. Keep at it!

Also I then did a sexy use of arguments for the filtering :)

The trick I want to know is how to make the View itself Multilingual.

I managed to make the Header multilingual by php and hitting the $languages-language variable with a conditional.
However I couldn't pull the same trick off with the Title.

So if anyone does happen to know or find out:

How can I make the view display it's title in one language and then change the title for another language?

Is there a way to do it through Views or does it require a different way to set it up..........ie two separate view displays?

Thanks!

giorgosk’s picture

Did you try
drupal_set_title ?
in your php snippet ?

Bensbury’s picture

Hi,
No I didn't.
Where can I find that snippet?

I know there are lots of cunning handlers and snippets people can call but I am kind of too dumb to find them. Looking at the API sadly makes entirely no sense to me without examples.

Is it something like drupal_set_title("newe title"); ?

I sure there must be a website that teaches this Drupal aspect somewhere.

giorgosk’s picture

I just tried a "view page display" and the TITLE is localizable
and I could actually translate it

BUT just in case you want to try what I told you with PHP

On your "view page display" > basic setting > "header" > input format php

echo "This is a Multilingual views page<br/>";
$lang = i18n_get_lang();
if($lang=="el")
  drupal_set_title("Greek Title");
else
  drupal_set_title("English Title");

In there you can use any other php code or any drupal function as found on the api
more code snippets can be found here

Nobody learns everything from day 1, we all learn as we go.

Bensbury’s picture

That's nice man.
Works like a charm.

I jut had brackets to stop php throwing an error. - in case someone reads this.

$lang = i18n_get_lang();
if($lang=="el") {
  drupal_set_title("Greek Title");}
else{
  drupal_set_title("English Title");}

How did you translate the title the other way?
With the strings translate thingy or something?

..........and do you know how to do this with the site name?
I guess I could slap that in the page template maybe?

Thanks.

giorgosk’s picture

egeos

The title of a view is available for translation at admin/build/translate/search

Site name title translation available on the same place if you make it MULTILINGUAL using http://drupal.org/node/313272

But its time to do some digging on your own or post a separate support issue on the appropriate module issue queue because this is becoming a lot of issues together and won't benefit anybody other than the two of us.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

greg.harvey’s picture

Follow up note. The approach in #6 works for us. The required option label is most misleading, but glad it's a working solution! =)