-
-
Save steelx/d9ce68c7894719088f47cb4e91b47d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
// Specify the locales you are interested here. | |
var locales = ['en', 'fr']; | |
var i; | |
var localesData = Object.create(null); | |
var prefix = 'data:text/javascript;base64,'; | |
var outputPrefix = "angular.module('tmh.dynamicLocalePreload', ['tmh.dynamicLocale'])" + | |
".config(['tmhDynamicLocaleProvider', function(tmhDynamicLocaleProvider) {" + | |
"tmhDynamicLocaleProvider.localeLocationPattern('{{base64Locales[locale]}}');" + | |
"tmhDynamicLocaleProvider.addLocalePatternValue('base64Locales', " | |
var outputSuffix = ");" + | |
"}]);"; | |
// Read all the locales and base64 encode them. | |
for (i = 0; i < locales.length; ++i) { | |
localesData[locales[i]] = prefix + base64( | |
fs.readFileSync('../node_modules/angular-i18n/angular-locale_' + locales[i] + '.js', 'utf8')); | |
} | |
console.log(outputPrefix); | |
console.log(JSON.stringify(localesData)); | |
console.log(outputSuffix); | |
function base64(content) { | |
return new Buffer(content).toString('base64'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment