# T() and 4 variables

**URL:** <https://www.ruby-forum.com/t/t-and-4-variables/192709>\
**Category:** Rails I18n\
**Created:** [August 4, 2010, 11:38am UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709 "2010-08-04T11:38:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 11:38am UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/1 "2010-08-04T11:38:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 12:08pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/2 "2010-08-04T12:08:39Z")

</div>

2010/8/4 CÃ©d’ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 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 {%%}

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 12:12pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/3 "2010-08-04T12:12:45Z")

</div>

Unfortunately i’m running rails 2.3.5

Le mercredi 04 août 2010 à 12:07 +0200, Andrés gutiérrez a écrit :

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 12:53pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/4 "2010-08-04T12:53:11Z")

</div>

2010/8/4 CÃ©dric Bousmanne [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 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?

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 1:27pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/5 "2010-08-04T13:27:08Z")

</div>

The output is the one i expected

Le mercredi 04 août 2010 à 12:51 +0200, Andrés gutiérrez a écrit :

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 2:42pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/6 "2010-08-04T14:42:05Z")

</div>

2010/8/4 Andrés gutiérrez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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.

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/7 "2010-08-04T14:44:25Z")

</div>

2010/8/4 Céd’ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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).

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 3:03pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/8 "2010-08-04T15:03:09Z")

</div>

Absolutely, i tried two or three differents names.

Le mercredi 04 août 2010 à 07:54 -0500, Andrés Mejía a écrit :

---

<div class="post-metadata">

**Author:** ![akyrho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@akyrho](https://www.ruby-forum.com/u/akyrho)\
**Post date:** [August 4, 2010, 2:56pm UTC](https://www.ruby-forum.com/t/t-and-4-variables/192709/9 "2010-08-04T14:56:08Z")

</div>

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 K.  
\<removed\_email\_address@domain.invalid
