Hi all, James,
I have been playing with Gallery 2 for a couple of days now and still discovering new stuff each day :)
I like it!
Here is the bug.
Drupal 4.6.3
Gallery 2
gallery.module cvs (Revision: 1.10, Wed Sep 21)
Drupal works well alone and Gallery too, actually everything is perfert, except one thing.
The default language does not follow NOR gallery NOR Drupal settings.
In Gallery (alone), it is set to Français (French) and works.
In Drupal (alone), it is set to French and works.
But with the integration, Gallery is in English. Here are the urls so you can see for yourself.
drupal alone : http://www.salsamontreal.com/montrealsalsa/
gallery alone : http://www.salsamontreal.com/montrealsalsa/outils/gallery2/
together : http://www.salsamontreal.com/montrealsalsa/gallery/
Edit : Just to double check, I have removed the Site Admin URL rewrite. Since if you don't, Gallery redirect you to the admin of Drupal. The setting is still in Français as he his suppose to be.
Thanks.
Comments
Comment #1
pitpit commentedthis bug stand is the _gallery_init() function:
This piece of code set the gallery language getting the user language whether the visitor is logged in or not.
If not, $user->language retrieve a null string, which is not understood by Gallery as a right 'activeLanguage'.
we can put the following code instead of, to set the gallery language with the drupal default language
Comment #2
alexandreracine commentedThis is not totally true. Since when I did my tests, I was logged in and not. The results where the same.
I think that a fallback aproch would be better in this case, since I think the value you are talking about, the user locale language, is in Drupal only if the "profile" module is enable. Witch is not at the moment on my website.
Something like this would be more proactive, I think.
This is only an algo since my coding days are way behind me.
This would have to be tested thought.
Comment #3
pitpit commentedhi,
the stand-alone Gallery (http://www.salsamontreal.com/montrealsalsa/outils/gallery2/) appears to be in english (except the content you type in), isn't it ? Are you sure you enabled the french translation in gallery2 settings ?
actually the 'locale' module is needed, not the 'profile' module
The code I posted may be bugprone if 'locale' module is not enabled. Here the fixed version:
the only case when drupal default language can not be retrieve ([get the Drupal language now]) = null) is when 'locale' module is not enabled, which means that the webmaster did not use another language than english. So we do not have to set the gallery language (which is english too)
to summary, that's what my code does:
- if user is not defined and 'locale' module is enabled, set the gallery language according to the default language setting in drupal.
- if not, 2 cases :
- webmaster does not user another language than english, ('locale' module is not enabled), $lang will be set with a null string (gallery2 will provide the only installed language too: english)
- the user is defined, $lang will be set with $user->language
Is it right for you ?
Damien
ps : Forgive me, I'm not fluent in english
Comment #4
alexandreracine commentedHi Damien,
No, the stand alone is in French :)
You said that the "bug stand is the _gallery_init() function". But where is that fonction? I have search a couple of files, but haven't found it. I would like to test your patch.
Thanks.
Comment #5
profix898 commentedI have got the same problem here.
Drupal 4.6.3 with locale.module installed. Default lang ist German (de).
Gallery2 with default lang set to German, as well.
I already replaced the _gallery_init() code piece with the one posted above (#3). But it still doesnt
work. The language of gallery2 is always switched to english when I open it from drupal and stays
so until I manually reset gallery2 settings back to german.
Any ideas?
Regards, Thilo
Comment #6
pitpit commentedhi,
alexandreracine> the _gallery_init is in gallery.module file
profix> can you give us your website url and provide us an demo account to have a look on the bug?
Comment #7
alexandreracine commentedHi dpdev,
Just to let you know, that the multilanguage module (in gallery2) does not have to be activated for the translation of gallery2 to work. Also, yes my website in set in French. Here is the description of the module:
So this is only if you want, for example, to have multi-language gallery2 with multi-language captions (descriptions). I made some tests, and it is exactly that. So my Multilanguage module in gallery2 is now deactivated and my gallery2 (stand-alone) is still in French.
-On another note, I'll test the patch too :)
Comment #8
alexandreracine commentedFeedback.
Profix : did you clear your cookies?
dpdev : I have try the second patch by dpdev, and half is working.
Guest user, are now in French. So I would guest that this part of the code...
...is working.
But, when logging as a user, it is still in English.
So by putting only this code, that we will call "second code"...
Everything is working. Visitor or not.
I made some tests. I used the "second code" (works) while not a visitor, uploaded your second patch, and refresh the browser. Gallery2 switch to English.
Comment #9
profix898 commentedSorry for my very delayed response to your messages!
@dpdev
I'm currently working on a new site and of course can provide you access to play with
my configuration! Tell me your email-adress (in case you still want to gain access) to
send the login information to. But you should read the rest of my posting before.
@all
I was able to figure out, that its not necessarily the gallery.module's code causing the
error. I used the following code to trace variables from the code.
Output of code piece above:
user error: language: in /www/htdocs/w005e099/modules/gallery.module on line 321.
It seems like
$user->languageis an empty variable. When setting $lang manually to'de' (look above) all works fine. But why? Do you have any idea why this variable is empty?
I will try to find a clue, look through the locale.module, etc. in hope to reveal this secret ;)
Comment #10
profix898 commentedI just examined my database and it seems like drupal does not fill the language field in table users,
when the user signs up with the default language. I put various language IDs in that field for testing
purposes and voila the gallery switched to according language.
-> the gallery module is works fine (but drupal or perhaps the locale.module does not)
Comment #11
profix898 commentedThe following piece of code extends the one posted above and checks $user->language. If its
empty (= user uses drupal's default language) get default language as you do for guests. It
seems to works with any tested combination of gallery+drupal languages. So try out this one:
Comment #12
alexandreracine commentedInteresting ideed.
I'll try that latest code and give you some feedback.
Comment #13
alexandreracine commentedprofix: Actually, I don't really have some time to test the new code. But, the "second code" is working fine.
My users don't have the privilege to be able to change they language. So why would drupal change that user related value?
Comment #14
iHawk commentedprofix: I had the same problem here, and the code you posted in comment #11 does work perfectly as of now. Thanks!
Comment #15
alexandreracine commentedDoes someone has the code adapted for Drupal 4.6 and Gallery 2.1 ?
Thanks.
Comment #16
alexandreracine commentedWell, the solution seems to upgrade. Closing.