Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Localization for moment.js
  • Loading branch information
andrewdavey committed Dec 18, 2012
1 parent a921df3 commit cc8c777
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions App/CassetteConfiguration.cs
Expand Up @@ -34,6 +34,12 @@ public void Configure(BundleCollection bundles)
bundles.Add<ScriptBundle>("ClientSpecs");
}

InitRequireJsModules();
}

void InitRequireJsModules()
{
// Convert basic bundles into AMD modules for use with require.js.
bundles.InitializeRequireJsModules("Client/Vendor/require.js", amd =>
{
amd.SetImportAlias("Client/Vendor/jquery.js", "$");
Expand All @@ -48,22 +54,13 @@ public void Configure(BundleCollection bundles)
module.ModulePath += "-template";
}
}
/*
b => amdModuleCollection.AddVendorModulesPerAsset(b, config =>
{
config("moment.js").Identifier("moment");// TODO: Un-hack the define() call in moment.js!
config("jquery.history.js").Identifier("History").Shim("History").DependsOn("Client/Vendor/jquery");
config("bootstrap.js").Identifier("bootstrap").Shim().DependsOn("Client/Vendor/jquery");
config("datepicker.js").Identifier("datepicker").Shim().DependsOn("Client/Vendor/jquery");
}
*/
});
}

void AddSharedBundle()
{
AddBundle("Shared");
AddBundle("lang");
}

void AddPageBundles()
Expand Down
4 changes: 2 additions & 2 deletions App/Infrastructure/Web/HtmlFormatter.cs
Expand Up @@ -56,12 +56,12 @@ async Task WritePageToStreamAsync(Stream writeStream, Page page)
using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var reader = new StreamReader(file))
{
var scripts = RequireJs.RenderScripts(page.InitializationModule).ToHtmlString();
var langModule = "Client/lang/" + page.Language + "/moment";
var scripts = RequireJs.RenderScripts(page.InitializationModule, langModule).ToHtmlString();
Bundles.Reference<StylesheetBundle>("Client/Vendor");
var styles = Bundles.RenderStylesheets().ToHtmlString();

var html = await reader.ReadToEndAsync();
html = html.Replace("$lang$", page.Language);
html = html.Replace("$styles$", styles);
html = html.Replace("$scripts$", scripts);

Expand Down

0 comments on commit cc8c777

Please sign in to comment.