This should fit what you want.
greetings = ["Hello", "G''day", "Hey",
"Hi"]
puts greetings[rand(greetings.length)]
Thanks,
B.
On Tue, Feb 22, 2011 at 10:09 AM, Heinz Strunk
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> Hey,
>
> is it somehow possible to translate one string e.g.
t(''hello'') to a
> random item of a number of strings?
>
> Example for language files (I know, wrong syntax):
> en:
> hello: Hello, G''day, Hey, Hi
>
> So every time t(''hello'') is rendered on of the strings is
randomly given
> out? Like:
>
>>> puts t(''hello'')
> -> Hello
>>> puts t(''hello'')
> -> Hey
>>> puts t(''hello'')
> -> G''day
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.