Localizing a site with Jade

408 views
Skip to first unread message

kmalakoff

unread,
Sep 6, 2012, 4:49:38 AM9/6/12
to jad...@googlegroups.com
Hello,

I've been requested to provide hooks by a community member who would like to translate one of my websites.

I'd like to pull out all of my strings into an external file, update my .jade files to refer to those strings, and hand off the string file to the volunteer. 

Is there a good localization plugin that handles this sort of thing in Jade? If not, does anyone have a working localized site in Jade that would be a good reference site for me to learn some best practices through this translation transition?

Any pointers would be much appreciated!

Kevin

Jan Buschtöns

unread,
Sep 6, 2012, 5:39:15 AM9/6/12
to jad...@googlegroups.com
+1

Noah Kantrowitz

unread,
Sep 6, 2012, 11:30:48 PM9/6/12
to jad...@googlegroups.com
I just submitted https://github.com/visionmedia/jade/pull/758 to enable this kind of stuff, but haven't heard anything back. The actual low-level filter is pretty simple so far:

filters.t = (str) -> i18n.gettext($.trim(str))

Where in my case i18n is a Jed object, but you could also use gettext.js.

--Noah

signature.asc

Kevin Malakoff

unread,
Sep 7, 2012, 5:22:23 AM9/7/12
to jad...@googlegroups.com
Thank you for the pointer Noah! 

I haven't really dug into how the Jade pipeline works under the hood so I'm not really clear on how to use your pull request ;-P

All I do is run jade like 'jade --pretty --out public app' from a script. 

Is there a sample project (even if it is really, really simple!) where I can see how to make a string table with multiple languages, hook in your script, and call your script from a .jade file?

One potential complication is that I mix Jade's HTML generation syntax with 'marked' github-flavored-markdown so sections of my .jade files may require different translation schemes/approaches...

Cheers,

Kevin

Noah Kantrowitz

unread,
Sep 7, 2012, 6:17:44 AM9/7/12
to jad...@googlegroups.com
> One potential complication is that I mix Jade's HTML generation syntax with 'marked' github-flavored-markdown so sections of my .jade files may require different translation schemes/approaches…

I threw up some of our code in to https://gist.github.com/890cbf99502b66634f44, but it may not be all that useful. The system is 1) unfinished, I haven't written a string extractor that will dump .pot yet and 2) highly opinionated re: require.js and precompilation. It seems like most people are using Jade in a server-side Node context, so I'm not sure how much of this will translate over directly, but it should get you close. If the pull request I mentioned get accepted it will be at least somewhat possible to package all this stuff up eventually, but until then you'll need to patch your lexer and parser.

--Noah


signature.asc

Kevin Malakoff

unread,
Sep 7, 2012, 6:25:01 AM9/7/12
to jad...@googlegroups.com
Excellent! Thank you for the quick response and gist link. Much appreciated!

Kevin
Reply all
Reply to author
Forward
0 new messages