MailingList


Re: A suggestion to multiple variabels in a string

by Kristian Hellquist-2 :: Rate this Message:

Reply to Author | View in Thread

Ah sorry

Variables with brackets in a string is variables that is gonna be replaced.

"A [animal] ate a banana".insert_copy("monkey") => "A monkey ate a banana"

By using the brackets syntax you have the chance to change order of
how words will be translated.

Locale.set_translation("[user] fed the [animal]", "[animal] foo bar [user]")

I do think that the bracket syntax also increases readability.

Examples above might not  be the best, but I hope you get the idea. I
really would like to get some feedback of it. I currently using it in
my code and seems like a good idea ... but I might ran in to problems
later that I dont see yet

Thanks again,
Kristian



2008/6/26 Luca Guidi <guidi.luca@...>:

> I haven't understood very well, try with:
>
> "[%s]'s blog posts tagged as [%s]".t % [@attachable.screen_name, @tag.value]
>
> Luca
> --
> blog: www.lucaguidi.com
> Pro-Netics: www.pro-netics.com
> Sourcesense - making sense of Open Source: www.sourcesense.com
>

 « Return to Thread: A suggestion to multiple variabels in a string