Closed hognevevle closed 7 years ago
Yes, I'm using i18n with bundles in an ASP.NET MVC 4 website and it works. Here's my bundle config if it helps:
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/lynx_early").Include(
"~/Scripts/modernizr-*"
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
));
bundles.Add(new ScriptBundle("~/bundles/lynx_late").Include(
"~/Scripts/q.js",
"~/Scripts/jquery/jquery-{version}.js",
"~/Scripts/jquery/jquery.unobtrusive*",
//LX125 "~/Scripts/jquery/jquery.validate.js",
//LX125 "~/Scripts/jquery/jquery.validate.unobtrusive.js",
//LX125 "~/Scripts/jquery/jquery.validate.hooks.js",
"~/Scripts/jquery/jquery.datetimepicker.js",
"~/Scripts/moment/moment.js",
"~/Scripts/mysite/mysite.general.js"
));
bundles.Add(new StyleBundle("~/Content/styles").Include(
"~/Scripts/jquery/jquery.datetimepicker.css"
));
// Enable optimization in Release build.
// NB: the <system.web><compilation debug=""> setting is suposed to enable/disable
// optimizations automatically. However, that doesn't seem to work. It might be
// because we removed the 'debug' attribute completely for Release build, rather
// than set it to false as stated is required (http://www.asp.net/mvc/overview/performance/bundling-and-minification).
#if !DEBUG
BundleTable.EnableOptimizations = true;
#endif
}
Nuggets in mysite.general.js are getting translated okay.
Url for the bundle comes out as:
https://mysite.com/fr-CA/bundles/lynx_late?v=bgjE-WVWJLPLbdLZ-bZdQktfPte7ktLHeDBmgvY5iz01
I'm a bit suspicious of your URL rewrite.
Thank you for confirming and sharing your config.
The rewrite magic was most likely to blame, indeed. We solved it by removing our subdirectory ("myapp/") from all routes in our application, and then added a new application inside the IIS site, using "myapp" as alias. This eliminated the need for any rewrites, and both i18n and the bundles are now working as intended. :)
Hi,
are bundles currently supported by i18n?
We are having some difficulties making it work.
In BundleConfig.cs we set the following property to correctly generate the URLs:
Scripts.DefaultTagFormat = "<script src='/myapp{0}'></script>";
Additionally, we have a rewrite in Web.config to remove the /myapp part when requesting the URLs (as the prefixed URL isn't being recognized when requesting a bundle resource). `
However, as long as i18n is enabled, the bundle URLs give 404. By adding "(^\/bundles\/)|(^\/myapp\/bundles\/)" to the i18n.UrlLocalizer.QuickUrlExclusionFilter, the bundle loads without a problem, but this causes i18n to fall back to i18n.LocalizedApplication.Current.DefaultLanguage, which we do not want.
Is there anything else that needs to be done configuration-wise in order to use bundles with i18n, or something we're missing?
Please let me know if I can provide any additional details.