Forum: Rails I18n t() and 4 variables

Posted by Céd B. (akyrho)
on 2010-08-04 11:38
(Received via mailing list)
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
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-08-04 12:08
(Received via mailing list)
2010/8/4 Céd' <akyrho@gmail.com>

> 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
>
Are you in Rails 3. If yes, you can try to change {{}} by this {%%}
Posted by Céd B. (akyrho)
on 2010-08-04 12:12
(Received via mailing list)
Unfortunately i'm running rails 2.3.5

Le mercredi 04 août 2010 à 12:07 +0200, Andrés gutiérrez a écrit :
Posted by Andrés Gutiérrez (andresgutgon)
on 2010-08-04 12:53
(Received via mailing list)
2010/8/4 Cédric Bousmanne <akyrho@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?
Posted by Céd B. (akyrho)
on 2010-08-04 13:27
(Received via mailing list)
The output is the one i expected

Le mercredi 04 août 2010 à 12:51 +0200, Andrés gutiérrez a écrit :
Posted by Krzysztof Knapik (Guest)
on 2010-08-04 14:42
(Received via mailing list)
2010/8/4 Andrés gutiérrez <andresgutgon@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.
Posted by Krzysztof Knapik (Guest)
on 2010-08-04 14:44
(Received via mailing list)
2010/8/4 Céd' <akyrho@gmail.com>:
> 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).
Posted by Andrés Mejía (Guest)
on 2010-08-04 14:56
(Received via mailing list)
Have you tried changing the variable name? Say, "total_price" instead of
"total"? If that works there might be some strange name conflict 
somewhere.

On Wed, Aug 4, 2010 at 7:43 AM, Krzysztof Knapik 
<krzysztof.knapik@gmail.com
Posted by Céd B. (akyrho)
on 2010-08-04 15:03
(Received via mailing list)
Absolutely, i tried two or three differents names.

Le mercredi 04 août 2010 à 07:54 -0500, Andrés Mejía a écrit :
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.