Commit 0373ae6b authored by Stavros Sachtouris's avatar Stavros Sachtouris Committed by Giorgos Korfiatis
Browse files

Create localized common labels, adjust GUI

GUI parts adjusted: menu, settings.
Greek is not used yet.
parent cd6409c3
......@@ -222,7 +222,7 @@ class AgkyraCLI(cmd.Cmd):
client = self.client
status, msg = client.get_status() if client else None, 'Not running'
if status:
msg = NOTIFICATION[status['code']]
msg = NOTIFICATION[str(status['code'])]
diff = remaining(status)
if diff:
msg = '%s, %s remaining' % (msg, diff)
......
......@@ -27,6 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<script src="static/js/jquery.js"></script>
<script type="text/javascript">
var NOTIFICATION = COMMON.NOTIFICATION;
var MENU = COMMON.MENU;
// Setup GUI
var windows = {
"settings": null,
......@@ -39,7 +42,7 @@ function closeWindows() {
// GUI components
var tray = new gui.Tray({
tooltip: 'Agkyra Syncing Client',
tooltip: MENU.TITLE,
icon: 'static/images/tray.png',
iconsAreTemplates: false
});
......@@ -47,9 +50,6 @@ var tray = new gui.Tray({
var menu = new gui.Menu();
// Progress and Pause
var start_syncing = 'Start Syncing';
var pause_syncing = 'Pause Syncing';
var paused = true;
progress_item = new gui.MenuItem({
// progress menu item
......@@ -63,7 +63,7 @@ pause_item = new gui.MenuItem({
// pause menu item
icon: 'static/images/play_pause.png',
iconIsTemplate: false,
label: 'NOT READY',
label: MENU.INITIALIZING,
type: 'normal',
click: function() {
if (globals.status.code == STATUS['PAUSED']) post_start(socket);
......@@ -76,7 +76,7 @@ menu.append(pause_item);
// Menu actions contents
var local_folder_menu = new gui.MenuItem({
label: 'Open local folder',
label: MENU.FOLDER,
icon: 'static/images/folder.png',
iconIsTemplate: false,
enabled: false,
......@@ -89,7 +89,7 @@ var local_folder_menu = new gui.MenuItem({
menu.append(local_folder_menu);
var pithos_page_menu = new gui.MenuItem({
label: 'Launch Pithos+ page',
label: MENU.PITHOS,
icon: 'static/images/pithos.png',
iconIsTemplate: false,
enabled: false,
......@@ -103,7 +103,7 @@ menu.append(pithos_page_menu);
// Settings and About
menu.append(new gui.MenuItem({type: 'separator'}));
var settings_menu = new gui.MenuItem({
label: 'Settings',
label: MENU.SETTINGS,
icon: 'static/images/settings.png',
iconIsTemplate: false,
enabled: false,
......@@ -139,7 +139,7 @@ var settings_menu = new gui.MenuItem({
menu.append(settings_menu);
menu.append(new gui.MenuItem({
label: 'About',
label: MENU.ABOUT,
icon: 'static/images/about.png',
iconIsTemplate: false,
click: function () {
......@@ -154,7 +154,7 @@ menu.append(new gui.MenuItem({
// Quit
menu.append(new gui.MenuItem({type: 'separator'}));
menu.append(new gui.MenuItem({
label: 'Quit Agkyra',
label: MENU.QUIT,
icon: 'static/images/exit.png',
iconIsTemplate: false,
click: function() {post_shutdown(socket);}
......@@ -208,26 +208,29 @@ window.setInterval(function() {
case STATUS['SHUTING DOWN']:
notify('info');
deactivate_menu();
new_pause = 'inactive';
new_pause = MENU.INACTIVE;
break;
case STATUS['SYNCING']:
notify('info');
activate_menu();
new_progress += ', ' + remaining(globals.status) + ' remaining';
new_pause = 'Pause';
new_progress += ', '
+ MENU.REMAINING.replace('%s', remaining(globals.status));
new_pause = MENU.PAUSE;
break;
case STATUS['PAUSING']:
notify('info');
new_progress += ', ' + remaining(globals.status) + ' remaining';
new_pause = 'waiting...';
new_progress += ', '
+ MENU.REMAINING.replace('%s', remaining(globals.status));
new_pause = MENU.WAITING;
pause_item.enabled = false;
break;
case STATUS['PAUSED']:
notify('info');
activate_menu();
new_pause = 'Start syncing';
new_pause = MENU.START;
if (remaining(globals.status) > 0)
new_progress += ', ' + remaining(globals.status) + ' remaining';
new_progress += ', '
+ MENU.REMAINING.replace('%s', remaining(globals.status));
break;
case STATUS['SETTINGS MISSING']:
case STATUS['AUTH URL ERROR']:
......@@ -235,7 +238,7 @@ window.setInterval(function() {
case STATUS['DIRECTORY ERROR']:
case STATUS['CONTAINER ERROR']:
deactivate_menu();
new_pause = 'inactive';
new_pause = MENU.INACTIVE;
settings_menu.enabled = true;
notify('error');
break;
......@@ -243,7 +246,7 @@ window.setInterval(function() {
}
if (globals.open_settings) {
new_progress = 'Settings window is open';
new_progress = MENU.SETTINGSOPEN;
globals.open_settings = false;
settings_menu.click();
deactivate_menu();
......
var gui = require('nw.gui');
var NOTIFIER = COMMON.NOTIFIER;
function is_up(code) { return (code / 100 >> 0) === 1; }
function has_settings_error(code) { return (code / 200 >> 0) === 2; }
......@@ -7,9 +8,9 @@ function remaining(status) {
}
var ntf_title = {
'info': 'Agkyra Notification',
'warning': 'Agkyra Warning',
'error': 'Agkyra Error'
'info': NOTIFIER.INFO,
'warning': NOTIFIER.WARNING,
'error': NOTIFIER.ERROR
}
var ntf_icon = {
'info': 'static/images/ntf_info.png',
......
......@@ -21,10 +21,9 @@ var fs = require('fs');
// Read config file
var cnf = JSON.parse(fs.readFileSync(gui.App.argv[0], encoding='utf-8'));
var COMMON = JSON.parse(fs.readFileSync(path.join('..', 'ui_data/common.json')));
var COMMON = JSON.parse(fs.readFileSync(path.join('..', 'ui_data/common_en.json')));
var STATUS = COMMON['STATUS'];
var NOTIFICATION = COMMON['NOTIFICATION'];
function log_debug(msg) { if (DEBUG) console.log(msg); }
......
......@@ -22,6 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<script src="static/js/jquery.js"></script>
<script src="settings.js"></script>
<script type="text/javascript">
var path = require('path');
var fs = require('fs');
var COMMON = JSON.parse(
fs.readFileSync(path.join('..', 'ui_data/common_en.json')));
var SETTINGS = COMMON.SETTINGS;
var errors = {
cloud_url_empty: 'Provide a Cloud Authentication URL',
cloud_inaccessible: 'Cloud URL did not respond as expected',
......@@ -200,14 +206,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<body>
<div class="wrapper">
<header>
<h2><img src="static/images/about.png"/> User Settings</h2>
<h2><img src="static/images/about.png"/> <span id="title">User Settings</span></h2>
</header>
<form>
<fieldset>
<legend>Cloud</legend>
<legend id="cloud_label">Cloud</legend>
<div class="clearfix">
<div class="small-3 columns">
<label for="cloud-url" class="right inline">Cloud URL</label>
<label id="url_label" for="cloud-url" class="right inline">Cloud URL</label>
</div>
<div class="small-9 columns" id="cloud-error">
......@@ -222,7 +228,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="clearfix">
<div class="small-3 columns">
<label for="token" class="right inline">User token</label>
<label id="token_label" for="token" class="right inline">User token</label>
</div>
<div class="small-9 columns" id="token-error">
<input type="text" id="token" placeholder="User token"
......@@ -240,10 +246,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</fieldset>
<fieldset>
<legend>What to sync</legend>
<legend id="sync_label">What to sync</legend>
<div class="row clearfix">
<div class="small-3 columns">
<label for="container" class="right inline">Remote container</label>
<label id="container_label" for="container" class="right inline">Remote container</label>
</div>
<div class="small-9 columns" id="container-error">
<input type="text" id="container" placeholder="Pithos+ container"
......@@ -253,11 +259,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div class="row clearfix">
<div class="small-3 columns">
<label for="directory" class="right">
<label id="directory_label" for="directory" class="right">
Local directory</label>
</div>
<div id="directory" class="small-6 columns"></div>
<div onclick="$('#choose-dir').trigger('click');"
<div id="dirdialogue_label" onclick="$('#choose-dir').trigger('click');"
class="small-3 columns pickdir" id="dirpick">
Select</div>
</div>
......@@ -274,26 +280,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
onchange="$('#directory').html($(this).val());
settings['directory'] = $(this).val();
check_directory();" />
<!--<div class="row clearfix">
<div class="small-3 columns"><label class="right inline">
Change the directory:</label></div>
<div class="small-9 columns">
<input type="file" nwdirectory
onchange="$('#directory').html($(this).val());
settings['directory'] = $(this).val();
" />
</div>
</div>-->
<!--<div class="row">
<div class="small-3 columns">
<label for="exclude" class="right inline">Exclude these items from syncing</label>
</div>
<div class="small-9 columns">
<textarea id="exclude"
onchange="update_exclude($(this).val())">
</textarea>
</div>
</div> -->
</fieldset>
<div class="clearfix">
<a id="sync_button" class="button right"
......@@ -307,5 +293,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
</form>
</div>
<script type="text/javascript">
document.getElementById('title').innerHTML = SETTINGS.TITLE;
document.getElementById('cloud_label').innerHTML = SETTINGS.CLOUD;
document.getElementById('url_label').innerHTML = SETTINGS.URL;
document.getElementById('token_label').innerHTML = SETTINGS.TOKEN;
document.getElementById('get_creds').innerHTML = SETTINGS.RETRIEVE;
document.getElementById('sync_label').innerHTML = SETTINGS.SYNC;
document.getElementById('container_label').innerHTML = SETTINGS.CONTAINER;
document.getElementById('directory_label').innerHTML = SETTINGS.DIRECTORY;
document.getElementById('dirdialogue_label').innerHTML = SETTINGS.DIRDIALOGUE;
document.getElementById('sync_button').innerHTML = SETTINGS.SAVE;
</script>
</body>
</html>
......@@ -34,7 +34,7 @@ CURPATH = os.path.dirname(os.path.abspath(__file__))
LOG = logging.getLogger(__name__)
SYNCERS = utils.ThreadSafeDict()
with open(os.path.join(CURPATH, 'ui_data/common.json')) as f:
with open(os.path.join(CURPATH, 'ui_data/common_en.json')) as f:
COMMON = json.load(f)
STATUS = COMMON['STATUS']
......
{
"STATUS": {
"UNINITIALIZED": 0,
"INITIALIZING": 1,
"SHUTTING DOWN": 2,
"SYNCING": 100,
"PAUSING": 101,
"PAUSED": 102,
"SETTINGS MISSING": 200,
"AUTH URL ERROR": 201,
"TOKEN ERROR": 202,
"DIRECTORY ERROR": 203,
"CONTAINER ERROR": 204,
"CRITICAL ERROR": 1000
},
"NOTIFICATION": {
"0": "Ανενεργό",
"1": "Εκκίνηση ...",
"2": "Κλείσιμο",
"100": "Κατάσταση συγχρονισμού",
"101": "Παύση",
"102": "Κατάσταση παύσης",
"200": "Ανεπαρκείς ρυθμίσεις",
"201": "Σφάλμα με το URL",
"202": "Σφάλμα ταυτοποίησης χρήστη",
"203": "Σφάλμα με τον τοπικό φάκελο",
"204": "Σφάλμα με τον απομακρυσμένο αποταμιευτήρα",
"1000": "Κρίσιμο σφάλμα"
},
"MENU": {
"TITLE": "Άγκυρα - συγχρονιστής αρχείων",
"START": "Εκκίνηση συγχρονισμού",
"PAUSE": "Παύση συγχρονισμού",
"INACTIVE": "Ανενεργό",
"WAITING": "Αναμονή...",
"REMAINING": "απομένουν %s",
"FOLDER": "Τοπικός φάκελος",
"PITHOS": "Σελίδα στον Πίθο+",
"SETTINGS": "Ρυθμίσεις",
"SETTINGSOPEN": "Ανοιχτό παράθυρο ρυθμίσεων",
"ABOUT": "Σχετικά",
"QUIT": "Κλείσιμο Άγκυρας"
},
"NOTIFIER": {
"INFO": "Άγκυρα",
"WARNING": "Άγκυρα - προσοχή!",
"ERROR": "Άγκυρα - σφάλμα!"
},
"SETTINGS": {
"TITLE": "Ρυθμίσεις χρήστη",
"CLOUD": "Απομακρυσμένο σύστημα (νέφος)",
"URL": "URL νέφους",
"TOKEN": "Κλειδί token",
"RETRIEVE": "Είσοδος με όνομα χρήστη/κωδικό",
"SYNC": "Τι να συγχρονιστεί",
"CONTAINER": "Αποταμιευτήρας (container)",
"DIRECTORY": "Τοπικός φάκελος",
"DIRDIALOGUE": "Επιλογή φακέλου",
"SAVE": "Αποθήκευση"
}
}
\ No newline at end of file
......@@ -26,5 +26,36 @@
"203": "Local directory error",
"204": "Remote container error",
"1000": "Critical error"
}
},
"MENU": {
"TITLE": "Agkyra Syncing Client",
"START": "Start syncing",
"PAUSE": "Pause syncing",
"INACTIVE": "Inactive",
"WAITING": "Waiting...",
"REMAINING": "%s remaining",
"FOLDER": "Open local folder",
"PITHOS": "Launch Pithos+ page",
"SETTINGS": "Settings",
"SETTINGSOPEN": "Settings window is open",
"ABOUT": "About",
"QUIT": "Quit Agkyra"
},
"NOTIFIER": {
"INFO": "Agkyra notification",
"WARNING": "Agkyra warning",
"ERROR": "Agkyra error"
},
"SETTINGS": {
"TITLE": "User Settings",
"CLOUD": "Cloud",
"URL": "Cloud URL",
"TOKEN": "User Token",
"RETRIEVE": "Login to retrieve token",
"SYNC": "What to sync",
"CONTAINER": "Remote container",
"DIRECTORY": "Local directory",
"DIRDIALOGUE": "Select",
"SAVE": "Save"
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment