From b1089a631dfbf8332a5613c1537fe50a89f716dc Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Wed, 26 Mar 2014 23:45:09 +0900 Subject: [PATCH] - Refactoring supported languages. --- gulpfile.js | 59 ++++---------- res/app/settings/language/language-service.js | 4 + res/common/lang/index.js | 12 ++- res/common/lang/langs.json | 5 ++ res/common/lang/po/stf.ja.po | 4 +- res/common/lang/po/stf.pot | 77 +++++++++++++++++++ res/common/lang/translations/stf.es.json | 1 + res/common/lang/translations/stf.ja.json | 2 +- 8 files changed, 113 insertions(+), 51 deletions(-) create mode 100644 res/common/lang/langs.json create mode 100644 res/common/lang/translations/stf.es.json diff --git a/gulpfile.js b/gulpfile.js index 597e522e..cb27a659 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,7 +29,7 @@ gulp.task('jsonlint', function () { gulp.task('lint', ['jshint', 'jsonlint']) gulp.task('test', ['lint']) -gulp.task('build', ['webpack:build'], function () { +gulp.task('build', ['translate', 'webpack:build'], function () { }) // For production @@ -61,65 +61,34 @@ gulp.task('translate', ['jade', 'translate:extract', 'translate:compile'], function () { }) -gulp.task('jade', function () { - return gulp.src(['./res/**/*.jade', '!./res/bower_components/**']) +gulp.task('jade', function (callback) { + gulp.src(['./res/**/*.jade', '!./res/bower_components/**']) .pipe(jade()) .pipe(gulp.dest('./tmp/html/')) + + callback() }) -gulp.task('translate:extract', function () { - //'./res/**/*.js' - return gulp.src(['./tmp/html/**/*.html', +gulp.task('translate:extract', function (callback) { + gulp.src(['./tmp/html/**/*.html', './res/**/*.js', '!./res/bower_components/**']) .pipe(gettext.extract('stf.pot')) .pipe(gulp.dest('./res/common/lang/po/')) + + callback() }) -gulp.task('translate:compile', function () { - return gulp.src('./res/common/lang/po/**/*.po') +gulp.task('translate:compile', function (callback) { + gulp.src('./res/common/lang/po/**/*.po') .pipe(gettext.compile({ format: 'json' })) .pipe(gulp.dest('./res/common/lang/translations/')) + + callback() }) 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 -//grunt.initConfig({ -// jade: { -// translate: { -// options: { -// data: { -// debug: false, -// files: { -// 'tmp/html/all.html': ['res/app/**/*.jade'] -// -// } -// } -// } -// } -// }, -// -// 'nggettext_extract': { -// pot: { -// files: { -// 'res/lang/po/template.pot': ['tmp/html/all.html', 'res/app/**/*.js'] -// } -// } -// }, -// -// 'nggettext_compile': { -// all: { -// files: { -// 'res/lang/translations.js': ['res/lang/po/*.po'] -// } -// } -// } -//}) +}) diff --git a/res/app/settings/language/language-service.js b/res/app/settings/language/language-service.js index 5bc0a27a..6bb4f188 100644 --- a/res/app/settings/language/language-service.js +++ b/res/app/settings/language/language-service.js @@ -1,5 +1,9 @@ var _ = require('lodash') +// TODO: Implement this +var supportedLanguages = require('./../../../common/lang/langs.json') + + module.exports = function LanguageServiceFactory( SettingsService , $q diff --git a/res/common/lang/index.js b/res/common/lang/index.js index 0666bbe0..b32695c3 100644 --- a/res/common/lang/index.js +++ b/res/common/lang/index.js @@ -1,7 +1,13 @@ -angular.module("gettext").run(['gettextCatalog', function (gettextCatalog) { - gettextCatalog.setStrings('ja', require('./translations/stf.ja.json').ja ) +angular.module('gettext').run(['gettextCatalog', function (gettextCatalog) { + // Load all supported languages + angular.forEach(require('./langs'), function (value, key) { + if (key !== 'en') { + gettextCatalog.setStrings(key, + require('./translations/stf.' + key + '.json')[key]) + } + }) }]) module.exports = angular.module('stf/lang', [ 'gettext' -]) +]) \ No newline at end of file diff --git a/res/common/lang/langs.json b/res/common/lang/langs.json new file mode 100644 index 00000000..80ec967f --- /dev/null +++ b/res/common/lang/langs.json @@ -0,0 +1,5 @@ +{ + "en": "English", + "es": "Espaniol", + "ja": "日本語" +} \ No newline at end of file diff --git a/res/common/lang/po/stf.ja.po b/res/common/lang/po/stf.ja.po index 903dba66..0a8f1c17 100644 --- a/res/common/lang/po/stf.ja.po +++ b/res/common/lang/po/stf.ja.po @@ -14,7 +14,7 @@ msgstr "" #: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html msgid "Carrier" -msgstr "" +msgstr "キャリア" #: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/clear-button/clear-button.html msgid "Clear" @@ -51,7 +51,7 @@ msgstr "" #: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html msgid "Help" -msgstr "" +msgstr "ヘルプ" #: /Users/a12907/STF/stf/tmp/html/app/settings/language/language.html msgid "Language" diff --git a/res/common/lang/po/stf.pot b/res/common/lang/po/stf.pot index 746621cd..1270a98e 100644 --- a/res/common/lang/po/stf.pot +++ b/res/common/lang/po/stf.pot @@ -7,6 +7,18 @@ msgstr "" msgid "" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Absent" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Available" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Busy" +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html msgid "Carrier" msgstr "" @@ -15,6 +27,14 @@ msgstr "" msgid "Clear" msgstr "" +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Connected successfully." +msgstr "" + +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Connecting..." +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html msgid "Control" msgstr "" @@ -32,10 +52,26 @@ msgstr "" msgid "Devices" msgstr "" +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Disconnected.
Socket connection was lost, try again reloading the page." +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/settings/notifications/notifications.html msgid "Enable notifications" msgstr "" +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Error while connecting." +msgstr "" + +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Error while reconnecting." +msgstr "" + +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Error." +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/settings/settings.html msgid "Example: 3000" msgstr "" @@ -64,6 +100,10 @@ msgstr "" msgid "Model" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "N/A" +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html msgid "Native" msgstr "" @@ -80,10 +120,34 @@ msgstr "" msgid "OS" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Offline" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Preparing" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Present" +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html msgid "Product" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Ready" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Reconnected successfully." +msgstr "" + +#: /Users/a12907/STF/stf/res/app/components/stf/socket/socket-state/socket-state-directive.js +msgid "Reconnecting..." +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/refresh-page/refresh-page.html msgid "Refresh" msgstr "" @@ -136,7 +200,16 @@ msgstr "" msgid "Target host (detect if blank)" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Unauthorized" +msgstr "" + +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Unknown" +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js msgid "Use" msgstr "" @@ -144,6 +217,10 @@ msgstr "" msgid "User" msgstr "" +#: /Users/a12907/STF/stf/res/app/device-list/device-list-controller.js +msgid "Using" +msgstr "" + #: /Users/a12907/STF/stf/tmp/html/app/menu/menu.html msgid "Web" msgstr "" diff --git a/res/common/lang/translations/stf.es.json b/res/common/lang/translations/stf.es.json new file mode 100644 index 00000000..21efc3a2 --- /dev/null +++ b/res/common/lang/translations/stf.es.json @@ -0,0 +1 @@ +{"es":{"Carrier":"Correa","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/res/common/lang/translations/stf.ja.json b/res/common/lang/translations/stf.ja.json index a391d2d0..e34cbf07 100644 --- a/res/common/lang/translations/stf.ja.json +++ b/res/common/lang/translations/stf.ja.json @@ -1 +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 +{"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