From 2b0e844656928435e99d36a37353f3b285f4fca1 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 6 Jun 2016 00:49:48 +0800 Subject: [PATCH] refactor code --- app/langs/{zh-CN.json => zh_CN.json} | 39 +++++++------- app/scripts/config/configuration.js | 4 +- app/scripts/config/constants.js | 2 +- app/scripts/config/language-default.js | 60 ++++++++++++++------- app/scripts/config/languages.js | 4 +- app/scripts/services/aria2SettingService.js | 17 ++++++ app/views/setting.html | 15 +----- 7 files changed, 84 insertions(+), 57 deletions(-) rename app/langs/{zh-CN.json => zh_CN.json} (97%) diff --git a/app/langs/zh-CN.json b/app/langs/zh_CN.json similarity index 97% rename from app/langs/zh-CN.json rename to app/langs/zh_CN.json index d1dfaf3..e2e40af 100644 --- a/app/langs/zh-CN.json +++ b/app/langs/zh_CN.json @@ -4,10 +4,6 @@ "Error": "错误", "OK": "确定", "Cancel": "取消", - "True": "是", - "true": "是", - "False": "否", - "false": "否", "New": "新建", "Start": "开始下载任务", "Pause": "暂停下载任务", @@ -105,20 +101,6 @@ "Disabled": "禁用", "Changes to the settings take effect after refreshing page.": "设置将在页面刷新后生效.", "Type is illegal!": "类型错误!", - "none": "无", - "http": "Http", - "https": "Https", - "ftp": "Ftp", - "mem": "仅内存", - "plain": "明文", - "arc4": "ARC4", - "binary": "二进制", - "ascii": "ASCII", - "debug": "调试 (Debug)", - "info": "普通 (Info)", - "notice": "一般 (Notice)", - "warn": "警告 (Warn)", - "error": "错误 (Error)", "format": { "time.millisecond": "{{value}} 毫秒", "time.milliseconds": "{{value}} 毫秒", @@ -138,6 +120,25 @@ } }, "options": { + "true": "是", + "false": "否", + "default": "默认", + "none": "无", + "hide": "隐藏", + "full": "完整", + "http": "Http", + "https": "Https", + "ftp": "Ftp", + "mem": "仅内存", + "plain": "明文", + "arc4": "ARC4", + "binary": "二进制", + "ascii": "ASCII", + "debug": "调试 (Debug)", + "info": "普通 (Info)", + "notice": "一般 (Notice)", + "warn": "警告 (Warn)", + "error": "错误 (Error)", "dir.name": "下载路径", "dir.description": "", "log.name": "日志文件", @@ -174,7 +175,7 @@ "no-proxy.name": "不使用代理服务器列表", "no-proxy.description": "设置不使用代理服务器的主机名, 域名, 包含或不包含子网掩码的网络地址, 多个使用逗号分隔.", "proxy-method.name": "代理服务器请求方法", - "proxy-method.description": "设置用来请求代理服务器的方法. 方法可设置为 get 或 tunnel. HTTPS 下载将忽略此选项并总是使用 tunnel.", + "proxy-method.description": "设置用来请求代理服务器的方法. 方法可设置为 GET 或 TUNNEL. HTTPS 下载将忽略此选项并总是使用 TUNNEL.", "remote-time.name": "获取服务器文件时间", "remote-time.description": "从 HTTP/FTP 服务获取远程文件的时间戳, 如果可用将设置到本地文件", "reuse-uri.name": "URI 复用", diff --git a/app/scripts/config/configuration.js b/app/scripts/config/configuration.js index 2e99488..7d4c92f 100644 --- a/app/scripts/config/configuration.js +++ b/app/scripts/config/configuration.js @@ -11,8 +11,8 @@ prefix: 'langs/', suffix: '.json' }).useLoaderCache(true) - .preferredLanguage('en-US') - .fallbackLanguage('en-US') + .preferredLanguage('en') + .fallbackLanguage('en') .useSanitizeValueStrategy('escape'); }]); })(); diff --git a/app/scripts/config/constants.js b/app/scripts/config/constants.js index a69cf36..742a8c2 100644 --- a/app/scripts/config/constants.js +++ b/app/scripts/config/constants.js @@ -7,7 +7,7 @@ optionStorageKey: 'Options', lazySaveTimeout: 500 }).constant('ariaNgDefaultOptions', { - language: 'en-US', + language: 'en', rpcHost: '', rpcPort: '6800', protocol: 'http', diff --git a/app/scripts/config/language-default.js b/app/scripts/config/language-default.js index 9e4d2c7..9decd0f 100644 --- a/app/scripts/config/language-default.js +++ b/app/scripts/config/language-default.js @@ -2,16 +2,12 @@ 'use strict'; angular.module('ariaNg').config(['$translateProvider', function ($translateProvider) { - $translateProvider.translations('en-US', { + $translateProvider.translations('en', { 'English': 'English', 'Operation Succeeded': 'Operation Succeeded', 'Error': 'Error', 'OK': 'OK', 'Cancel': 'Cancel', - 'True': 'True', - 'true': 'True', - 'False': 'False', - 'false': 'False', 'New': 'New', 'Start': 'Start', 'Pause': 'Pause', @@ -109,20 +105,6 @@ 'Disabled': 'Disabled', 'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.', 'Type is illegal!': 'Type is illegal!', - 'none': 'None', - 'http': 'Http', - 'https': 'Https', - 'ftp': 'Ftp', - 'mem': 'Memory Only', - 'plain': 'Plain', - 'arc4': 'ARC4', - 'binary': 'Binary', - 'ascii': 'ASCII', - 'debug': 'Debug', - 'info': 'Info', - 'notice': 'Notice', - 'warn': 'Warn', - 'error': 'Error', 'format': { 'time.millisecond': '{{value}} Millisecond', 'time.milliseconds': '{{value}} Milliseconds', @@ -142,6 +124,44 @@ } }, 'options': { + 'true': 'True', + 'false': 'False', + 'default': 'Default', + 'none': 'None', + 'hide': 'Hide', + 'full': 'Full', + 'http': 'Http', + 'https': 'Https', + 'ftp': 'Ftp', + 'mem': 'Memory Only', + 'get': 'GET', + 'tunnel': 'TUNNEL', + 'plain': 'Plain', + 'arc4': 'ARC4', + 'binary': 'Binary', + 'ascii': 'ASCII', + 'debug': 'Debug', + 'info': 'Info', + 'notice': 'Notice', + 'warn': 'Warn', + 'error': 'Error', + 'adaptive': 'adaptive', + 'epoll': 'epoll', + 'falloc': 'falloc', + 'feedback': 'feedback', + 'geom': 'geom', + 'inorder': 'inorder', + 'kqueue': 'kqueue', + 'poll': 'poll', + 'port': 'port', + 'prealloc': 'prealloc', + 'random': 'random', + 'select': 'select', + 'trunc': 'trunc', + 'SSLv3': 'SSLv3', + 'TLSv1': 'TLSv1', + 'TLSv1.1': 'TLSv1.1', + 'TLSv1.2': 'TLSv1.2', 'dir.name': 'Download Path', 'dir.description': '', 'log.name': 'Log File', @@ -179,7 +199,7 @@ 'no-proxy.name': 'No Proxy List', 'no-proxy.description': 'Specify a comma separated list of host names, domains and network addresses with or without a subnet mask where no proxy should be used.', 'proxy-method.name': 'Proxy Method', - 'proxy-method.description': 'Set the method to use in proxy request. METHOD is either get or tunnel. HTTPS downloads always use tunnel regardless of this option.', + 'proxy-method.description': 'Set the method to use in proxy request. METHOD is either GET or TUNNEL. HTTPS downloads always use TUNNEL regardless of this option.', 'remote-time.name': 'Remote File Timestamp', 'remote-time.description': 'Retrieve timestamp of the remote file from the remote HTTP/FTP server and if it is available, apply it to the local file.', 'reuse-uri.name': 'Reuse Uri', diff --git a/app/scripts/config/languages.js b/app/scripts/config/languages.js index 9ef67ed..cff2f85 100644 --- a/app/scripts/config/languages.js +++ b/app/scripts/config/languages.js @@ -2,10 +2,10 @@ 'use strict'; angular.module('ariaNg').constant('ariaNgLanguages', { - 'en-US': { + 'en': { name: 'English' }, - 'zh-CN': { + 'zh_CN': { name: 'Simplified Chinese' } }); diff --git a/app/scripts/services/aria2SettingService.js b/app/scripts/services/aria2SettingService.js index 5c86885..0fef967 100644 --- a/app/scripts/services/aria2SettingService.js +++ b/app/scripts/services/aria2SettingService.js @@ -68,6 +68,23 @@ descriptionKey: 'options.' + key + '.description' }, option); + if (option.type == 'boolean') { + option.options = ['true', 'false']; + } + + if (option.options) { + var availableOptions = []; + + for (var j = 0; j < option.options.length; j++) { + availableOptions.push({ + name: 'options.' + option.options[j], + value: option.options[j] + }); + } + + option.options = availableOptions; + } + options.push(option); } diff --git a/app/views/setting.html b/app/views/setting.html index 0aad955..6ef7bd7 100644 --- a/app/views/setting.html +++ b/app/views/setting.html @@ -25,22 +25,11 @@ -
-
- -
- -
-
-
-
+