pystache icon indicating copy to clipboard operation
pystache copied to clipboard

i18n support?

Open sontek opened this issue 13 years ago • 3 comments

I'm using pystache + mustache.js to render same templates either client side or server side. Do you have any information on doing translations for mustache? I'd like to support multiple languages with my application.

Thanks

sontek avatar Aug 10 '12 14:08 sontek

https://github.com/dmfrancisco/pystache seems to have added support as well?

sontek avatar Aug 10 '12 14:08 sontek

Without knowing much about the options, if it's necessary to change Pystache in order to support i18n, I would be open to it. The keys for me would be to do so in a way that (1) is consistent with the documented spec (e.g. allow it to be turned off and on if it breaks the spec), and (2) allows people to swap in other implementations if there isn't "one" accepted way to do it. Are there any blog posts, etc. with more information that you've come across?

cjerdonek avatar Aug 10 '12 17:08 cjerdonek

I was able to accomplish i18n by passing a translation function to the render:

def translate(text):
    return 'my translation'

pystache.render('template', {'_': translate})

sontek avatar Aug 14 '12 15:08 sontek