language toggle on the fly

Creating and modifying plugins.
Post Reply
chepiok
Regular
Posts: 7
Joined: Tue Jun 07, 2005 10:14 pm

language toggle on the fly

Post by chepiok » Tue Jun 07, 2005 10:19 pm

My web site is available in 2 different languages. I use url rewriting to finally set a php define that contains the current language (ie. "en" or "fr").

How can I dynamically change the blog language (ie. translation of "comments", "posted by"...) ?

I've try without success to add the line: $serendipity['lang']=SMT_LANGUAGE; to the file config.inc.php of the new serendipity theme I've created for my layout.

Does someone has an idea ?

User avatar
Oliver
Regular
Posts: 178
Joined: Mon Jan 10, 2005 7:43 pm
Location: Herne, Germany
Contact:

Post by Oliver » Tue Jun 07, 2005 11:17 pm

There is a sidebar-plugin for changing the language:

Code: Select all

Choose Language   
Allows visitors to change the frontend interface language
Author: Garvin Hicking; version: 1.0


But I can not say, if this is, what you are looking for, because for the moment, I can not install plugins.

Regards,

- Oliver
Image

chepiok
Regular
Posts: 7
Joined: Tue Jun 07, 2005 10:14 pm

not really

Post by chepiok » Tue Jun 07, 2005 11:26 pm

The problem is that the user already has choose its language on my site. I have an url rewriting that convert /fr/ or /en/ hierachy to get the language parameter. And I want to "push" this language in the strings used by Serendipity (the serendipity_lang_en.inc.php file).

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: not really

Post by garvinhicking » Wed Jun 08, 2005 10:24 am

Look at the "Language autodetection" feature of serendipity. Specifically the function "serendipity_getSessionLanguage" inside include/functions_config.inc.php and search for files calling/Accessing this function.

Have fun,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

chepiok
Regular
Posts: 7
Joined: Tue Jun 07, 2005 10:14 pm

yes but

Post by chepiok » Wed Jun 08, 2005 1:17 pm

there is a "strange" comment in this function : "Find a way to let plugins hook into that sequence :-)".

It' means that for the moment I cannot hook this function. Do you mean I should modified the code (easy but not very good for the future update) ?

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: yes but

Post by garvinhicking » Wed Jun 08, 2005 3:28 pm

You should be able to get around this by used either the embed function of Serendipity, or by using a PHP auto_prepend directive.

Sadly until now I could not find a way to let plugins hook into the code at that point.

Probably the best way would be to modify the code directly, yes...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

chepiok
Regular
Posts: 7
Joined: Tue Jun 07, 2005 10:14 pm

Post by chepiok » Wed Jun 08, 2005 4:44 pm

Ok thansk a lot. And thank you for serendipity, it's rocks!

Post Reply