Hi Antoine,

What you are trying will work in the master (1.0-dev).
In the master the z_language variable is handled in a special way.

In the 0.x you can set the language in the request handler or for template 
expressions like:

        {{ _”Hello” with z_language = `de` }}

(Note the back-ticks, that forces an atom, all language codes are atoms.)

In Erlang you can set the language like this:

        Context1 = z_context:set_language(de, Context)

In a dispatch rule you need to use “z_language”, you could do it like this:

        {page, ["page", id, z_language, slug ], controller_page, [ … ]}

And then maybe also force it to be two letters:

        {page, ["page", id, {z_language, “^[a-z][a-z]$”}, slug ], 
controller_page, [ … ]}

Note that this is only used for dispatching requests.
I don’t expect it to work for the url generation...

mod_translation will see the “z_language” during the session notifications and 
set the language.

Regretfully we don’t have a way to force a fixed language in the controller 
options.
That would be easy to add though, if you like you can file an issue for that 
and explain your use case.

Best, Marc


> On 05 Dec 2016, at 19:28, Antoine <antoine.koe...@gmail.com> wrote:
> 
> Hello,
> 
> I'm in a specific configuration that prevent url rewriting for setting 
> language.
> So I tried to extract and language parameter using a dispatch url:
> 
> .. ["page", id, lang, slug ], controller_template ....
> 
> Inside the template I would like to be able to do the following:
> 
>  {% include "_sub_template" z_language=q.lang %}
> 
> But that fails.
> 
> If I understand correctly the only way to force a new language is the 
> z_language var in the javascript side ?
> 
> Is there a way to force z_language ?
> 
> Should I need to create a specific controller_X that will pass a z_language 
> var to a z_render:template() ?
> 
> NOTE:
> I even tried:
> {% with q.lang as z_language %}
> {_ translate me _} 
> {% trans "translate me" %}
> {% endwith %}
> 
> Nothing works :-(
> 
> 
> Thank you !
> 
> 
> 
> -- 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Zotonic developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to zotonic-developers+unsubscr...@googlegroups.com 
> <mailto:zotonic-developers+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Zotonic developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to zotonic-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to