defunkt / pystache

Mustache in Python
http://mustache.github.com/
MIT License
1.31k stars 308 forks source link

i18n support? #128

Open sontek opened 12 years ago

sontek commented 12 years ago

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 commented 12 years ago

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

cjerdonek commented 12 years ago

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?

sontek commented 12 years ago

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

def translate(text):
    return 'my translation'

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