You can set and initiate the default language in the bootstrap init function.
And do the switching in the plugin.

As a suggestion, instead of querying the ip2country db, it would be
-in my opinion- a better
practice to find the browser's default language and set the language
accordingly.

scs

On Mon, Mar 15, 2010 at 8:14 PM, Hector Virgen <[email protected]> wrote:
> The benefit of a front controller plugin is that it will have access to the
> request. This would, for example, allow you to add a link in your layout
> that reads "View in French" that would be a link to the current page but
> with a "lang" parameter in the request:
> <a href="<?= $this->url(array('lang' => 'fr')) ?>">View in French</a>
> Your plugin could then check for a "lang" parameter and then switch the
> site's language (and update the cookie) if it exists.
> I currently use a similar plugin to switch between an "enhanced" version of
> the site (heavy use of JS/CSS) and a "light" version (for mobile browsers)
> without causing the user to lose what page they were on.
>
> --
> Hector
>
>
> On Mon, Mar 15, 2010 at 10:56 AM, holografix . <[email protected]> wrote:
>>
>> Hi
>>
>> I am developing a multi-language site/application and have this scenario:
>>
>> Check if a cookie exists with a language value.
>> If the cookie does not exists, query a 'ip2country' table, set the
>> language based on user's ip and set the cookie
>> User may change language later and the cookie is updated.
>>
>> My question is about the best place to run this code.
>>
>> I have a _initLanguage method in bootstrap but is this a case better
>> suited for a front controller plugin ?
>>
>> Regards,
>> holo
>>
>>
>
>

Reply via email to