3

I'm building dynamic HTML emails by using RazorEngine to populate a CSHTML template. I need to send emails in multiple languages, and I'd like to use localized string resources within my template to switch languages, like so:

@Resources.EmailTemplate.OrderNumberLabel

How can I specify the culture used by RazorEngine? It always appears to use the default culture when pulling in strings. I've tried setting the thread culture before parsing with no luck:

System.Threading.Thread.CurrentThread.CurrentCulture System.Globalization.CultureInfo.CreateSpecificCulture(culture);

Note: I've seen other implementations that have used a different CSHTML file for each language, but I'd like to keep the localized content and the markup separated.

4

2 回答 2

6

您需要设置该Thread.CurrentThread.CurrentUICulture属性来代替或附加该CurrentCulture属性。

于 2014-03-06T21:25:53.467 回答
1

请在此处查看本地化模板服务 http://netmvc.blogspot.ca/2012/04/localizable-text-template-engine-using.html

于 2014-03-06T21:03:29.567 回答