From 651e92b85bb6c7e395748cf039a4ecbffa5e3105 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 9 May 2013 10:13:58 +0000 Subject: [PATCH] add localization to pandora --- .bzrignore | 3 +- pandora/app/config.py | 15 ++ pandora/config.0xdb.jsonc | 1 + pandora/config.indiancinema.jsonc | 1 + pandora/config.padma.jsonc | 1 + pandora/config.pandora.jsonc | 1 + static/js/pandora.js | 95 ++++--- static/js/pandora/account.js | 58 ++--- static/js/pandora/allItems.js | 12 +- static/js/pandora/annotationDialog.js | 12 +- static/js/pandora/apiDialog.js | 10 +- static/js/pandora/autovalidate.js | 10 +- static/js/pandora/backButton.js | 2 +- static/js/pandora/chunkupload.js | 2 +- static/js/pandora/clipsView.js | 9 +- static/js/pandora/contactForm.js | 36 +-- static/js/pandora/deleteFileDialog.js | 9 +- static/js/pandora/deleteItemDialog.js | 12 +- static/js/pandora/deleteListDialog.js | 9 +- static/js/pandora/embedError.js | 6 +- static/js/pandora/embedFileDialog.js | 6 +- static/js/pandora/embedPlayer.js | 6 +- static/js/pandora/embedVideoDialog.js | 6 +- static/js/pandora/errorDialog.js | 12 +- static/js/pandora/eventsDialog.js | 6 +- static/js/pandora/filesDialog.js | 59 +++-- static/js/pandora/filesView.js | 71 +++--- static/js/pandora/filter.js | 8 +- static/js/pandora/filterDialog.js | 6 +- static/js/pandora/filterForm.js | 3 +- static/js/pandora/findElement.js | 12 +- static/js/pandora/folderBrowserBar.js | 6 +- static/js/pandora/folderBrowserList.js | 16 +- static/js/pandora/folderList.js | 16 +- static/js/pandora/folders.js | 74 +++--- static/js/pandora/helpDialog.js | 12 +- static/js/pandora/home.0xdb.js | 22 +- static/js/pandora/home.indiancinema.js | 22 +- static/js/pandora/home.js | 22 +- static/js/pandora/home.padma.js | 18 +- static/js/pandora/homePage.js | 4 +- static/js/pandora/idDialog.js | 12 +- static/js/pandora/importAnnotations.js | 26 +- static/js/pandora/info.js | 13 +- static/js/pandora/infoView.0xdb.js | 20 +- static/js/pandora/infoView.indiancinema.js | 51 ++-- static/js/pandora/infoView.js | 8 +- static/js/pandora/infoView.padma.js | 4 +- static/js/pandora/insertEmbedDialog.js | 56 ++-- static/js/pandora/item.js | 6 +- static/js/pandora/list.js | 4 +- static/js/pandora/listDialog.js | 18 +- static/js/pandora/logsDialog.js | 24 +- static/js/pandora/mainMenu.js | 284 ++++++++++++--------- static/js/pandora/makeListPrivateDialog.js | 14 +- static/js/pandora/metadataDialog.js | 44 ++-- static/js/pandora/namesDialog.js | 18 +- static/js/pandora/navigationView.js | 4 +- static/js/pandora/news.js | 6 +- static/js/pandora/onloadDialog.js | 10 +- static/js/pandora/placesDialog.js | 6 +- static/js/pandora/preferencesDialog.js | 28 +- static/js/pandora/publicLists.js | 4 +- static/js/pandora/resetUIDialog.js | 10 +- static/js/pandora/sectionButtons.js | 4 +- static/js/pandora/sectionSelect.js | 4 +- static/js/pandora/sequencesDialog.js | 19 +- static/js/pandora/siteDialog.0xdb.js | 6 +- static/js/pandora/siteDialog.js | 6 +- static/js/pandora/sortElement.js | 10 +- static/js/pandora/sortMenu.js | 10 +- static/js/pandora/statisticsDialog.js | 14 +- static/js/pandora/statusbar.js | 6 +- static/js/pandora/textPanel.js | 22 +- static/js/pandora/titlesDialog.js | 14 +- static/js/pandora/toolbar.js | 2 +- static/js/pandora/tv.js | 6 +- static/js/pandora/uploadDialog.js | 57 ++--- static/js/pandora/uploadFileDialog.js | 31 +-- static/js/pandora/uploadPDFDialog.js | 6 +- static/js/pandora/usersDialog.js | 100 ++++---- static/js/pandora/utils.js | 70 ++--- static/js/pandora/viewSelect.js | 6 +- static/json/locale.pandora.ar.json | 2 + static/json/locale.pandora.de.json | 2 + 85 files changed, 929 insertions(+), 849 deletions(-) create mode 100644 static/json/locale.pandora.ar.json create mode 100644 static/json/locale.pandora.de.json diff --git a/.bzrignore b/.bzrignore index ae791dde3..f6fd6b56f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -9,7 +9,8 @@ local_settings.py config.jsonc ./local ./static/js/pandora.min.js.gz -./static/json/pandora.json.gz +./static/json/*.json.gz +./static/json/locale.??.json ./static/oxjs ./static/admin ./data diff --git a/pandora/app/config.py b/pandora/app/config.py index f414a5c54..81790c94f 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -7,6 +7,7 @@ import sys import shutil import time import thread +from glob import glob from django.conf import settings from django.contrib.auth.models import User @@ -192,6 +193,20 @@ def update_static(): shutil.copyfile(site, image) else: shutil.copyfile(pandora, image) + #locale + for f in sorted(glob(os.path.join(settings.STATIC_ROOT, 'json/locale.pandora.*.json'))): + with open(f) as fd: + locale = json.load(fd) + site_locale = f.replace('pandora', settings.CONFIG['site']['id']) + locale_file = f.replace('.pandora', '') + if os.path.exists(site_locale): + with open(f) as site_locale: + locale.update(json.load(fd)) + print 'write', locale_file + with open(locale_file, 'w') as fd: + json.dump(locale, fd) + os.system('gzip -9 -c "%s" > "%s.gz"' % (locale_file, locale_file)) + #download geo data update_geoip() diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index ea387ee14..41fe65d91 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -768,6 +768,7 @@ "listSort": [{"key": "director", "operator": "+"}], "listView": "grid", "lists": {}, + "locale": "en", "mapFind": "", "mapSelection": "", "page": "", diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index cf24631f2..3f499d527 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -805,6 +805,7 @@ "listSort": [{"key": "year", "operator": "+"}], "listView": "grid", "lists": {}, + "locale": "en", "mapFind": "", "mapSelection": "", "page": "", diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 6a9315dd8..36a954ead 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -686,6 +686,7 @@ "listSort": [{"key": "title", "operator": "+"}], "listView": "grid", "lists": {}, + "locale": "en", "mapFind": "", "mapSelection": "", "page": "", diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index 31a3d558d..0b623f70b 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -606,6 +606,7 @@ "listSort": [{"key": "title", "operator": "+"}], "listView": "grid", "lists": {}, + "locale": "en", "mapFind": "", "mapSelection": "", "page": "", diff --git a/static/js/pandora.js b/static/js/pandora.js index c1eb34137..8224a4725 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -310,56 +310,55 @@ appPanel }); // set up url controller - - pandora.URL.init().parse(function() { - - if (data.browserSupported) { - stopAnimation(); - $('#loadingScreen').remove(); - } else { - loadBrowserMessage(); - } - - Ox.Theme(pandora.user.ui.theme); - if (isEmbed) { - pandora.$ui.embedPanel = pandora.ui.embedPanel().display(); - Ox.$parent.onMessage({ - settheme: function(data) { - if (Ox.contains(pandora.site.themes, data.theme)) { - Ox.Theme(data.theme); - } - }, - seturl: function(data) { - if (pandora.isEmbedURL(data.url)) { - pandora.URL.push(data.url); - } - } - }); - } else if (isPrint) { - pandora.$ui.printView = pandora.ui.printView().display(); - } else { - pandora.$ui.appPanel = pandora.ui.appPanel().display(); - Ox.Request.requests() && pandora.$ui.loadingIcon.start(); - pandora.$ui.body.ajaxStart(pandora.$ui.loadingIcon.start); - pandora.$ui.body.ajaxStop(pandora.$ui.loadingIcon.stop); - Ox.Request.bindEvent({ - error: pandora.ui.errorDialog, - request: function(data) { - pandora.$ui.loadingIcon.options({ - tooltip: (data.requests || 'No') - + ' request' - + (data.requests == 1 ? '' : 's') - }); - } - }); - pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; - if (getLocalStorage('pandora.onload')) { - try { - eval(localStorage['pandora.onload']) - } catch(e) {} + pandora.setLocale(pandora.user.ui.locale, function() { + pandora.URL.init().parse(function() { + if (data.browserSupported) { + stopAnimation(); + $('#loadingScreen').remove(); + } else { + loadBrowserMessage(); } - } + Ox.Theme(pandora.user.ui.theme); + if (isEmbed) { + pandora.$ui.embedPanel = pandora.ui.embedPanel().display(); + Ox.$parent.onMessage({ + settheme: function(data) { + if (Ox.contains(pandora.site.themes, data.theme)) { + Ox.Theme(data.theme); + } + }, + seturl: function(data) { + if (pandora.isEmbedURL(data.url)) { + pandora.URL.push(data.url); + } + } + }); + } else if (isPrint) { + pandora.$ui.printView = pandora.ui.printView().display(); + } else { + pandora.$ui.appPanel = pandora.ui.appPanel().display(); + Ox.Request.requests() && pandora.$ui.loadingIcon.start(); + pandora.$ui.body.ajaxStart(pandora.$ui.loadingIcon.start); + pandora.$ui.body.ajaxStop(pandora.$ui.loadingIcon.stop); + Ox.Request.bindEvent({ + error: pandora.ui.errorDialog, + request: function(data) { + pandora.$ui.loadingIcon.options({ + tooltip: (data.requests || 'No') + + ' request' + + (data.requests == 1 ? '' : 's') + }); + } + }); + pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; + if (getLocalStorage('pandora.onload')) { + try { + eval(localStorage['pandora.onload']) + } catch(e) {} + } + } + }); }); } diff --git a/static/js/pandora/account.js b/static/js/pandora/account.js index 3e9b163c5..946b7ff74 100644 --- a/static/js/pandora/account.js +++ b/static/js/pandora/account.js @@ -40,22 +40,22 @@ pandora.ui.accountDialogOptions = function(action, value) { resetAndSignin: 'Sign In' }, dialogText = { - signin: 'To sign in to your account, please enter your username and password.', - signup: 'To sign up for an account, please choose a username and password, and enter your e-mail address.', - reset: 'To reset your password, please enter either your username or your e-mail address.', - resetAndSignin: 'To sign in to your account, please choose a new password, and enter the code that we have just e-mailed to you.' + signin: Ox._('To sign in to your account, please enter your username and password.'), + signup: Ox._('To sign up for an account, please choose a username and password, and enter your e-mail address.'), + reset: Ox._('To reset your password, please enter either your username or your e-mail address.'), + resetAndSignin: Ox._('To sign in to your account, please choose a new password, and enter the code that we have just e-mailed to you.') }, dialogTitle = { - signin: 'Sign In', - signup: 'Sign Up', - reset: 'Reset Password', - resetAndSignin: 'Reset Password' + signin: Ox._('Sign In'), + signup: Ox._('Sign Up'), + reset: Ox._('Reset Password'), + resetAndSignin: Ox._('Reset Password') }; function button(type) { if (type == 'cancel') { return Ox.Button({ id: 'cancel' + Ox.toTitleCase(action), - title: 'Cancel' + title: Ox._('Cancel') }).bindEvent({ click: function() { pandora.$ui.accountDialog.close(); @@ -66,7 +66,7 @@ pandora.ui.accountDialogOptions = function(action, value) { return Ox.Button({ disabled: true, id: 'submit' + Ox.toTitleCase(action), - title: buttonTitle[action] + title: Ox._(buttonTitle[action]) }).bindEvent({ click: function() { pandora.$ui.accountForm.submit(); @@ -75,7 +75,7 @@ pandora.ui.accountDialogOptions = function(action, value) { } else { return Ox.Button({ id: type, - title: buttonTitle[type] + '...' + title: Ox._(buttonTitle[type] + '...') }).bindEvent({ click: function() { if (['signin', 'signup'].indexOf(type) > -1 && type != pandora.user.ui.page) { @@ -151,7 +151,7 @@ pandora.ui.accountForm = function(action, value) { pandora.signin(result.data); } else { pandora.$ui.accountDialog.enableButtons(); - that.setMessages([{id: 'password', message: 'Incorrect password'}]); + that.setMessages([{id: 'password', message: Ox._('Incorrect password')}]); } }); } else if (action == 'signup') { @@ -176,7 +176,7 @@ pandora.ui.accountForm = function(action, value) { pandora.$ui.accountDialog.enableButtons(); } else { pandora.$ui.accountDialog.enableButtons(); - that.setMessages([{id: 'usernameOrEmail', message: 'Unknown ' + (key == 'username' ? 'username' : 'e-mail address')}]) + that.setMessages([{id: 'usernameOrEmail', message: Ox._('Unknown ' + (key == 'username' ? 'username' : 'e-mail address'))}]) } }); } else if (action == 'resetAndSignin') { @@ -186,7 +186,7 @@ pandora.ui.accountForm = function(action, value) { pandora.signin(result.data); } else { pandora.$ui.accountDialog.enableButtons(); - that.setMessages([{id: 'code', message: 'Incorrect code'}]); + that.setMessages([{id: 'code', message: Ox._('Incorrect code')}]); } }); } @@ -204,7 +204,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: pandora.autovalidateCode, id: 'code', - label: 'Code', + label: Ox._('Code'), labelWidth: 120, validate: pandora.validateCode, width: 320 @@ -213,7 +213,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: pandora.autovalidateEmail, id: 'email', - label: 'E-Mail Address', + label: Ox._('E-Mail Address'), labelWidth: 120, type: 'email', // fixme: ?? validate: pandora.validateUser('email'), @@ -223,7 +223,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: /.+/, id: 'password', - label: 'New Password', + label: Ox._('New Password'), labelWidth: 120, type: 'password', validate: pandora.validateNewPassword, @@ -233,7 +233,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: pandora.autovalidateUsername, id: 'username', - label: 'Username', + label: Ox._('Username'), labelWidth: 120, validate: pandora.validateUser('username'), width: 320 @@ -242,7 +242,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ disabled: true, id: 'username', - label: 'Username', + label: Ox._('Username'), labelWidth: 120, value: value, width: 320 @@ -251,7 +251,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: /.+/, id: 'password', - label: 'Password', + label: Ox._('Password'), labelWidth: 120, type: 'password', validate: pandora.validatePassword, @@ -261,7 +261,7 @@ pandora.ui.accountForm = function(action, value) { return Ox.Input({ autovalidate: pandora.autovalidateUsername, id: 'username', - label: 'Username', + label: Ox._('Username'), labelWidth: 120, validate: pandora.validateUser('username', true), width: 320 @@ -273,8 +273,8 @@ pandora.ui.accountForm = function(action, value) { pandora.$ui.usernameOrEmailSelect = Ox.Select({ id: 'usernameOrEmailSelect', items: [ - {id: 'username', title: 'Username'}, - {id: 'email', title: 'E-Mail Address'}, + {id: 'username', title: Ox._('Username')}, + {id: 'email', title: Ox._('E-Mail Address')}, ], overlap: 'right', width: 128 @@ -315,7 +315,7 @@ pandora.ui.accountSignoutDialog = function() { buttons: [ Ox.Button({ id: 'stay', - title: 'Stay Signed In' + title: Ox._('Stay Signed In') }).bindEvent({ click: function() { that.close(); @@ -324,7 +324,7 @@ pandora.ui.accountSignoutDialog = function() { }), Ox.Button({ id: 'signout', - title: 'Sign Out' + title: Ox._('Sign Out') }).bindEvent({ click: function() { that.close(); @@ -350,7 +350,7 @@ pandora.ui.accountSignoutDialog = function() { height: 128, keys: {enter: 'signout', escape: 'stay'}, removeOnClose: true, - title: 'Sign Out', + title: Ox._('Sign Out'), width: 304 }); return that; @@ -361,7 +361,7 @@ pandora.ui.accountWelcomeDialog = function() { buttons: [ Ox.Button({ id: 'preferences', - title: 'Preferences...' + title: Ox._('Preferences...') }).bindEvent('click', function() { that.close(); pandora.$ui.preferencesDialog = pandora.ui.preferencesDialog().open(); @@ -369,7 +369,7 @@ pandora.ui.accountWelcomeDialog = function() { {}, Ox.Button({ id: 'close', - title: 'Close' + title: Ox._('Close') }).bindEvent('click', function() { that.close(); }) @@ -392,7 +392,7 @@ pandora.ui.accountWelcomeDialog = function() { height: 128, keys: {enter: 'close', escape: 'close'}, removeOnClose: true, - title: 'Welcome to ' + pandora.site.site.name, + title: Ox._('Welcome to {0}', [pandora.site.site.name]), width: 304 }); return that; diff --git a/static/js/pandora/allItems.js b/static/js/pandora/allItems.js index 2ba11e013..85ae0c3ff 100644 --- a/static/js/pandora/allItems.js +++ b/static/js/pandora/allItems.js @@ -41,8 +41,8 @@ pandora.ui.allItems = function() { }) .html( pandora.user.ui.section == 'items' - ? 'All ' + pandora.site.itemName.plural - : pandora.site.site.name + ' ' + Ox.toTitleCase(pandora.user.ui.section) + ? Ox._('All {0}', [Ox._(pandora.site.itemName.plural)]) + : Ox._('{0} ' + Ox.toTitleCase(pandora.user.ui.section), [pandora.site.site.name]) ) .appendTo(that), $items; @@ -59,7 +59,7 @@ pandora.ui.allItems = function() { Ox.Button({ style: 'symbol', title: 'add', - tooltip: canAddItems ? 'Add ' + pandora.site.itemName.singular : '', + tooltip: canAddItems ? Ox._('Add {0}', [Ox._(pandora.site.itemName.singular)]) : '', type: 'image' }) .css({opacity: canAddItems ? 1 : 0.25}) @@ -70,7 +70,7 @@ pandora.ui.allItems = function() { Ox.Button({ style: 'symbol', title: 'upload', - tooltip: canUploadVideo ? 'Upload Video...' : '', + tooltip: canUploadVideo ? Ox._('Upload Video...') : '', type: 'image' }) .css({opacity: canUploadVideo ? 1 : 0.25}) @@ -89,14 +89,14 @@ pandora.ui.allItems = function() { Ox.Button({ style: 'symbol', title: 'file', - tooltip: 'HTML', + tooltip: Ox._('HTML'), type: 'image' }) .appendTo(that); Ox.Button({ style: 'symbol', title: 'help', - tooltip: 'Help', + tooltip: Ox._('Help'), type: 'image' }) .bindEvent({ diff --git a/static/js/pandora/annotationDialog.js b/static/js/pandora/annotationDialog.js index 339458bbf..5ac13b1c3 100644 --- a/static/js/pandora/annotationDialog.js +++ b/static/js/pandora/annotationDialog.js @@ -6,20 +6,20 @@ pandora.ui.annotationDialog = function(layer) { that = pandora.ui.iconDialog({ buttons: [].concat( isEditor ? [ - Ox.Button({title: 'Sign Up...'}).bindEvent({ + Ox.Button({title: Ox._('Sign Up...')}).bindEvent({ click: function() { that.close(); pandora.$ui.accountDialog = pandora.ui.accountDialog('signup').open(); } }), - Ox.Button({title: 'Sign In...'}).bindEvent({ + Ox.Button({title: Ox._('Sign In...')}).bindEvent({ click: function() { that.close(); pandora.$ui.accountDialog = pandora.ui.accountDialog('signin').open(); } }) ] : [ - Ox.Button({title: 'Switch to Editor'}).bindEvent({ + Ox.Button({title: Ox._('Switch to Editor')}).bindEvent({ click: function() { that.close(); pandora.UI.set({itemView: 'editor'}); @@ -28,17 +28,17 @@ pandora.ui.annotationDialog = function(layer) { ], [ {}, - Ox.Button({title: 'Not Now'}).bindEvent({ + Ox.Button({title: Ox._('Not Now')}).bindEvent({ click: function() { that.close(); } }) ] ), - text: 'To add or edit ' + layer + ', ' + ( + text: Ox._('To add or edit {0}, ' + ( isEditor ? 'please sign up or sign in.' - : 'just switch to the editor.' + : 'just switch to the editor.'), [layer] ), title: Ox.toTitleCase(layer) }); diff --git a/static/js/pandora/apiDialog.js b/static/js/pandora/apiDialog.js index b8aae0758..3ed62ddf7 100644 --- a/static/js/pandora/apiDialog.js +++ b/static/js/pandora/apiDialog.js @@ -13,7 +13,7 @@ pandora.ui.apiDialog = function() { buttons: [ Ox.Button({ id: 'switch', - title: 'Help...' + title: Ox._('Help...') }).bindEvent({ click: function() { pandora.UI.set({page: 'help', 'hash.anchor': ''}); @@ -22,7 +22,7 @@ pandora.ui.apiDialog = function() { {}, Ox.Button({ id: 'close', - title: 'Close' + title: Ox._('Close') }).bindEvent({ click: function() { that.close(); @@ -37,7 +37,7 @@ pandora.ui.apiDialog = function() { minHeight: 256, minWidth: 544 + Ox.UI.SCROLLBAR_SIZE, removeOnClose: true, - title: 'API Documentation', + title: Ox._('API Documentation'), width: 672 + Ox.UI.SCROLLBAR_SIZE }) .bindEvent({ @@ -55,7 +55,7 @@ pandora.ui.apiDialog = function() { pandora.api.api({docs: true, code: true}, function(results) { var items = [{ id: '', - title: 'API Documentation', + title: Ox._('API Documentation'), sort: 'aaa' }]; actions = results.data.actions; @@ -180,7 +180,7 @@ pandora.ui.apiDialog = function() { .appendTo($text); Ox.Button({ - title: 'Source (' + f + ')', + title: Ox._('Source ({0})', [f]), }).bindEvent({ click: function() { $code.toggle(); diff --git a/static/js/pandora/autovalidate.js b/static/js/pandora/autovalidate.js index b95b5029b..b42e45fe4 100644 --- a/static/js/pandora/autovalidate.js +++ b/static/js/pandora/autovalidate.js @@ -56,11 +56,11 @@ pandora.validateNewEmail = function(value, callback) { operator: '==' }, function(result) { callback({ - message: 'E-mail address already exists', + message: Ox._('E-mail address already exists'), valid: !result.data.users.length }); }) : callback({ - message: value.length ? 'Invalid e-mail address' : '', + message: value.length ? Ox._('Invalid e-mail address') : '', // message: (!value.length ? 'Missing' : 'Invalid') + ' e-mail address', valid: false }); @@ -97,12 +97,12 @@ pandora.validateUser = function(key, existing) { var valid = existing == !!result.data.users.length; callback({ message: existing ? - 'Unknown ' + string : - string[0].toUpperCase() + string.slice(1) + ' already exists', + Ox._('Unknown ' + string) : + Ox._(string[0].toUpperCase() + string.slice(1) + ' already exists'), valid: valid }); }) : callback({ - message: value.length ? 'Invalid ' + string : '', + message: value.length ? Ox._('Invalid ' + string) : '', // message: (!value.length ? 'Missing' : 'Invalid') + ' ' + string, valid: false }); diff --git a/static/js/pandora/backButton.js b/static/js/pandora/backButton.js index 8894aa076..868c06242 100644 --- a/static/js/pandora/backButton.js +++ b/static/js/pandora/backButton.js @@ -2,7 +2,7 @@ 'use strict'; pandora.ui.backButton = function() { var that = Ox.Button({ - title: 'Back to ' + pandora.site.itemName.plural, + title: Ox._('Back to {0}', [Ox._(pandora.site.itemName.plural)]), width: 96 }).css({ float: 'left', diff --git a/static/js/pandora/chunkupload.js b/static/js/pandora/chunkupload.js index cd886d5a5..87b8774be 100644 --- a/static/js/pandora/chunkupload.js +++ b/static/js/pandora/chunkupload.js @@ -122,7 +122,7 @@ pandora.chunkupload = function(options) { } else if(file.slice) { chunk = file.slice(chunkOffset, chunkOffset+chunkSize, file.type); } else { - that.status = 'Sorry, your browser is currently not supported.'; + that.status = Ox._('Sorry, your browser is currently not supported.'); done(); } diff --git a/static/js/pandora/clipsView.js b/static/js/pandora/clipsView.js index 0e0549b22..d7de8baa2 100644 --- a/static/js/pandora/clipsView.js +++ b/static/js/pandora/clipsView.js @@ -11,7 +11,7 @@ pandora.ui.clipsView = function(videoRatio) { fontSize: '9px', textAlign: 'center' }) - .html('Loading...'), + .html(Ox._('Loading...')), that = Ox.SplitPanel({ elements: [ @@ -23,14 +23,14 @@ pandora.ui.clipsView = function(videoRatio) { .append( Ox.Input({ clear: true, - placeholder: 'Find Clips', + placeholder: Ox._('Find Clips'), value: pandora.user.ui.itemFind, width: 192 }) .css({float: 'right', margin: '4px'}) .bindEvent({ submit: function(data) { - $status.html('Loading...'); + $status.html(Ox._('Loading...')); pandora.UI.set('itemFind', data.value); // since this is the only way itemFind can change, // there's no need for an event handler @@ -59,8 +59,7 @@ pandora.ui.clipsView = function(videoRatio) { init: function(data) { var items = data.items; $status.html( - (items ? Ox.formatNumber(items) : 'No') - + ' Clip' + (items == 1 ? '' : 's') + Ox.formatCount(items, 'Clip') ); } }); diff --git a/static/js/pandora/contactForm.js b/static/js/pandora/contactForm.js index bb91c0afe..a9b6c3e90 100644 --- a/static/js/pandora/contactForm.js +++ b/static/js/pandora/contactForm.js @@ -12,7 +12,7 @@ pandora.ui.contactForm = function() { items: [ Ox.Input({ id: 'name', - label: 'Your Name', + label: Ox._('Your Name'), labelWidth: 128, validate: function(value, callback) { callback({valid: true}); @@ -23,13 +23,13 @@ pandora.ui.contactForm = function() { Ox.Input({ autovalidate: pandora.autovalidateEmail, id: 'email', - label: 'Your E-Mail Address', + label: Ox._('Your E-Mail Address'), labelWidth: 128, validate: function(value, callback) { callback({ - message: 'Please enter ' + message: Ox._('Please enter ' + (value.length == 0 ? 'your' : 'a valid') - + ' e-mail address', + + ' e-mail address'), valid: Ox.isValidEmail(value) }); }, @@ -38,7 +38,7 @@ pandora.ui.contactForm = function() { }), Ox.Input({ id: 'subject', - label: 'Subject', + label: Ox._('Subject'), labelWidth: 128, validate: function(value, callback) { callback({valid: true}); @@ -54,7 +54,7 @@ pandora.ui.contactForm = function() { type: 'textarea', validate: function(value, callback) { callback({ - message: 'Please enter a message', + message: Ox._('Please enter a message'), valid: value.length > 0 }); }, @@ -73,7 +73,7 @@ pandora.ui.contactForm = function() { $receiptCheckbox = Ox.Checkbox({ id: 'receipt', - title: 'Send a receipt to ' + pandora.user.email, + title: Ox._('Send a receipt to {}', pandora.user.email), value: pandora.user.level != 'guest', width: width - 136 }) @@ -82,8 +82,8 @@ pandora.ui.contactForm = function() { change: function(data) { $receiptCheckbox.options({ title: data.value - ? 'Send a receipt to ' + pandora.user.email - : 'Don\'t send me a receipt' + ? Ox._('Send a receipt to {0}', [pandora.user.email]) + : Ox._('Don\'t send me a receipt') }); } }) @@ -91,7 +91,7 @@ pandora.ui.contactForm = function() { $sendButton = Ox.Button({ disabled: true, - title: 'Send Message', + title: Ox._('Send Message'), width: 128 }) .css({float: 'left', margin: '8px 0 8px ' + (pandora.user.level == 'guest' ? width - 128 : 4) + 'px'}) @@ -100,7 +100,7 @@ pandora.ui.contactForm = function() { var data = $form.values(); $sendButton.options({ disabled: true, - title: 'Sending Message...' + title: Ox._('Sending Message...') }); pandora.api.contact({ name: data.name, @@ -113,7 +113,7 @@ pandora.ui.contactForm = function() { buttons: [ Ox.Button({ id: 'close', - title: 'Close' + title: Ox._('Close') }).bindEvent({ click: function() { $dialog.close(); @@ -122,13 +122,13 @@ pandora.ui.contactForm = function() { }) ], keys: {enter: 'close', escape: 'close'}, - text: 'Thanks for your message!

We will get back to you as soon as possible.', - title: 'Message Sent' + text: Ox._('Thanks for your message!

We will get back to you as soon as possible.'), + title: Ox._('Message Sent') }) .open(); $sendButton.options({ disabled: false, - title: 'Send Message' + title: Ox._('Send Message') }); }); @@ -139,9 +139,9 @@ pandora.ui.contactForm = function() { $text = $('
') .css({width: width + 'px'}) .html( - ' Alternatively, you can contact us via ' - + pandora.site.site.email.contact + '' + ' ' + Ox._('Alternatively, you can contact us via {0}', + ['' + + pandora.site.site.email.contact + '']) ) .appendTo(that); diff --git a/static/js/pandora/deleteFileDialog.js b/static/js/pandora/deleteFileDialog.js index c7c0f7a8f..52cea9e92 100644 --- a/static/js/pandora/deleteFileDialog.js +++ b/static/js/pandora/deleteFileDialog.js @@ -7,7 +7,7 @@ pandora.ui.deleteFileDialog = function(file, callback) { buttons: [ Ox.Button({ id: 'keep', - title: 'Keep File' + title: Ox._('Keep File') }).bindEvent({ click: function() { that.close(); @@ -15,7 +15,7 @@ pandora.ui.deleteFileDialog = function(file, callback) { }), Ox.Button({ id: 'delete', - title: 'Delete File' + title: Ox._('Delete File') }).bindEvent({ click: function() { that.close(); @@ -26,9 +26,8 @@ pandora.ui.deleteFileDialog = function(file, callback) { }) ], keys: {enter: 'delete', escape: 'keep'}, - text: 'Are you sure you want to delete the file' - + ' "'+ file + '"?', - title: 'Delete File' + text: Ox._('Are you sure you want to delete the file "{0}"?', [file]), + title: Ox._('Delete File') }); return that; diff --git a/static/js/pandora/deleteItemDialog.js b/static/js/pandora/deleteItemDialog.js index 6845f786b..cf2d45951 100644 --- a/static/js/pandora/deleteItemDialog.js +++ b/static/js/pandora/deleteItemDialog.js @@ -7,7 +7,7 @@ pandora.ui.deleteItemDialog = function(item) { buttons: [ Ox.Button({ id: 'keep', - title: 'Keep ' + pandora.site.itemName.singular + title: Ox._('Keep {0}', [Ox._(pandora.site.itemName.singular)]) }).bindEvent({ click: function() { that.close(); @@ -15,7 +15,7 @@ pandora.ui.deleteItemDialog = function(item) { }), Ox.Button({ id: 'delete', - title: 'Delete ' + pandora.site.itemName.singular + title: Ox._('Delete {0}', [Ox._(pandora.site.itemName.singular)]) }).bindEvent({ click: function() { that.close(); @@ -29,10 +29,10 @@ pandora.ui.deleteItemDialog = function(item) { }) ], keys: {enter: 'delete', escape: 'keep'}, - text: 'Are you sure you want to delete the ' - + pandora.site.itemName.singular - + ' "'+ item.title + '"?

All data will be removed.', - title: 'Delete ' + pandora.site.itemName.singular + text: Ox._('Are you sure you want to delete the {0} "{1}"?' + + '

All data will be removed.', + [Ox._(pandora.site.itemName.singular), item.title]), + title: Ox._('Delete {0}', [Ox._(pandora.site.itemName.singular)]) }); return that; diff --git a/static/js/pandora/deleteListDialog.js b/static/js/pandora/deleteListDialog.js index 44c6fbba0..f5451989b 100644 --- a/static/js/pandora/deleteListDialog.js +++ b/static/js/pandora/deleteListDialog.js @@ -14,7 +14,7 @@ pandora.ui.deleteListDialog = function(list) { buttons: [ Ox.Button({ id: 'keep', - title: 'Keep ' + folderItem + title: Ox._('Keep {0}', [folderItem]) }).bindEvent({ click: function() { that.close(); @@ -22,7 +22,7 @@ pandora.ui.deleteListDialog = function(list) { }), Ox.Button({ id: 'delete', - title: 'Delete ' + folderItem + title: Ox._('Delete {0}', [folderItem]) }).bindEvent({ click: function() { that.close(); @@ -51,8 +51,9 @@ pandora.ui.deleteListDialog = function(list) { }) ], keys: {enter: 'delete', escape: 'keep'}, - text: 'Are you sure you want to delete the ' + folderItem.toLowerCase() + ' "' + listData.name + '"?', - title: 'Delete ' + folderItem + text: Ox._('Are you sure you want to delete the {0} "{1}"?', + [folderItem.toLowerCase(), listData.name]), + title: Ox._('Delete {0}', [folderItem]) }); return that; diff --git a/static/js/pandora/embedError.js b/static/js/pandora/embedError.js index 63c62cb29..a410ae9a6 100644 --- a/static/js/pandora/embedError.js +++ b/static/js/pandora/embedError.js @@ -34,12 +34,12 @@ pandora.ui.embedError = function(notImplemented) { .css({marginTop: '4px', fontSize: '9px', textAlign: 'center'}) .html( notImplemented - ? 'This view is not
implemented.' - : 'This view cannot
be embedded.' + ? Ox._('This view is not
implemented.') + : Ox._('This view cannot
be embedded.') ) ) .appendTo(that); return that; -}; \ No newline at end of file +}; diff --git a/static/js/pandora/embedFileDialog.js b/static/js/pandora/embedFileDialog.js index 7cff1d62b..ce4615942 100644 --- a/static/js/pandora/embedFileDialog.js +++ b/static/js/pandora/embedFileDialog.js @@ -10,7 +10,7 @@ pandora.ui.embedFileDialog = function(id) { $content = Ox.Element() .css({margin: '16px'}) .html( - 'To embed this file, use the following HTML:
' + Ox._('To embed this file, use the following HTML:
') ), $embed = $('