[英]Razor Template C# Exception thrown: 'RazorEngine.Templating.TemplateCompilationException' in RazorEngine.dll
[英]C# / Razor - Access localized string resources from a RazorEngine template
我正在使用RazorEngine填充CSHTML模板來構建動態HTML電子郵件。 我需要發送多種語言的電子郵件,我想在我的模板中使用本地化的字符串資源來切換語言,如下所示:
@Resources.EmailTemplate.OrderNumberLabel
如何指定RazorEngine使用的培養物? 在拉入字符串時,它似乎總是使用默認文化。 我嘗試在解析之前設置線程文化而沒有運氣:
System.Threading.Thread.CurrentThread.CurrentCulture System.Globalization.CultureInfo.CreateSpecificCulture(culture);
注意:我已經看到其他實現為每種語言使用了不同的CSHTML文件,但我想保持本地化內容和標記分開。
您需要設置Thread.CurrentThread.CurrentUICulture
屬性,而不是CurrentCulture
屬性,或者除了CurrentCulture
屬性之外。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.