Erlang/OTP Forums

Author Message

<  Erlang Web mailing list  ~  [Erlangweb-users] Language support

Guest
Posted: Mon Mar 22, 2010 6:14 pm Reply with quote
Guest
Hi all,

I'm trying to add international support for a website based on the
Erlang Web 1.4.

I would like to have a couple of links on every page (the notorious
Country flags) that allow the user to set his language session variable.

What I have right now is a link like:

<li><a href="/session/language/en">English</a></li>

Where, in the session controller I do:

language(Args) ->
LanguageId = proplists:get_value(id, Args),
case language_is_supported(LanguageId) of
false ->
ok;
true ->
wpart:fset("session:lang", LanguageId)
end,
{redirect, "/"}.

The problem is that, after setting the preferred language, I would like
the user to be redirected to the page he was visiting before changing
the language. In this case the "__path" variable doesn't help because it
contains the language request and not the "previous" one.

How could I resolve this situation?
I'm probably using the wrong approach but I cannot thing to anything
else right now.

Cheers,

Roberto Aloi
--
University of Kent - Erlang Solutions Ltd.
Twitter: @prof3ta
Blog: http://aloiroberto.wordpress.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
Guest
Posted: Tue Mar 23, 2010 7:51 am Reply with quote
Guest
Hi Roberto,
the first thing which comes to me, is to have link to 'session handler' (/session/language/en) dynamic. Every time you load some page, you can rebuild it.

So, for example, if you are on startpage.html, link could look like /sesssion/en/startpage.html.

Another solution, would be to encode the link in GET variable. The link would look like /session/language/en?current_address=startpage.html.

Finally, it would be possible to make it in more RESTful way and keep in every link to content, on your page, language code (/en/startpage.html), but this is not too good for search engines and indexing (I guess?).

br

MichaƂ Zajda

----- "Roberto Aloi" <roberto.aloi@erlang-solutions.com> wrote:

> Hi all,
>
> I'm trying to add international support for a website based on the
> Erlang Web 1.4.
>
> I would like to have a couple of links on every page (the notorious
> Country flags) that allow the user to set his language session
> variable.
>
> What I have right now is a link like:
>
> <li><a href="/session/language/en">English</a></li>
>
> Where, in the session controller I do:
>
> language(Args) ->
> LanguageId = proplists:get_value(id, Args),
> case language_is_supported(LanguageId) of
> false ->
> ok;
> true ->
> wpart:fset("session:lang", LanguageId)
> end,
> {redirect, "/"}.
>
> The problem is that, after setting the preferred language, I would
> like
> the user to be redirected to the page he was visiting before changing
> the language. In this case the "__path" variable doesn't help because
> it
> contains the language request and not the "previous" one.
>
> How could I resolve this situation?
> I'm probably using the wrong approach but I cannot thing to anything
> else right now.
>
> Cheers,
>
> Roberto Aloi
> --
> University of Kent - Erlang Solutions Ltd.
> Twitter: @prof3ta
> Blog: http://aloiroberto.wordpress.com
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Erlangweb-users mailing list
> Erlangweb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlangweb-users
> http://www.erlang-web.org/
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com

--
Michal Zajda

Erlang Solutions Ltd.
http://www.erlang-solutions.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
Guest
Posted: Tue Mar 23, 2010 12:36 pm Reply with quote
Guest
Roberto,

I am not sure whether Erlang Web supports this, but one option would
be to add the current page to the language-setting URL, and then
retrieve it in the controller. i.e.something like

<li><a href="/session/language/en?/the/current/page.html">English</a></li>

(suitable escaped, of course) and then pick it out again for the redirect.

Make any sense?

graeme
_______________________________________
On 23 March 2010 02:13, Roberto Aloi <roberto.aloi@erlang-solutions.com> wrote:
> Hi all,
>
> I'm trying to add international support for a website based on the
> Erlang Web 1.4.
>
> I would like to have a couple of links on every page (the notorious
> Country flags) that allow the user to set his language session variable.
>
> What I have right now is a link like:
>
> <li><a href="/session/language/en">English</a></li>
>
> Where, in the session controller I do:
>
> language(Args) ->
>

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum