On Mon, Jun 28, 2010 at 9:33 AM, Kevin Jardine <[email protected]> wrote:
>
>
> --- On Mon, 6/28/10, MightyByte <[email protected]> wrote:
>
>>
>> My current recommendation would be to use a different
>> approach.  A
>> post-run hook seems like the simplest way to do this.
>> You might do
>> something like the following:
>>
>> postRun :: Monad m => Map String String -> Template
>> -> m Template
>> postRun stringLangs t = return $ map (mapAllTags translate)
>> t
>>   where
>>     translate str = fromMaybe str $ Map.lookup
>> str stringLangs
>>
>> ...and then use (addPostRunHook postRun) when you
>> initialize your TemplateState.
>>
>> If you don't want to incur the (small?) performance penalty
>> of the
>> post-run hook, you could use an on-load hook and then make
>> sure all
>> your dynamic splices generate strings that are translated
>> correctly.
>>
>> Does this make sense?
>>
>
> Yes, I think so if this approach allows localised strings to have embedded 
> tags. The web app I am currently using just uses %s and sprintf when 
> inserting parameters into localised strings. But this approach seems 
> primitive given the XML power of Heist. So I want to include tags (which 
> always rennder to bytestrings) instead.

Hmmm, I don't think my code example above will type check.  It looks
like mapAllTags doesn't have the behavior we want, but I think you get
the idea.  Since addPostRunHook takes a function (Template -> m
Template), it is general enough to do what you want.
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to