public LocalizedBundleWrapper(Bundle bundle, string virtualPath, CultureInfo culture, BundleLocalizer localizer)
     : base(virtualPath, bundle.TransformType)
 {
     _bundle = bundle;
     _culture = culture;
     _localizer = localizer;
 }
        public static void AddLocalizedBundles(this BundleCollection collection, Bundle bundle, BundleLocalizer bundleLocalizer, ResourceCultureProvider cultureProvider, string cultureInvariantVirtualPath = null)
        {
            if (!bundle.Path.Contains("{0}"))
            {
                throw new Exception("Bundle path must contain {0} as placeholder for culture string");
            }

            var cultures = cultureProvider.GetDefinedCultures();
            foreach (var culture in cultures)
            {
                var path = String.Format(bundle.Path, culture.Name);
                var localizedBundle = new LocalizedBundleWrapper(bundle, path, culture, bundleLocalizer);
                collection.Add(localizedBundle);

            }

            if (!string.IsNullOrEmpty(cultureInvariantVirtualPath))
            {
                var culture = cultureProvider.GetDefaultCulture();
                var cultureInvariantBundle = new LocalizedBundleWrapper(bundle, cultureInvariantVirtualPath, culture, bundleLocalizer);
                collection.Add(cultureInvariantBundle);
            }
        }
        public static void AddLocalizedBundles(this BundleCollection collection, Bundle bundle, BundleLocalizer bundleLocalizer, ResourceCultureProvider cultureProvider, string cultureInvariantVirtualPath = null)
        {
            if (!bundle.Path.Contains("{0}"))
            {
                throw new Exception("Bundle path must contain {0} as placeholder for culture string");
            }

            var cultures = cultureProvider.GetDefinedCultures();

            foreach (var culture in cultures)
            {
                var path            = String.Format(bundle.Path, culture.Name);
                var localizedBundle = new LocalizedBundleWrapper(bundle, path, culture, bundleLocalizer);
                collection.Add(localizedBundle);
            }

            if (!string.IsNullOrEmpty(cultureInvariantVirtualPath))
            {
                var culture = cultureProvider.GetDefaultCulture();
                var cultureInvariantBundle = new LocalizedBundleWrapper(bundle, cultureInvariantVirtualPath, culture, bundleLocalizer);
                collection.Add(cultureInvariantBundle);
            }
        }
示例#4
0
 public LocalizedBundleWrapper(Bundle bundle, string virtualPath, CultureInfo culture, BundleLocalizer localizer) : base(virtualPath, bundle.TransformType)
 {
     _bundle    = bundle;
     _culture   = culture;
     _localizer = localizer;
 }