Background
- I am creating a multilingual system.
- I use the MVC 4 packages feature
- I have a different files
Javascriptsand Stylesfor languages Right-To-Left (RTL) and Left-To-Right (LTR)
I am currently processing this script as follows:
BundleConfig File
bundles.Add(new StyleBundle("~/Content/bootstarp").Include(
"~/Content/bootstrap.css",
"~/Content/CustomStyles.css"));
bundles.Add(new StyleBundle("~/Content/bootstrapRTL").Include(
"~/Content/bootstrap-rtl.css",
"~/Content/CustomStyles.css"));
bundles.Add(new ScriptBundle("~/scripts/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/CmsCommon.js"
));
bundles.Add(new ScriptBundle("~/scripts/bootstrapRTL").Include(
"~/Scripts/bootstrap-rtl.js",
"~/Scripts/CmsCommon.js"
));
Implementation in views:
@if (this.Culture == "he-IL")
{
@Styles.Render("~/Content/bootstrapRTL")
}
else
{
@Styles.Render("~/Content/bootstrap")
}
Question:
I was wondering if there is a better way to implement it, I was hoping:
Process the culture detection logic and pull out the desired file in bundles (code behind), not in views.
So, in the views that I need to do, I need to call one file.
If I leave the logic in the views, it means that I have to process it in each view. I want to avoid this.
source
share