diff --git a/README.md b/README.md index 8902d92..a0d076e 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ An Open Source Web Hosting Account and Support Management System for MyOwnFreeHo ### multi-language module -- [x] Load default language +- [x] Load default language config (/core/language/) - [x] Change language +- [x] Load custom language config (/data/language/) ### ClientArea module diff --git a/src/admin/views/accounts/edit.php b/src/admin/views/accounts/edit.php index bb26a7c..e61d3ff 100755 --- a/src/admin/views/accounts/edit.php +++ b/src/admin/views/accounts/edit.php @@ -24,7 +24,7 @@
- +
diff --git a/src/admin/views/clients/view.php b/src/admin/views/clients/view.php index 1b933e5..cf9ed41 100755 --- a/src/admin/views/clients/view.php +++ b/src/admin/views/clients/view.php @@ -21,7 +21,7 @@ I18N('Email Address'); ?>:
- Phone Number: + I18N('Phone Number'); ?>:
I18N('Billing Address'); ?>: diff --git a/src/clientarea/views/accounts/add.php b/src/clientarea/views/accounts/add.php index 32f80c8..bda611e 100755 --- a/src/clientarea/views/accounts/add.php +++ b/src/clientarea/views/accounts/add.php @@ -22,7 +22,7 @@
- +
diff --git a/src/clientarea/views/accounts/edit.php b/src/clientarea/views/accounts/edit.php index f579556..f05eb9e 100755 --- a/src/clientarea/views/accounts/edit.php +++ b/src/clientarea/views/accounts/edit.php @@ -24,7 +24,7 @@
- +
diff --git a/src/clientarea/views/clients/profile.php b/src/clientarea/views/clients/profile.php index 5893b3f..bd4e4be 100755 --- a/src/clientarea/views/clients/profile.php +++ b/src/clientarea/views/clients/profile.php @@ -16,7 +16,7 @@
I18N('Email Address'); ?>:
-
Phone Number:
+
I18N('Phone Number'); ?>:
I18N('Billing Address'); ?>:
diff --git a/src/clientarea/views/common/sidebar.php b/src/clientarea/views/common/sidebar.php index 125cc75..31ce475 100755 --- a/src/clientarea/views/common/sidebar.php +++ b/src/clientarea/views/common/sidebar.php @@ -29,7 +29,7 @@ $avatar_path = $ClientInfo['client_email'] ? md5($ClientInfo['client_email']) : - I18N('SSL Certificate'); ?> + I18N('SSL Certificates'); ?> diff --git a/src/clientarea/views/settings.php b/src/clientarea/views/settings.php index 7eb5d47..50a57cf 100755 --- a/src/clientarea/views/settings.php +++ b/src/clientarea/views/settings.php @@ -29,7 +29,7 @@
- +
diff --git a/src/core/application.php b/src/core/application.php index 7d18641..8d6ee11 100755 --- a/src/core/application.php +++ b/src/core/application.php @@ -58,7 +58,7 @@ include_once __DIR__ . '/library/autoloader.php'; Autoloader::register(); -$lang = new \lib\Language(ROOT . '/data/language/'); +$lang = new \lib\Language(ROOT . '/core/language/', ROOT . '/data/language/'); define('DB_PREFIX', $dbconfig['prefix']); diff --git a/src/data/language/en-US/language.php b/src/core/language/en-US/language.php similarity index 100% rename from src/data/language/en-US/language.php rename to src/core/language/en-US/language.php diff --git a/src/data/language/ko-KR/language.php b/src/core/language/ko-KR/language.php similarity index 100% rename from src/data/language/ko-KR/language.php rename to src/core/language/ko-KR/language.php diff --git a/src/core/language/zh-CN/language.php b/src/core/language/zh-CN/language.php new file mode 100755 index 0000000..b536b77 --- /dev/null +++ b/src/core/language/zh-CN/language.php @@ -0,0 +1,131 @@ + "主页", + "solution" => "方案", + "news" => "新闻", + "News" => "新闻", + "contact" => "联系", + "Contact Us" => "联系我们", + "help" => "帮助", + "login" => "登录", + 'logout' => '退出登录', + "register" => "注册", + 'Signup' => "注册", + 'First Name' => '名字', + 'Last Name' => '姓氏', + "username" => "用户名", + "input_username" => "请输入用户名", + "password" => "密码", + 'Password' => "密码", + 'Confirm Password' => "确认密码", + "input_password" => "请输入密码", + "password_lost" => "忘记密码了?", + "password_reset" => "重置密码", + "email" => "电子邮箱", + "input_email" => "请输入电子邮箱地址", + "site_category" => "网站类型", + "personal" => "个人", + "business" => "商业", + "hobby" => "爱好", + "forum" => "论坛", + "adult" => "成人", + "dating" => "约会", + "software_download" => "软件/下载", + "choose_from_below" => "下拉选择", + "site_language" => "网站语言", + "english" => "英文", + "non_english" => "非英文", + "security_code" => "验证码", + "input_security_code" => "输入验证码", + "input_security_code_above" => "请输入上面图中验证码", + "legal_information" => "法律信息", + "privacy_policy" => "隐私政策", + "tos" => "服务条款", + "cancellation_refund" => "取消与退款", + "payment_methods" => "支付方式", + "signup_free_hosting" => "注册免费空间", + "Remember me" => "记住我", + "please_login" => "请登录", + "address" => "地址", + "host-plan" => "主机方案", + "host-plan-free" => "免费主机", + "host-plan-paid" => "收费主机", + 'host-plan-super' => '高级主机', + 'host-plan-ultimate' => '顶级主机', + "ftp-accounts" => "FTP账号", + 'free-domains' => '免费域名', + "sub-domains" => "子域名", + "add-on-domains" => "绑定域名", + "parked-domains" => "停放域名", + "mysql-databases" => "MySQL数据库", + "disk-quota" => "总空间配额", + "monthly-bandwidth" => "每月流量限制", + "daily-hits" => "每日点击配额", + "host-inodes" => "使用Inode配额", + "unlimited" => "无限", + "domain" => "域名", + "input-domain" => "请输入域名", + 'support' => '支持', + 'not-support' => '不支持', + 'more' => '更多', + 'about' => '关于', + 'aboutus' => '关于我们', + 'clientarea' => '客户中心', + 'Client Area' => '客户中心', + 'add' => '新增', + 'modify' => '修改', + 'edit' => '编辑', + 'list' => '列表', + 'managearea' => '管理中心', + 'delete' => '删除', + 'details' => '详情', + 'Tickets' => '工单管理', + 'My Tickets' => '我的工单', + 'Tickets Details' => '工单详情', + 'member' => '客户', + 'members' => '客户', + 'reg_date' => '注册日期', + 'cancel' => '取消', + 'Settings' => '设置', + 'Return' => '返回', + 'Save' => '保存', + 'Clients' => '客户', + 'Hosting Accounts' => '托管帐户', + 'System Settings' => '系统配置', + 'Company Name' => '公司名称', + 'Company' => '公司', + 'Brand Name' => '品牌标识', + 'Contact Phone' => '联系电话', + 'Phone' => '电话', + 'Phone Number' => '手机号码', + 'Contact Email' => '联系邮箱', + 'Email' => '电子邮箱', + 'Email Address' => '邮箱地址', + 'iFastNet Affiliate ID' => 'iFastNet 推广编号', + 'Technical Support' => '技术支持', + 'Main Menu' => '菜单', + 'Logged in as' => '当前登陆账号', + 'Validate Account' => '验证帐户', + 'Validate' => '验证', + 'Validation Code' => '验证码', + 'Resend Code' => '重新发送验证码', + 'Forget Password' => '忘记密码', + 'Reset Password' => '重置密码', + 'Profile' => '个人资料', + 'My Profile' => '个人资料', + 'Knowledgebase' => '知识库', + 'Knowledgebase List' => '知识库', + 'Additional Tools' => '附加工具', + 'Send Email' => '发送邮件', + 'Send Test Email' => '发送测试邮件', + 'This test email indicates that SMTP has been configured correctly.' => '收到这个测试邮件,说明SMTP已配置正确。', + 'SSL Certificates' => 'SSL证书', + 'Site Name' => '网站名称', + 'Site Status' => '网站状态', + 'Page Title' => '网页标题', + 'Page Description' => '网页描述', + 'Page Keywords' => '网页关键字', + 'Page Copyright' => '网页版权标识', + 'Page Author' => '网页著作人', + 'Admin Area' => '管理中心' +); diff --git a/src/data/language/zh-HK/language.php b/src/core/language/zh-HK/language.php similarity index 100% rename from src/data/language/zh-HK/language.php rename to src/core/language/zh-HK/language.php diff --git a/src/data/language/zh-SG/language.php b/src/core/language/zh-SG/language.php similarity index 100% rename from src/data/language/zh-SG/language.php rename to src/core/language/zh-SG/language.php diff --git a/src/data/language/zh-TW/language.php b/src/core/language/zh-TW/language.php similarity index 100% rename from src/data/language/zh-TW/language.php rename to src/core/language/zh-TW/language.php diff --git a/src/core/library/lib/Language.class.php b/src/core/library/lib/Language.class.php index b0e51c2..9b72b7e 100755 --- a/src/core/library/lib/Language.class.php +++ b/src/core/library/lib/Language.class.php @@ -7,7 +7,8 @@ class Language public $language_current; public $language_cached; public $language_default; - public $language_root; + public $root_default; + public $root_custom; public $language_file; private $languages = [ 'en-US' => ['English', 'English'], @@ -118,18 +119,20 @@ class Language 'yo' => ['Yorùbá', 'Yoruba'], 'zu' => ['Zulu', 'Zulu'], ]; - private $LANG; + private $LANG = []; private $domain; /** 构造函数 - * @param string $language_root 翻译文件根目录 + * @param string $root_default 翻译文件根目录 + * @param string $root_custom 翻译文件自定义目录 * @param array $languages 可用语言列表 * @param string $lang_default 默认语言 * @return void */ - public function __construct($language_root, $lang_default = '') + public function __construct($root_default, $root_custom, $lang_default = '') { - $this->language_root = $language_root; + $this->root_default = $root_default; + $this->root_custom = $root_custom; if (!empty($lang_default) && array_key_exists($lang_default, $this->languages)) { $this->language_default = $lang_default; $this->language_current = $lang_default; @@ -189,17 +192,23 @@ class Language private function has_language_file($lang) { - return !empty($lang) && file_exists($this->language_root . $lang . '/' . 'language.php'); + return file_exists($this->root_default . $lang . '/language.php') || file_exists($this->root_custom . $lang . '/' . 'language.php'); } private function init_language_file() { - if ($this->has_language_file($this->language_current)) { - $this->language_file = $this->language_root . $this->language_current . '/' . 'language.php'; - } else { - $this->language_file = $this->language_root . $this->language_default . '/' . 'language.php'; + + $default = $this->root_default . $this->language_current . '/language.php'; + $custom = $this->root_custom . $this->language_current . '/language.php'; + if (!$this->has_language_file($this->language_current)) { + // change to default language + $default = $this->root_default . $this->language_default . '/language.php'; + $custom = $this->root_custom . $this->language_default . '/language.php'; } - $this->LANG = require $this->language_file; + + $defaultConfig = file_exists($default) ? require $default : []; + $customConfig = file_exists($custom) ? require $custom : []; + $this->LANG = array_replace_recursive($defaultConfig, $customConfig); } public function get_languages_tags() diff --git a/src/data/language/zh-CN/language.php b/src/data/language/zh-CN/language.php index dfda9d1..3d1e91e 100755 --- a/src/data/language/zh-CN/language.php +++ b/src/data/language/zh-CN/language.php @@ -1,130 +1,5 @@ "主页", - "solution" => "方案", - "news" => "新闻", - "News" => "新闻", - "contact" => "联系", - "Contact Us" => "联系我们", - "help" => "帮助", - "login" => "登录", - 'logout' => '退出登录', - "register" => "注册", - 'Signup' => "注册", - 'First Name' => '名字', - 'Last Name' => '姓氏', - "username" => "用户名", - "input_username" => "请输入用户名", - "password" => "密码", - 'Password' => "密码", - 'Confirm Password' => "确认密码", - "input_password" => "请输入密码", - "password_lost" => "忘记密码了?", - "password_reset" => "重置密码", - "email" => "电子邮箱", - "input_email" => "请输入电子邮箱地址", - "site_category" => "网站类型", - "personal" => "个人", - "business" => "商业", - "hobby" => "爱好", - "forum" => "论坛", - "adult" => "成人", - "dating" => "约会", - "software_download" => "软件/下载", - "choose_from_below" => "下拉选择", - "site_language" => "网站语言", - "english" => "英文", - "non_english" => "非英文", - "security_code" => "验证码", - "input_security_code" => "输入验证码", - "input_security_code_above" => "请输入上面图中验证码", - "legal_information" => "法律信息", - "privacy_policy" => "隐私政策", - "tos" => "服务条款", - "cancellation_refund" => "取消与退款", - "payment_methods" => "支付方式", - "signup_free_hosting" => "注册免费空间", - "Remember me" => "记住我", - "please_login" => "请登录", - "address" => "地址", - "host-plan" => "主机方案", - "host-plan-free" => "免费主机", - "host-plan-paid" => "收费主机", - 'host-plan-super' => '高级主机', - 'host-plan-ultimate' => '顶级主机', - "ftp-accounts" => "FTP账号", - 'free-domains' => '免费域名', - "sub-domains" => "子域名", - "add-on-domains" => "绑定域名", - "parked-domains" => "停放域名", - "mysql-databases" => "MySQL数据库", - "disk-quota" => "总空间配额", - "monthly-bandwidth" => "每月流量限制", - "daily-hits" => "每日点击配额", - "host-inodes" => "使用Inode配额", - "unlimited" => "无限", - "domain" => "域名", - "input-domain" => "请输入域名", - 'support' => '支持', - 'not-support' => '不支持', - 'more' => '更多', - 'about' => '关于', - 'aboutus' => '关于我们', - 'clientarea' => '客户中心', - 'Client Area' => '客户中心', - 'add' => '新增', - 'modify' => '修改', - 'edit' => '编辑', - 'list' => '列表', - 'managearea' => '管理中心', - 'delete' => '删除', - 'details' => '详情', - 'Tickets' => '工单管理', - 'My Tickets' => '我的工单', - 'Tickets Details' => '工单详情', - 'member' => '客户', - 'members' => '客户', - 'reg_date' => '注册日期', - 'cancel' => '取消', - 'Settings' => '设置', - 'Return' => '返回', - 'Save' => '保存', - 'Clients' => '客户', - 'Hosting Accounts' => '托管帐户', - 'System Settings' => '系统配置', - 'Company Name' => '公司名称', - 'Company' => '公司', - 'Brand Name' => '品牌标识', - 'Contact Phone' => '联系电话', - 'Phone' => '电话', - 'Contact Email' => '联系邮箱', - 'Email' => '电子邮箱', - 'Email Address' => '邮箱地址', - 'iFastNet Affiliate ID' => 'iFastNet 推广编号', - 'Technical Support' => '技术支持', - 'Main Menu' => '菜单', - 'Logged in as' => '当前登陆账号', - 'Validate Account' => '验证帐户', - 'Validate' => '验证', - 'Validation Code' => '验证码', - 'Resend Code' => '重新发送验证码', - 'Forget Password' => '忘记密码', - 'Reset Password' => '重置密码', - 'Profile' => '个人资料', - 'My Profile' => '个人资料', - 'Knowledgebase' => '知识库', - 'Knowledgebase List' => '知识库', - 'Additional Tools' => '附加工具', - 'Send Email' => '发送邮件', - 'Send Test Email' => '发送测试邮件', - 'This test email indicates that SMTP has been configured correctly.' => '收到这个测试邮件,说明SMTP已配置正确。', - 'SSL Certificates' => 'SSL证书', - 'Site Name' => '网站名称', - 'Site Status' => '网站状态', - 'Page Title' => '网页标题', - 'Page Description' => '网页描述', - 'Page Keywords' => '网页关键字', - 'Page Copyright' => '网页版权标识', - 'Page Author' => '网页著作人', - 'Admin Area' => '管理中心' + 'Country' => '国家', + 'Phone Number' => '手机号码' );