【发布时间】:2013-02-01 06:19:28
【问题描述】:
背景
- 我正在构建一个多语言系统
- 我正在使用 MVC 4 捆绑功能
- 对于从右到左 (RTL) 和从左到右 (LTR) 语言,我有不同的
Javascripts和Styles文件
目前我处理这种情况如下:
BundleConfig 文件
//Styles for LTR
bundles.Add(new StyleBundle("~/Content/bootstarp").Include(
"~/Content/bootstrap.css",
"~/Content/CustomStyles.css"));
// Styles for RTL
bundles.Add(new StyleBundle("~/Content/bootstrapRTL").Include(
"~/Content/bootstrap-rtl.css",
"~/Content/CustomStyles.css"));
//Scripts for LTR
bundles.Add(new ScriptBundle("~/scripts/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/CmsCommon.js"
));
//Scripts for RTL
bundles.Add(new ScriptBundle("~/scripts/bootstrapRTL").Include(
"~/Scripts/bootstrap-rtl.js",
"~/Scripts/CmsCommon.js"
));
视图中的实现:
@if (this.Culture == "he-IL")
{
@Styles.Render("~/Content/bootstrapRTL")
}
else
{
@Styles.Render("~/Content/bootstrap")
}
问题:
我想知道是否有更好的方法来实现它,我希望:
处理检测哪种文化的逻辑并将正确的文件拉到包中(代码隐藏)而不是在视图中。
所以在视图中我要做的就是调用一个文件。
如果我将逻辑留在视图中,则意味着我必须在每个视图中处理它。我想避免它。
【问题讨论】:
-
顺便说一句,它的 bootstRAP 位 bootstARP ;)
-
您是否考虑过使用 html 助手?
-
你的意思是使用 HTML helper 来获取文件名?
-
但我想使用捆绑功能。还有一些我需要在捆绑减速中包含 bth 文件 LTR 和 RTL
标签: c# css asp.net-mvc bundle