t() and 4 variables

7 views
Skip to first unread message

Céd'

unread,
Aug 4, 2010, 4:39:10 AM8/4/10
to rails-i18n
Hi everyone,

I am facing a weird issue with the translation helper.

When i try to display a localized string with 4 variables, here what i
get :

my_string: "We successfully add {{count}} credits available from
{{start_date}} to {{end_date}}. Total : {{total}} EUR"

t("my_string", :count => 3, :start_date => "2010-01-01", :end_date =>
"2010-12-31", :total => 12)

=> "We successfully add 3 credits available from 2010-01-01 to
2010-12-31. Total : {{total}} EUR"

The point is the fourth (total) variable is not interpreted. I tried
to change my variables' order but it didn't change anything.

Thanks per advance for your help

Andrés gutiérrez

unread,
Aug 4, 2010, 6:07:29 AM8/4/10
to rails...@googlegroups.com


2010/8/4 Céd' <aky...@gmail.com>
Are you in Rails 3. If yes, you can try to change {{}} by this {%%}

--
You received this message because you are subscribed to the Google Groups "rails-i18n" group.
To post to this group, send email to rails...@googlegroups.com.
To unsubscribe from this group, send email to rails-i18n+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-i18n?hl=en.


Cédric Bousmanne

unread,
Aug 4, 2010, 6:11:20 AM8/4/10
to rails...@googlegroups.com
Unfortunately i'm running rails 2.3.5

Andrés gutiérrez

unread,
Aug 4, 2010, 6:51:37 AM8/4/10
to rails...@googlegroups.com


2010/8/4 Cédric Bousmanne <aky...@gmail.com>

Unfortunately i'm running rails 2.3.5

Le mercredi 04 août 2010 à 12:07 +0200, Andrés gutiérrez a écrit :
>
> Are you in Rails 3. If yes, you can try to change {{}} by this {%%}
>

Try to print "total" variable in the view:
value of total: <%=  total %>

What is the ouput?

Cédric Bousmanne

unread,
Aug 4, 2010, 7:19:19 AM8/4/10
to rails...@googlegroups.com
The output is the one i expected

Le mercredi 04 août 2010 à 12:51 +0200, Andrés gutiérrez a écrit :
>
>
> 2010/8/4 Cédric Bousmanne <aky...@gmail.com>
> Unfortunately i'm running rails 2.3.5
>
> Le mercredi 04 août 2010 à 12:07 +0200, Andrés gutiérrez a
> écrit :
>
> >
> > Are you in Rails 3. If yes, you can try to change {{}} by
> this {%%}
> >
>
>
> Try to print "total" variable in the view:
> value of total: <%= total %>
>
> What is the ouput?
>
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "rails-i18n" group.
> To post to this group, send email to
> rails...@googlegroups.com.
> To unsubscribe from this group, send email to rails-i18n

> +unsub...@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "rails-i18n" group.
> To post to this group, send email to rails...@googlegroups.com.
> To unsubscribe from this group, send email to rails-i18n

> +unsub...@googlegroups.com.

Krzysztof Knapik

unread,
Aug 4, 2010, 8:41:12 AM8/4/10
to rails...@googlegroups.com
2010/8/4 Andrés gutiérrez <andres...@gmail.com>:

> Are you in Rails 3. If yes, you can try to change {{}} by this {%%}

Rails version does not matter. i18n version is relevant. Also {{}}
throws deprecation, but still works in latest i18n.

Krzysztof Knapik

unread,
Aug 4, 2010, 8:43:33 AM8/4/10
to rails...@googlegroups.com
2010/8/4 Céd' <aky...@gmail.com>:

> Hi everyone,
>
> I am facing a weird issue with the translation helper.
>
> When i try to display a localized string with 4 variables, here what i
> get :
>
> my_string: "We successfully add {{count}} credits available from
> {{start_date}} to {{end_date}}. Total : {{total}} EUR"
>
> t("my_string", :count => 3, :start_date => "2010-01-01", :end_date =>
> "2010-12-31", :total => 12)
>
> => "We successfully add 3 credits available from 2010-01-01 to
> 2010-12-31. Total : {{total}} EUR"

Tried with identical case and works for me (Rails 2.3.8 + i18n 0.4.1).

Andrés Mejía

unread,
Aug 4, 2010, 8:54:39 AM8/4/10
to rails...@googlegroups.com
Have you tried changing the variable name? Say, "total_price" instead of "total"? If that works there might be some strange name conflict somewhere.

--
You received this message because you are subscribed to the Google Groups "rails-i18n" group.
To post to this group, send email to rails...@googlegroups.com.
To unsubscribe from this group, send email to rails-i18n+...@googlegroups.com.

Cédric Bousmanne

unread,
Aug 4, 2010, 9:01:38 AM8/4/10
to rails...@googlegroups.com
Absolutely, i tried two or three differents names.

> +unsub...@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/rails-i18n?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "rails-i18n" group.
> To post to this group, send email to rails...@googlegroups.com.
> To unsubscribe from this group, send email to rails-i18n

> +unsub...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages