I just read the new blog post: http://blog.stackexchange.com/2015/07/announcing-stackexchange-precompilation/ (which is awesome)

This sentence interests me:

We do a lot of meta-programming to bake translations into our views at (pre-)compile-time (as opposed to doing a lookup for each string at run-time).

This sounds like a great solution, how does this work within StackExchange?


If you're interested in that topic, here are some great articles by Matt Jibbson (he was in charge of localizing careers long before we ever localized the Q&A sites):

So what we do in core is basically take the _s and _m syntax and generate a per-culture switch statement and pluralization rules that inline the translations to minimize the run-time overhead:

generated code

We do that for both .cshtml views as well as .cs files. We also detect when the s&m calls (we really do love pain at SE) happen inside a view's Write method, so we can use that instead of string concatenation:

view optimization

Of course we also use the semantic model to verify the properties used etc. As you've probably noticed from the screenshot above, we've extended the original careers syntax to support pluralization by multiple variables in a single string, so we can spare you some giant S injuries.

I'me also planing on writing about more about some of the caveats of rewriting code with roslyn, but that's the only post I've managed to write till now:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .