I looked around with Google and within Drupal's site, yet I'm surprised nobody seems to have reported this. Maybe I haven't looked hard enough?

Clean URL's work, the i18n module works, and the gallery module with its "clean URL's" works fine too. I have the English, French, and Japanese languages enabled. Everything is fine... almost.

If you go in the album from another page, since the link to the album is rewritten properly, you'll get the page in the proper language. However, clicking on any picture will bring you back to the English version, since the link is not rewritten. If you write the address manually to get a specific language and to go in a specific sub-album, you'll get the correct language, but with the front page of the album.

To summarize:
(Note: "album" is an alias for the default "gallery" path.)
/album -> Front page of Gallery in English.
/fr/album -> Front page of Gallery in French. (Links point back to default language, English.)
/album/meetup -> "Meetup" album page of Gallery in English.
/fr/album/meetup -> Front page of Gallery in French. (Like /fr/album .)

I tried separating the gallery_embed_uri in the $conf['i18n_variables'] array of the settings.php file. This rewrites the URL's properly. However, when going to /fr/album/meetup, I have the same issue.

I tried rewriting the .htaccess file in the Drupal root folder, which is rewritten by the gallery module in order to make its clean URL system work. I replaced all instances similar to this:

RewriteCond %{THE_REQUEST} \ /album/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !/index\.php$
RewriteRule . /index.php?q=album&g2_view=core.ShowItem&g2_path=%1 [QSA,L]

With the following:

RewriteCond %{THE_REQUEST} \ /([a-z]{2}/)?album/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !/index\.php$
RewriteRule . /index.php?q=%1album&g2_view=core.ShowItem&g2_path=%2 [QSA,L]

This gives me the proper pages, i.e.: /fr/album/meetup gives me the "Meetup" album page in French. However, the links are rewritten incorrectly. A link on the mentioned page to a picture will go to "/fr/album/meetup/album/meetup/[picturepage]" instead of "/fr/album/meetup/[picturepage]".

Has anyone needed to deal with this? Surely I can't be the only one! Any help would be greatly appreciated.

And to all a happy new year. I can't wait for Drupal 5 to be out of beta!

Comments

edinjapan’s picture

You can find a thread related to this topic at the following link, but the answer is "no luck".
http://www.galleryembedded.com/forums/viewtopic.php?t=4095
I ended up switching from i18n to Localizer and the language issues with integrated G2 seem to have gone away. If you want to go that route you can see my post with the hacks (provided by the author of Localizer) at the following link.
http://www.galleryembedded.com/forums/viewtopic.php?p=24809#24809

remi’s picture

Thanks for telling me about that module. I didn't know there was an alternative. However, I'm deceived that, even though it's advertised as working with language codes embedded in the URL (ex: /ja/page or /page?locale=ja), it doesn't. I did set up the URL aliases in my settings.php. Is there something I forgot to do?

I'm trying to avoid using hostnames because of bandwidth transfer. Loading the same image in the album at ja.example.com and en.example.com would be considered different by the browser, hence loaded twice. Also, with this method, changing the language would require a registered user to log in again.

Furthermore, were you able to separate the variables for each language? How about database tables? Those are both great features of i18n that doesn't seem to be supported by localizer.

Rémi
remino.net

Roberto Gerola’s picture

Hi. I'm the author of Localizer module.
Perhaps I can help you. I try.

> it's advertised as working with language codes embedded in the URL (ex: /ja/page or /page?locale=ja), it doesn't
Actually Localizer supports 4 methods for language switching :

- hostname (now fully configurable : www.example.com (for English), fr.example.com or www.example.fr (for French))

- node locale (implicit locale detection)
If you call the localized version of your node the language change accordingly
I mean :
Suppose you have two nodes : www.example.com/products (for English) and www.example.com/produits (for French)
If you call www.example.com/produits the language is changed and everything is translated in French.
- locale prefix in url
You can assign to the two nodes the URL alias : www.example.com/en/products, www.example.com/fr/products
- locale parameter

You don't have to assign url aliases in settings.php.
It is up to you to define the correct aliases.
I prefer this way because I am free to define the url aliases in the proper language of each node.

>were you able to separate the variables for each language?
This is not yet available, but it is present on my todo list.

>How about database tables?
Localizer uses different tables from i18n, it creates and uses its own tables :
localizernode and localizertranslation.

Hope this helps.

Let me know if you have additional questions.

Roberto

remi’s picture

Hi Roberto,

Thanks for your help. About your module, some ideas implemented in it are quite good. However, I'd like to see if its possible to merge i18n and localizer into one. I've already did a lot of work with translations by using i18n, but there's something I like about localizer. It is storing the last used language in $_SESSION.

For now, I've come up with a dirty trick to make i18n do the same while having to enable that new feature manually in settings.php, just to make sure it doesn't bother other sites. I modified _i18n_get_lang() in i18n.module:

function _i18n_get_lang() {
  global $user, $i18n_langpath;
  static $i18n_lang;
  // Check whether the language is already set.
  if ($i18n_lang) {
    return $i18n_lang;
  }
  // Language not set, find one
  $languages = i18n_supported_languages();
  if (($var = variable_get('i18n_language', '')) != '' && array_key_exists($var, $languages)) {
    $i18n_lang = $var;
  }
  elseif ($i18n_langpath && array_key_exists($i18n_langpath,$languages)) {
    $i18n_lang = $i18n_langpath;
  }
  elseif (($var = $_REQUEST['locale']) != '' && array_key_exists($var, $languages)) {
    $i18n_lang = $var;
  }
  elseif (variable_get('i18n_use_last', 0) && ($var = $_SESSION['locale']) != '' && array_key_exists($var, $languages)) {
    $i18n_lang = $var;
  }
  elseif ($user->uid && $user->language && array_key_exists($user->language,$languages)) {
    $i18n_lang = $user->language;
  }
  elseif (variable_get("i18n_browser",0) && $lang=i18n_get_browser_lang()) {
    $i18n_lang=$lang;
  }
  else {
    $i18n_lang=key($languages);
  }

  if(variable_get('i18n_use_last', 0)) $_SESSION['locale'] = $i18n_lang;
  return $i18n_lang;
}

With the above, I can override the language in settings.php with the $conf['i18n_language'] variable, or add ?locale=xx at the end of the URL to specify the language. Also, when enabled, the last used language is stored in the $_SESSION. That way, if I go to a Japanese page, for example /ja/page, then go back to /page2, the page will be displayed in Japanese, until I go to a page of another language.

In your settings.php, add the following line to enable that "feature":
$conf['i18n_use_last'] = 1;

I know, it's dirty and it may break, but it does the trick for me! And I can use Gallery with Clean URL's. There are still somethings I need to work around, but so far so good.

Rémi
remino.net