var fs = require('fs'),\r
uglifyJS = require('uglify-js'),\r
_ = require('lodash'),\r
+ po2json = require('po2json'),\r
config = require('./../../../server/configuration.js');\r
\r
var FILE_ENCODING = 'utf-8',\r
__dirname + '/views/application.js',\r
__dirname + '/views/apptoolbar.js',\r
__dirname + '/views/controlbox.js',\r
+ __dirname + '/views/favicon.js',\r
__dirname + '/views/mediamessage.js',\r
__dirname + '/views/member.js',\r
__dirname + '/views/memberlist.js',\r
\r
\r
\r
+/**\r
+* Convert translations from .po to .json\r
+*/\r
+var translations = [];\r
+var translation_files = fs.readdirSync(__dirname + '/translations');\r
+if (!fs.existsSync(__dirname + '/../locales')) {\r
+ fs.mkdirSync(__dirname + '/../locales');\r
+}\r
+translation_files.forEach(function (file) {\r
+ var locale = file.slice(0, -3),\r
+ json = '',\r
+ languages = JSON.parse(fs.readFileSync(__dirname + '/translations/translations.json'));\r
+ if ((file.slice(-3) === '.po') && (locale !== 'template')) {\r
+ json = po2json.parseSync(__dirname + '/translations/' + file);\r
+ fs.writeFileSync(__dirname + '/../locales/' + locale + '.json', JSON.stringify(json));\r
+ translations.push({tag: locale, language: languages[locale]});\r
+ console.log('Built translation file %s', locale + '.json');\r
+ }\r
+});\r
+\r
+\r
\r
\r
\r
vars.client_plugins = config.get().client_plugins;\r
}\r
\r
+// Translations\r
+vars.translations = translations;\r
+\r
_.each(vars, function(value, key) {\r
if (typeof value === 'object') value = JSON.stringify(value);\r
index_src = index_src.replace(new RegExp('<%' + key + '%>', 'g'), value);\r
fs.writeFileSync(__dirname + '/../../index.html', index_src, FILE_ENCODING);\r
\r
\r
-console.log('index.html built');
\ No newline at end of file
+console.log('index.html built');\r