SfondoAdd lingua (LTR/RTL) meccanismo per bundle MVC 4
- Sto costruendo un sistema multilingue
- Sto usando MVC 4 fasci dispongono
- Ho diversi
Javascripts
eStyles
file per le lingue Right-To-Left (RTL) e Left-To-Right (LTR)
Attualmente gestisco questo scenario come segue:
BundleConfig file
//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"
));
Attuazione della vista:
@if (this.Culture == "he-IL")
{
@Styles.Render("~/Content/bootstrapRTL")
}
else
{
@Styles.Render("~/Content/bootstrap")
}
La domanda:
Mi chiedevo se esiste un modo migliore per attuarlo , speravo in:
Gestire la logica di rilevamento di quale cultura e tirare il file corretto nei pacchetti (Code behind) non nelle Visualizzazioni.
Quindi nelle visualizzazioni tutto ciò che dovrò fare è chiamare su un file.
Se sto lasciando la logica nelle viste, significa che dovrò gestirlo in ogni vista. Voglio evitarlo.
btw è' Bootstrap bit bootstARP;) – abatishchev
Avete considerato un aiutante html, invece? – abatishchev
Intendi usare l'helper HTML per ottenere il nome del file? – Silagy