On Wed, Oct 7, 2009 at 7:41 PM, Steven Roussey <[email protected]> wrote:
>
>> How do other template languages handle this?  I don't have much
>> experience in this area.
>
> Well, what I currently have going is: {[Hello]} to translate Hello
> using meta of {}. That would be the same as {.translate}Hello{.end}
>
> The option where the ordering may change is generally handled by
> sprintf(text,var1,var2) type thing, and like your option 1, a lot of
> people use sprintf(gettranslation("Hello %s"),name).
>
> {.if num singluar}
>  {[There is one book]}
> {.or}
>  {.translate}There are {num} books{.end}
> {.end}

OK, so the problem is that translation can change the ordering of
words, which includes substitution variables.

English: Hello {name}
Spanish: {name} Hola  (making this up)

So you need the translation done with variables in it.

I think the simplest thing would then be to have 2 template expansions again.

file english.strings:
greeting: "Hello {name}"

file spanish.strings:
greeting: "{name} Hola"

file page.template-for-template:   # this file has all your HTML structure
<p>
{greeting|translate}
</p>

expand ->

<p>
Hello {name}
</p>

expand ->

Hello Bob

Another option is to have a type of formatter on sections that format
before expansion:

{.section ||| translate}  <-  ||| means format before substituion
    Hello {name}
{.end}

First "Hello {name}" is passed through "translate", and then
substitution is done.  This may be quite difficult to implement.

This is not very different from the {.translate} {.end} block you
propose, but I would like to make things more generic and not specific
to web app translation.

I don't see the point of {[ ]} in your examples.  {.translate}{.end}
looks better.

Are you really translating a web app now?  If so then we can figure it
out; otherwise I'd like to get the other stuff sorted out first.

Actually I do have marginal experience with some translation on Google
Code -- basically we just copy the templates and translate them, and
the content either drifts or causes a big headache for someone to
tediously fix up.  So yeah coming up with something nicer there would
be good. : )

Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON 
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to