1. support custom language config
This commit is contained in:
Jackson Dou 2023-05-20 11:59:27 +08:00
parent 097726c785
commit 87929ce135
17 changed files with 163 additions and 147 deletions

View file

@ -10,8 +10,9 @@ An Open Source Web Hosting Account and Support Management System for MyOwnFreeHo
### multi-language module ### multi-language module
- [x] Load default language - [x] Load default language config (/core/language/)
- [x] Change language - [x] Change language
- [x] Load custom language config (/data/language/)
### ClientArea module ### ClientArea module

View file

@ -24,7 +24,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="mb-10 px-10"> <div class="mb-10 px-10">
<label class="form-label required">Phone Number</label> <label class="form-label required"><?php echo $lang->I18N('Phone Number'); ?></label>
<input type="text" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly> <input type="text" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly>
</div> </div>
</div> </div>

View file

@ -21,7 +21,7 @@
<b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $ClientInfo['client_email']; ?> <b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $ClientInfo['client_email']; ?>
</div> </div>
<div class="col-md-6 mb-10"> <div class="col-md-6 mb-10">
<b>Phone Number:</b> <?php echo $ClientInfo['client_phone']; ?> <b><?php echo $lang->I18N('Phone Number'); ?>:</b> <?php echo $ClientInfo['client_phone']; ?>
</div> </div>
<div class="col-md-6 mb-10"> <div class="col-md-6 mb-10">
<b><?php echo $lang->I18N('Billing Address'); ?>:</b> <?php echo $ClientInfo['client_address']; ?> <b><?php echo $lang->I18N('Billing Address'); ?>:</b> <?php echo $ClientInfo['client_address']; ?>

View file

@ -22,7 +22,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="mb-10 px-10"> <div class="mb-10 px-10">
<label class="form-label required">Phone Number</label> <label class="form-label required"><?php echo $lang->I18N('Phone Number'); ?></label>
<input type="text" name="email" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly> <input type="text" name="email" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly>
</div> </div>
</div> </div>

View file

@ -24,7 +24,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="mb-10 px-10"> <div class="mb-10 px-10">
<label class="form-label required">Phone Number</label> <label class="form-label required"><?php echo $lang->I18N('Phone Number'); ?></label>
<input type="text" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly> <input type="text" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control disabled" readonly>
</div> </div>
</div> </div>

View file

@ -16,7 +16,7 @@
<h6 class="mb-0"><b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $ClientInfo['client_email'];?></h6> <h6 class="mb-0"><b><?php echo $lang->I18N('Email Address'); ?>:</b> <?php echo $ClientInfo['client_email'];?></h6>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<h6 class="mb-0"><b>Phone Number:</b> <?php echo $ClientInfo['client_phone'];?></h6> <h6 class="mb-0"><b><?php echo $lang->I18N('Phone Number'); ?>:</b> <?php echo $ClientInfo['client_phone'];?></h6>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<h6 class="mb-0"><b><?php echo $lang->I18N('Billing Address'); ?>:</b> <?php echo $ClientInfo['client_address'];?></h6> <h6 class="mb-0"><b><?php echo $lang->I18N('Billing Address'); ?>:</b> <?php echo $ClientInfo['client_address'];?></h6>

View file

@ -29,7 +29,7 @@ $avatar_path = $ClientInfo['client_email'] ? md5($ClientInfo['client_email']) :
</a> </a>
<a href="myssl.php" class="sidebar-link sidebar-link-with-icon"> <a href="myssl.php" class="sidebar-link sidebar-link-with-icon">
<span class="sidebar-icon bg-transparent"><i class="fa fa-lock" aria-hidden="true"></i></span> <span class="sidebar-icon bg-transparent"><i class="fa fa-lock" aria-hidden="true"></i></span>
<?php echo $lang->I18N('SSL Certificate'); ?> <?php echo $lang->I18N('SSL Certificates'); ?>
</a> </a>
<a href="knowledgebase.php" class="sidebar-link sidebar-link-with-icon"> <a href="knowledgebase.php" class="sidebar-link sidebar-link-with-icon">
<span class="sidebar-icon bg-transparent"><i class="fa fa-book" aria-hidden="true"></i></span> <span class="sidebar-icon bg-transparent"><i class="fa fa-book" aria-hidden="true"></i></span>

View file

@ -29,7 +29,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="mb-10 px-10"> <div class="mb-10 px-10">
<label class="form-label required">Phone Number</label> <label class="form-label required"><?php echo $lang->I18N('Phone Number'); ?></label>
<input type="text" name="phone" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control" required> <input type="text" name="phone" value="<?php echo $ClientInfo['client_phone']; ?>" class="form-control" required>
</div> </div>
</div> </div>

View file

@ -58,7 +58,7 @@ include_once __DIR__ . '/library/autoloader.php';
Autoloader::register(); Autoloader::register();
$lang = new \lib\Language(ROOT . '/data/language/'); $lang = new \lib\Language(ROOT . '/core/language/', ROOT . '/data/language/');
define('DB_PREFIX', $dbconfig['prefix']); define('DB_PREFIX', $dbconfig['prefix']);

View file

@ -0,0 +1,131 @@
<?php
return array(
"home" => "主页",
"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' => '管理中心'
);

View file

@ -7,7 +7,8 @@ class Language
public $language_current; public $language_current;
public $language_cached; public $language_cached;
public $language_default; public $language_default;
public $language_root; public $root_default;
public $root_custom;
public $language_file; public $language_file;
private $languages = [ private $languages = [
'en-US' => ['English', 'English'], 'en-US' => ['English', 'English'],
@ -118,18 +119,20 @@ class Language
'yo' => ['Yorùbá', 'Yoruba'], 'yo' => ['Yorùbá', 'Yoruba'],
'zu' => ['Zulu', 'Zulu'], 'zu' => ['Zulu', 'Zulu'],
]; ];
private $LANG; private $LANG = [];
private $domain; private $domain;
/** 构造函数 /** 构造函数
* @param string $language_root 翻译文件根目录 * @param string $root_default 翻译文件根目录
* @param string $root_custom 翻译文件自定义目录
* @param array $languages 可用语言列表 * @param array $languages 可用语言列表
* @param string $lang_default 默认语言 * @param string $lang_default 默认语言
* @return void * @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)) { if (!empty($lang_default) && array_key_exists($lang_default, $this->languages)) {
$this->language_default = $lang_default; $this->language_default = $lang_default;
$this->language_current = $lang_default; $this->language_current = $lang_default;
@ -189,17 +192,23 @@ class Language
private function has_language_file($lang) 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() private function init_language_file()
{ {
if ($this->has_language_file($this->language_current)) {
$this->language_file = $this->language_root . $this->language_current . '/' . 'language.php'; $default = $this->root_default . $this->language_current . '/language.php';
} else { $custom = $this->root_custom . $this->language_current . '/language.php';
$this->language_file = $this->language_root . $this->language_default . '/' . '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() public function get_languages_tags()

View file

@ -1,130 +1,5 @@
<?php <?php
return array( return array(
"home" => "主页", 'Country' => '国家',
"solution" => "方案", 'Phone Number' => '手机号码'
"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' => '管理中心'
); );