diff --git a/.gitignore b/.gitignore index a4d8e1a3..791b18df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ /.env /tmp .idea/ -.DS_Store \ No newline at end of file +.DS_Store +*.mo +/res/build/* \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index d1822b88..597e522e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,20 +1,26 @@ var gulp = require('gulp') +var gutil = require('gulp-util') var jshint = require('gulp-jshint') var jsonlint = require('gulp-jsonlint') +var webpack = require('webpack') +var webpackConfig = require('./webpack.config.js') +var gettext = require('gulp-angular-gettext') +var jade = require('gulp-jade') +var clean = require('gulp-clean') -gulp.task('jshint', function() { +gulp.task('jshint', function () { return gulp.src([ - 'lib/**/*.js' + 'lib/**/*.js' , 'res/app/**/*.js' , 'res/auth-ldap/**/*.js' , 'res/auth-mock/**/*.js' , '*.js' - ]) + ]) .pipe(jshint()) .pipe(jshint.reporter('jshint-stylish')) }) -gulp.task('jsonlint', function() { +gulp.task('jsonlint', function () { return gulp.src(['.jshintrc', '.bowerrc', '.yo-rc.json', '*.json']) .pipe(jsonlint()) .pipe(jsonlint.reporter()) @@ -23,6 +29,66 @@ gulp.task('jsonlint', function() { gulp.task('lint', ['jshint', 'jsonlint']) gulp.task('test', ['lint']) +gulp.task('build', ['webpack:build'], function () { +}) + +// For production +gulp.task("webpack:build", function (callback) { + var myConfig = Object.create(webpackConfig) + myConfig.plugins = myConfig.plugins.concat( + new webpack.DefinePlugin({ + "process.env": { + "NODE_ENV": JSON.stringify('production') + } + }), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.UglifyJsPlugin() + ) + + webpack(myConfig, function (err, stats) { + if (err) { + throw new gutil.PluginError('webpack:build', err) + } + + gutil.log("[webpack:build]", stats.toString({ + colors: true + })) + callback() + }) +}) + +gulp.task('translate', ['jade', 'translate:extract', 'translate:compile'], + function () { + }) + +gulp.task('jade', function () { + return gulp.src(['./res/**/*.jade', '!./res/bower_components/**']) + .pipe(jade()) + .pipe(gulp.dest('./tmp/html/')) +}) + +gulp.task('translate:extract', function () { + //'./res/**/*.js' + return gulp.src(['./tmp/html/**/*.html', + '!./res/bower_components/**']) + .pipe(gettext.extract('stf.pot')) + .pipe(gulp.dest('./res/common/lang/po/')) +}) + +gulp.task('translate:compile', function () { + return gulp.src('./res/common/lang/po/**/*.po') + .pipe(gettext.compile({ + format: 'json' + })) + .pipe(gulp.dest('./res/common/lang/translations/')) +}) + +gulp.task('clean', function () { + gulp.src('./tmp', {read: false}) + .pipe(clean()) +}); + + // TODO: convert this to gulp // 1. extract task: jade->html+js->pot // 2. compile task: po->js diff --git a/lib/middleware/webpack.js b/lib/middleware/webpack.js index 30dda3bc..7f7a7352 100644 --- a/lib/middleware/webpack.js +++ b/lib/middleware/webpack.js @@ -5,8 +5,8 @@ var _ = require('lodash') var webpackOptions = require('../../webpack.config.js') var overrideOptions = { - debug: true, - devtool: 'eval' + debug: false, +// devtool: 'eval' } var finalOptions = _.assign(webpackOptions, overrideOptions) diff --git a/res/app/app.js b/res/app/app.js index 97825f04..ec84e8f8 100644 --- a/res/app/app.js +++ b/res/app/app.js @@ -15,7 +15,8 @@ angular.module('app', [ require('./control-panes').name, require('./menu').name, require('./settings').name, - require('./help').name + require('./help').name, + require('./../common/lang').name ]) .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { diff --git a/res/common/lang/index.js b/res/common/lang/index.js new file mode 100644 index 00000000..0666bbe0 --- /dev/null +++ b/res/common/lang/index.js @@ -0,0 +1,7 @@ +angular.module("gettext").run(['gettextCatalog', function (gettextCatalog) { + gettextCatalog.setStrings('ja', require('./translations/stf.ja.json').ja ) +}]) + +module.exports = angular.module('stf/lang', [ + 'gettext' +]) diff --git a/res/common/lang/po/stf.ja.po b/res/common/lang/po/stf.ja.po new file mode 100644 index 00000000..903dba66 --- /dev/null +++ b/res/common/lang/po/stf.ja.po @@ -0,0 +1,154 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Gunther Brunner \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.6.4\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Language: ja\n" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Carrier" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/clear-button/clear-button.html +msgid "Clear" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Control" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Details" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Device Port" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Devices" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/notifications/notifications.html +msgid "Enable notifications" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Example: 3000" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/filter-button/filter-button.html +msgid "Filter" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Help" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/language/language.html +msgid "Language" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Local Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Location" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Model" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Native" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "No devices connected" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/notifications/notifications.html +msgid "Notifications" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "OS" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Product" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/refresh-page/refresh-page.html +msgid "Refresh" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Release Date" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Reset Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Saved to: {{savedTo}}" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Screen" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/control-panes/shell/shell.html +msgid "Shell" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Start Using" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Status" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Stop Using" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target IP / Hostname" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target Port" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target host (detect if blank)" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Use" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "User" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Web" +msgstr "" diff --git a/res/common/lang/po/stf.pot b/res/common/lang/po/stf.pot new file mode 100644 index 00000000..746621cd --- /dev/null +++ b/res/common/lang/po/stf.pot @@ -0,0 +1,149 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Carrier" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/clear-button/clear-button.html +msgid "Clear" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Control" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Details" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Device Port" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Devices" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/notifications/notifications.html +msgid "Enable notifications" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Example: 3000" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/filter-button/filter-button.html +msgid "Filter" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Help" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/language/language.html +msgid "Language" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Local Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Location" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Model" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Native" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "No devices connected" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/notifications/notifications.html +msgid "Notifications" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "OS" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Product" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/refresh-page/refresh-page.html +msgid "Refresh" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Release Date" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Reset Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/local/local-settings.html +msgid "Saved to: {{savedTo}}" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Screen" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Settings" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/control-panes/shell/shell.html +msgid "Shell" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Start Using" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Status" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Stop Using" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target IP / Hostname" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target Port" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html +msgid "Target host (detect if blank)" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "Use" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +msgid "User" +msgstr "" + +#: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html +msgid "Web" +msgstr "" diff --git a/res/common/lang/translations/stf.ja.json b/res/common/lang/translations/stf.ja.json new file mode 100644 index 00000000..a391d2d0 --- /dev/null +++ b/res/common/lang/translations/stf.ja.json @@ -0,0 +1 @@ +{"ja":{"Carrier":"","Clear":"","Control":"","Details":"","Device Port":"","Devices":"","Enable notifications":"","Example: 3000":"","Filter":"","Help":"","Language":"","Local Settings":"","Location":"","Model":"","Native":"","No devices connected":"","Notifications":"","OS":"","Product":"","Refresh":"","Release Date":"","Reset Settings":"","Saved to: {{savedTo}}":"","Screen":"","Settings":"","Shell":"","Start Using":"","Status":"","Stop Using":"","Target IP / Hostname":"","Target Port":"","Target host (detect if blank)":"","Use":"","User":"","Web":""}} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index d5392e6c..782def44 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,6 +30,7 @@ module.exports = { , module: { loaders: [ { test: /\.css$/, loader: 'style!css' } + , { test: /\.json$/, loader: 'json' } , { test: /\.jpg$/, loader: "url-loader?limit=5000&mimetype=image/jpeg" } , { test: /\.png$/, loader: "url-loader?limit=5000&mimetype=image/png" } , { test: /\.gif$/, loader: "url-loader?limit=5000&mimetype=image/gif" }