# Gettext and placeholder

**URL:** <https://www.ruby-forum.com/t/gettext-and-placeholder/48113>\
**Category:** Rails\
**Created:** [November 16, 2005, 9:22pm UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113 "2005-11-16T21:22:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 16, 2005, 9:22pm UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113/1 "2005-11-16T21:22:24Z")

</div>

Hello!  
In one of my views i have something like this:

\<% ciccio = ‘panza’ %\>  
\<%=h \_(“yeah #{ciccio}”) %\>

but the localize script from  
[Peak Obsession](http://manuals.rubyonrails.com/read/chapter/105) does not add the second  
line to my pot and po files. Am I doing something wrong? Did someone get  
this to work?

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 17, 2005, 2:19pm UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113/2 "2005-11-17T14:19:12Z")

</div>

Hi,

On Wed, 16 Nov 2005 21:20:57 +0100  
Simon S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello!  
> In one of my views i have something like this:
> 
> \<% ciccio = ‘panza’ %\>  
> \<%=h \_(“yeah #{ciccio}”) %\>
> 
> but the localize script from  
> [Peak Obsession](http://manuals.rubyonrails.com/read/chapter/105) does not add the second  
> line to my pot and po files. Am I doing something wrong? Did someone get  
> this to work?

Ruby-GetText-Package doesn’t support “#{…}” style.  
Use:

\_(“yeah %s”) % ciccio

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 17, 2005, 8:01pm UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113/3 "2005-11-17T20:01:37Z")

</div>

Masao M. wrote:

> Ruby-GetText-Package doesn’t support “#{…}” style.  
> Use:
> 
> \_(“yeah %s”) % ciccio

Thanks!

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 18, 2005, 7:50pm UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113/4 "2005-11-18T19:50:33Z")

</div>

Hi,

On Fri, 18 Nov 2005 00:16:15 +0100  
Sascha E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \_(“yeah :greeting”) % :greeting =\> ‘right’
> 
> The reason for this would be so that the translator will have it easier to  
> translate because more of the context of the message is known when you are  
> looking at the msgid.

Interesting.

If gettext overrides String#%(ary) =\> String#%(hash\_or\_ary),  
It seems we can implement it with backward compatibility.  
I’ll consider your suggestion.

On the other hand, it may be a good proposal to extend the  
behaviour of ruby’s string literal.(ruby-1.9 or 2.0?)

“yeah :greeting :number” % {:greeting =\> ‘right’, :number =\> 10}

So I recommand you to discuss this proposal on ruby-talk  
or ruby-core.

---

<div class="post-metadata">

**Author:** ![Simon.Santoro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Simon.Santoro](https://www.ruby-forum.com/u/Simon.Santoro)\
**Post date:** [November 18, 2005, 12:18am UTC](https://www.ruby-forum.com/t/gettext-and-placeholder/48113/5 "2005-11-18T00:18:52Z")

</div>

Simon S. wrote:

> Masao M. wrote:
> 
> > Ruby-GetText-Package doesn’t support “#{…}” style.  
> > Use:
> > 
> > \_(“yeah %s”) % ciccio

Masao,

what do you think about supporting something like

\_(“yeah :greeting”) % :greeting =\> ‘right’

The reason for this would be so that the translator will have it easier  
to  
translate because more of the context of the message is known when you  
are  
looking at the msgid.

Sascha
