Forum: Ruby on Rails gettext and placeholder

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B6e90ad1e69d563f1f13cccffe137262?d=identicon&s=25 Simon.Santoro (Guest)
on 2005-11-16 21:22
(Received via mailing list)
Hello!
In one of my views i have something like this:

<% ciccio = 'panza' %>
<%=h _("yeah #{ciccio}") %>

but the localize script from
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?
9fe908f5593444a40be14a424c372e58?d=identicon&s=25 mutoh (Guest)
on 2005-11-17 14:19
(Received via mailing list)
Hi,

On Wed, 16 Nov 2005 21:20:57 +0100
Simon Santoro <Simon.Santoro@poste.it> wrote:

> Hello!
> In one of my views i have something like this:
>
> <% ciccio = 'panza' %>
> <%=h _("yeah #{ciccio}") %>
>
> but the localize script from
> 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
B6e90ad1e69d563f1f13cccffe137262?d=identicon&s=25 Simon.Santoro (Guest)
on 2005-11-17 20:01
(Received via mailing list)
Masao Mutoh wrote:
> Ruby-GetText-Package doesn't support "#{...}" style.
> Use:
>
> _("yeah %s") % ciccio
>

Thanks!
722a18819725c0f6275b556ced89a3f4?d=identicon&s=25 se (Guest)
on 2005-11-18 00:18
(Received via mailing list)
Simon Santoro wrote:
> Masao Mutoh 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
9fe908f5593444a40be14a424c372e58?d=identicon&s=25 mutoh (Guest)
on 2005-11-18 19:50
(Received via mailing list)
Hi,

On Fri, 18 Nov 2005 00:16:15 +0100
Sascha Ebach <se@digitale-wertschoepfung.de> 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.
This topic is locked and can not be replied to.