From d9b364556b444c3c331679c9278c00edb4ab908f Mon Sep 17 00:00:00 2001 From: printempw Date: Thu, 15 Sep 2016 23:03:58 +0800 Subject: [PATCH] working on i18n of user center --- app/Services/Utils.php | 5 -- config/menu.php | 24 +++--- resources/lang/en/auth.yml | 67 ++++++++++++---- resources/lang/en/general.yml | 38 ++++++++++ resources/lang/en/locale.js | 70 +++++++++++++++++ resources/lang/en/user.yml | 107 ++++++++++++++++++++++++++ resources/lang/zh-CN/general.yml | 38 ++++++++++ resources/lang/zh-CN/index.yml | 7 -- resources/lang/zh-CN/locale.js | 30 ++++++++ resources/lang/zh-CN/user.yml | 114 ++++++++++++++++++++++++++++ resources/src/js/user.js | 88 +++++++-------------- resources/src/js/utils.js | 12 ++- resources/views/admin/customize.tpl | 12 +-- resources/views/admin/index.tpl | 4 +- resources/views/admin/master.tpl | 42 +++++----- resources/views/admin/options.tpl | 24 +++--- resources/views/admin/score.tpl | 16 ++-- resources/views/admin/update.tpl | 4 +- resources/views/auth/bind.tpl | 2 +- resources/views/auth/forgot.tpl | 2 +- resources/views/auth/login.tpl | 2 +- resources/views/auth/mail.tpl | 4 +- resources/views/auth/master.tpl | 2 +- resources/views/auth/register.tpl | 4 +- resources/views/auth/reset.tpl | 2 +- resources/views/index.tpl | 110 +++++++++++++-------------- resources/views/skinlib/master.tpl | 20 ++--- resources/views/skinlib/show.tpl | 4 +- resources/views/skinlib/upload.tpl | 2 +- resources/views/user/closet.tpl | 46 ++++++----- resources/views/user/config.tpl | 68 ++++++++++++----- resources/views/user/index.tpl | 55 ++++++-------- resources/views/user/master.tpl | 42 +++++----- resources/views/user/player.tpl | 58 +++++++------- resources/views/user/profile.tpl | 55 +++++++------- 35 files changed, 786 insertions(+), 394 deletions(-) create mode 100644 resources/lang/en/general.yml create mode 100644 resources/lang/en/locale.js create mode 100644 resources/lang/en/user.yml create mode 100644 resources/lang/zh-CN/general.yml delete mode 100644 resources/lang/zh-CN/index.yml create mode 100644 resources/lang/zh-CN/user.yml diff --git a/app/Services/Utils.php b/app/Services/Utils.php index 0538cc5c..9ce07534 100644 --- a/app/Services/Utils.php +++ b/app/Services/Utils.php @@ -79,11 +79,6 @@ class Utils return ($timestamp == 0) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $timestamp); } - public static function getNameOrEmail(\App\Models\User $user) - { - return ($user->getNickName() == '') ? $user->email : $user->getNickName(); - } - /** * Replace content of string according to given rules * diff --git a/config/menu.php b/config/menu.php index 53a066d2..d857a5f9 100644 --- a/config/menu.php +++ b/config/menu.php @@ -9,21 +9,21 @@ */ $menu['user'] = array( - 1 => ['title' => '仪表盘', 'link' => '/user', 'icon' => 'fa-dashboard'], - 2 => ['title' => '我的衣柜', 'link' => '/user/closet', 'icon' => 'fa-star'], - 3 => ['title' => '角色管理', 'link' => '/user/player', 'icon' => 'fa-users'], - 4 => ['title' => '配置生成', 'link' => '/user/config', 'icon' => 'fa-book'], - 5 => ['title' => '个人资料', 'link' => '/user/profile', 'icon' => 'fa-user'] + ['title' => 'general.dashboard', 'link' => '/user', 'icon' => 'fa-dashboard'], + ['title' => 'general.my-closet', 'link' => '/user/closet', 'icon' => 'fa-star'], + ['title' => 'general.player-manage', 'link' => '/user/player', 'icon' => 'fa-users'], + ['title' => 'general.generate-config', 'link' => '/user/config', 'icon' => 'fa-book'], + ['title' => 'general.profile', 'link' => '/user/profile', 'icon' => 'fa-user'] ); $menu['admin'] = array( - 1 => ['title' => '仪表盘', 'link' => '/admin', 'icon' => 'fa-dashboard'], - 2 => ['title' => '用户管理', 'link' => '/admin/users', 'icon' => 'fa-users'], - 3 => ['title' => '角色管理', 'link' => '/admin/players', 'icon' => 'fa-gamepad'], - 4 => ['title' => '个性化', 'link' => '/admin/customize', 'icon' => 'fa-paint-brush'], - 5 => ['title' => '积分配置', 'link' => '/admin/score', 'icon' => 'fa-credit-card'], - 6 => ['title' => '站点配置', 'link' => '/admin/options', 'icon' => 'fa-cog'], - 7 => ['title' => '检查更新', 'link' => '/admin/update', 'icon' => 'fa-arrow-up'] + ['title' => 'general.dashboard', 'link' => '/admin', 'icon' => 'fa-dashboard'], + ['title' => 'general.user-manage', 'link' => '/admin/users', 'icon' => 'fa-users'], + ['title' => 'general.player-manage', 'link' => '/admin/players', 'icon' => 'fa-gamepad'], + ['title' => 'general.customize', 'link' => '/admin/customize', 'icon' => 'fa-paint-brush'], + ['title' => 'general.score-options', 'link' => '/admin/score', 'icon' => 'fa-credit-card'], + ['title' => 'general.options', 'link' => '/admin/options', 'icon' => 'fa-cog'], + ['title' => 'general.check-update', 'link' => '/admin/update', 'icon' => 'fa-arrow-up'] ); return $menu; diff --git a/resources/lang/en/auth.yml b/resources/lang/en/auth.yml index 586f414e..05dfba29 100644 --- a/resources/lang/en/auth.yml +++ b/resources/lang/en/auth.yml @@ -1,41 +1,76 @@ login: - login: Log In + title: Log In + button: Log In message: Log in to manage your skin & players keep: Remember me + success: Logged in successfully~ + +check: + anonymous: Illegal access. Please log in first. + banned: You are banned on this site. Please contact the admin. + token: Invalid token. Please log in. register: - register: Register - message: Welcome to :sitename + title: Register + button: Register + message: Welcome to :sitename! nickname-intro: Whatever you like expect special characters repeat-pwd: Repeat your password + close: Well, this site doesn't allow any register. + success: Registered successfully. Redirecting... + max: You can't register more than :regs accounts. + registered: The email address is already registered. forgot: - forgot: Reset Password - message: We will send you an E-mail to verify - send: Send + title: Forgot Password + button: Send + message: We will send you an E-mail to verify. login-link: I do remember it + close: Password resetting is not available now. + frequent-mail: You click the send button too fast. Wait for 60 secs, guy. + unregistered: The email address is not registered. mail: + title: Reset your password on :sitename + success: Mail is sent. Will be expired in 1 hour, please check. + failed: Fail to send mail, detailed message :msg message: You are receiving this email because this email address was used to reset your password on :sitename ignore: If you haven't signed up on our site, please ignore this email. No unsubscribing is required. reset: Reset your password notice: This mail is sending automatically, no reponses will be sent if you reply. reset: - reset: Reset - message: :username, reset your email address here + title: Reset Password + button: Reset + invalid: Invalid link. + expired: This link is expired. + message: :username, reset your email address here. + success: Password resetted successfully. bind: - bind: Bind - message: You need to fill your email adderss to continue + title: Bind Email + button: Bind + message: You need to fill your email adderss to continue. introduction: Email addresses will be used for password resetting. We won't send you any spam. + registered: The email address is already registered. + +validation: + identification: Invalid format of email or player name. + email: Email format is invalid. + captcha: Wrong CAPTCHA. + user: Unexistent user. + password: Wrong email or password. + +logout: + success: Logged out successfully~ + fail: No valid session. nickname: Nickname -email: Email Address -identification: Email or Player Name +email: Email +identification: Email or player name password: Password -captcha: Enter the CAPTCHA -change-captcha: Click to change another image. -login-link: Already have an account? +captcha: Please enter the CAPTCHA. +change-captcha: Click to change CAPTCHA image. +login-link: Already registered? Log in here. forgot-link: Forgot your password? -register-link: Register a new account +register-link: Register new account diff --git a/resources/lang/en/general.yml b/resources/lang/en/general.yml new file mode 100644 index 00000000..1cb6921c --- /dev/null +++ b/resources/lang/en/general.yml @@ -0,0 +1,38 @@ +index: Homepage +skinlib: Skin Library +langs: Language +user-center: User Center +logout: Log Out +login: Log In +register: Register Now +profile: User Profile +online: Online +admin-panel: Admin Panel +explore: Explore +manage: Manage +anonymous: Guest +back: Back +dashboard: Dashboard +my-closet: Closet +player-manage: Player Manage +user-manage: User Manage +generate-config: Generate Config +customize: Customize +options: Options +score-options: Score Options +check-update: Check Update +close: Close +skin: Skin +cape: Cape + +pagination: Page :page, total :total + +texture-preview: Texture Preview +walk: Walk +run: Run +rotation: Rotation + +submit: Submit + +notice: Notice +switch-2d-preview: Switch to 2D Preview diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js new file mode 100644 index 00000000..7e8ae450 --- /dev/null +++ b/resources/lang/en/locale.js @@ -0,0 +1,70 @@ +/*! + * Blessing Skin English Translations + * + * @see https://github.com/printempw/blessing-skin-server + * @author printempw + * + * NOTE: this file must be saved in UTF-8 encoding. + */ + +(function ($) { + "use strict"; + + $.locales['zh-CN'] = { + auth: { + emptyIdentification: 'Empty email/player name.', + emptyPassword: 'Password is required.', + emptyCaptcha: 'Empty password.', + login: 'Log In', + loggingIn: 'Logging In', + tooManyFails: 'You fails too many times! Please enter the CAPTCHA.', + emptyEmail: 'Empty email address.', + invalidEmail: 'Invalid format of email address.', + invalidPassword: 'Invalid password. The length of password should between 8 and 16.', + emptyConfirmPwd: 'Empty confirming password.', + invalidConfirmPwd: 'Confirming password is not equal with password.', + emptyNickname: 'Empty nickname.', + register: 'Register', + registering: 'Registering', + send: 'Send', + sending: 'Sending', + reset: 'Reset', + resetting: 'Resetting' + }, + user: { + switch2dPreview: 'Switch to 2D Preview', + switch3dPreview: 'Switch to 3D Preview', + removeFromCloset: 'Sure to remove this from your closet?', + setAvatar: 'Sure to set this as your avatar?', + setAvatarNotice: 'The head segment of skin will bu used.', + noSelectedPlayer: 'No player is selected.', + noSelectedTexture: 'No texture is selected.', + changePlayerName: 'Please enter the player name:', + playerNameRule: 'The player name may only contain letters, numbers, and dashes. Chinese characters supporting is depended on option of this site.', + emptyPlayerName: 'Empty player name.', + clearTexture: 'Sure to clear the skins & cape of this player?', + deletePlayer: 'Sure to delete this player?', + deletePlayerNotice: 'It\'s permanent. No backups.', + emptyNewNickName: 'Empty new nickname.', + changeNickName: 'SUre to set your nickname to :new_nickname?', + emptyPassword: 'Original password is required.', + emptyNewPassword: 'Empty new password.', + emptyNewEmail: 'Empty new email address.', + changeEmail: 'Sure to change your email address to :new_email?', + emptyDeletePassword: 'Please enter the current password:', + signRemainTime: 'Can sign after :time hours', + }, + config: { + csl13_1Upper: 'v13.1 and upper (recommended)', + csl13_1Lower: 'lower than v13.1', + usm1_4Upper: 'v1.4 and upper (recommended)', + usm1_2To1_3: 'v1.2 to v1.3', + usm1_2Lower: 'lower than v1.2', + }, + general: { + confirmLogout: 'Sure to log out?', + confirm: 'OK', + cancel: 'Cancel' + } + }; +})(window.jQuery); diff --git a/resources/lang/en/user.yml b/resources/lang/en/user.yml new file mode 100644 index 00000000..b2bfdd5b --- /dev/null +++ b/resources/lang/en/user.yml @@ -0,0 +1,107 @@ +used: + title: Resources Used + players: Registered players + storage: Storage used + +cur-score: Current Score +score-notice: Click the score to show introduction. +sign: Sign In +last-sign: Last signed in at :time +remain-time: Can sign in after :time hours +announcement: Announcement + +score-intro: + title: What is score? + introduction: | + We use score system to prevent the behaviors like uplaoding huge amount of textures and registering players casually. + Both adding players and uplaoding textures will consume your score. The score will be returned if you deleted them. + Adding textures from skin library to your closet will not decline your score. + + The inital score of user on this site is :initial_score, you can acquire :score-from ~ :score-to scores by signing in. + rates: + storage: :score scores = 1 KB storage + player: :score scores = 1 player + +closet: + upload: Uplaod Texture + search: Search Texture + switch-category: Switch Category + view: View in skin librariy + more: More + remove: Remove from closet + set-avatar: Set as avatar + empty-msg: | +

Nothing in your closet...

+

Why not explore the Skin Library for a while?

+ + use-as: + button: Apply... + title: Which player should be applied to? + empty: It seems that you own no player... + add: Add new player + +player: + player-name: Player Name + preference: Preference + edit: Edit + operation: Delete + edit-pname: Player name + delete-texture: Textures + delete-player: Player + add-player: Add new player + + login-notice: Now you can log in with player names you owned instead email address. + + player-info: Information (click player name to show preview) + + textures: + steve: Steve Model: + alex: Alex Model: + cape: Cape: + empty: Nothing + + pname-rule: Could only contain letters, numbers and dashes. + pname-rule-chinese: Could only contain chinese characters, letters, numbers and dashes. + +profile: + change-avatar: Change Avatar? + avatar-notice: Click the gear icon「」of any skin in your skinlib, then click 「Set as avatar」. We will cut the head segment of that skin for you. + + password: + title: Change Password + old: Old Password + new: New Password + confirm: Repeat Password + button: Change Password + + nickname: + title: Change Nickname + empty: No nickname is setted now. + rule: Whatever you like expect special characters + + email: + title: Change Email + new: New Email + password: Current Password + button: Change Email + + delete: + title: Delete Account + notice: Sure to delete your account on :sitename? + admin: Admin account can not be deleted. + button: Delete My Account + + modal-title: You need to enter your password to continue + modal-notice: | + You're about to delete your account. + This is permanent! No backups, no restores, no magic undo button. + We warned you, ok? + password: Current Password + +config: + mod-requirement: MOD Requirement + mod-intro: | +

We support all versions of UniSkinMod and CustomSkinLoader, and any other skin mod using with leagcy links.

+

Detailed Documentation Here: @GitHub

+ version: Version + config-file: Config File diff --git a/resources/lang/zh-CN/general.yml b/resources/lang/zh-CN/general.yml new file mode 100644 index 00000000..e54190e3 --- /dev/null +++ b/resources/lang/zh-CN/general.yml @@ -0,0 +1,38 @@ +index: 首页 +skinlib: 皮肤库 +langs: 语言 +user-center: 用户中心 +logout: 登出 +login: 登录 +register: 现在注册 +profile: 个人资料 +online: 在线 +admin-panel: 管理面板 +explore: 浏览 +manage: 管理 +anonymous: 未登录 +back: 返回 +dashboard: 仪表盘 +my-closet: 我的衣柜 +player-manage: 角色管理 +user-manage: 用户管理 +generate-config: 配置生成 +customize: 个性化 +options: 站点配置 +score-options: 积分配置 +check-update: 检查更新 +close: 关闭 +skin: 皮肤 +cape: 披风 + +pagination: 第 :page 页,共 :total 页 + +texture-preview: 材质预览 +walk: 行走 +run: 奔跑 +rotation: 旋转 + +submit: 提交 + +notice: 提示 +switch-2d-preview: 切换 2D 预览 diff --git a/resources/lang/zh-CN/index.yml b/resources/lang/zh-CN/index.yml deleted file mode 100644 index 98c48f04..00000000 --- a/resources/lang/zh-CN/index.yml +++ /dev/null @@ -1,7 +0,0 @@ -index: 首页 -skinlib: 皮肤库 -langs: 语言 -user-center: 用户中心 -logout: 登出 -login: 登录 -register: 现在注册 diff --git a/resources/lang/zh-CN/locale.js b/resources/lang/zh-CN/locale.js index f6c16115..5eece609 100644 --- a/resources/lang/zh-CN/locale.js +++ b/resources/lang/zh-CN/locale.js @@ -31,6 +31,36 @@ reset: '重置', resetting: '重置中' }, + user: { + switch2dPreview: '切换 2D 预览', + switch3dPreview: '切换 3D 预览', + removeFromCloset: '确定要从衣柜中移除此材质吗?', + setAvatar: '确定要将此材质设置为用户头像吗?', + setAvatarNotice: '将会自动截取皮肤头部', + noSelectedPlayer: '你还没有选择角色哦', + noSelectedTexture: '你还没有选择要应用的材质哦', + changePlayerName: '请输入角色名:', + playerNameRule: '允许数字、字母以及下划线,是否支持中文角色名请参考本站设置', + emptyPlayerName: '你还没有填写名称哦', + clearTexture: '确定要重置该用户的皮肤/披风吗?', + deletePlayer: '真的要删除该玩家吗?', + deletePlayerNotice: '这将是永久性的删除', + emptyNewNickName: '你还没有填写新昵称啊', + changeNickName: '确定要将昵称设置为 :new_nickname 吗?', + emptyPassword: '原密码不能为空', + emptyNewPassword: '新密码要好好填哦', + emptyNewEmail: '你还没有填写新邮箱啊', + changeEmail: '确定要将用户邮箱更改为 :new_email 吗?', + emptyDeletePassword: '请先输入当前用户密码', + signRemainTime: ':time 小时后可签到', + }, + config: { + csl13_1Upper: '13.1 版及以上(推荐)', + csl13_1Lower: '13.1 版以下', + usm1_4Upper: '1.4 版及以上(推荐)', + usm1_2To1_3: '1.2 及 1.3 版', + usm1_2Lower: '1.2 版以下', + }, general: { confirmLogout: '确定要登出吗?', confirm: '确定', diff --git a/resources/lang/zh-CN/user.yml b/resources/lang/zh-CN/user.yml new file mode 100644 index 00000000..bee84381 --- /dev/null +++ b/resources/lang/zh-CN/user.yml @@ -0,0 +1,114 @@ +used: + title: 使用情况 + players: 角色数量 + storage: 存储空间 + +cur-score: 当前积分 +score-notice: 点击积分查看说明 +sign: 每日签到 +last-sign: 上次签到于 :time +remain-time: :time 小时后可签到 +announcement: 公告 + +score-intro: + title: 积分是个啥? + introduction: | + 「既然你诚心诚意地发问了!」 + 「那我们就大发慈悲地告诉你!」 + 「为了守护皮肤站的和平」 + 「为了防止皮肤站被破坏」 + 「贯彻爱与真实的。。呸!」上面只是卖下萌~ + + 为了不出现用户一个劲上传材质导致存储空间爆满,我们决定启用积分系统。 + 添加角色以及上传材质都会消耗积分,而删除已经添加的角色和已上传的材质时积分将会被返还。 + + 本站用户初始积分为 :initial_score,每日签到可以随机获得 :score-from ~ :score-to 积分 + 添加皮肤库里的材质到衣柜不消耗积分。 + rates: + storage: :score 积分 = 1 KB 存储空间 + player: :score 积分 = 1 个角色 + +closet: + upload: 上传材质 + search: 搜索材质 + switch-category: 切换分类 + view: 在皮肤库中查看 + more: 更多 + remove: 从衣柜中移除 + set-avatar: 设为头像 + empty-msg: | +

衣柜里啥都没有哦~

+

皮肤库看看吧~

+ + use-as: + button: 使用... + title: 要给哪个角色使用呢? + empty: 你好像还没有添加任何角色哦 + add: 添加角色 + +player: + player-name: 角色名称 + preference: 优先模型 + edit: 编辑 + operation: 操作 + edit-pname: 修改角色名 + delete-texture: 删除材质 + delete-player: 删除角色 + add-player: 添加新角色 + + login-notice: 你现在可以使用你所拥有的角色名来登录皮肤站啦~ + + player-info: 角色信息 (点击角色名以查看预览) + + textures: + steve: Steve 模型的皮肤: + alex: Alex 模型的皮肤: + cape: 披风: + empty: 未上传 + + pname-rule: 只能包含数字、字母以及下划线 + pname-rule-chinese: 可使用汉字,字母数字以及下划线 + +profile: + change-avatar: 更改头像? + avatar-notice: 请在衣柜中任意皮肤的右下角「」处选择「设为头像」,将会自动截取该皮肤的头部作为头像哦~ + + password: + title: 更改密码 + old: 旧的密码 + new: 新密码 + confirm: 确认密码 + button: 修改密码 + + nickname: + title: 更改昵称 + empty: 当前未设置昵称, + rule: 可使用除一些特殊符号外的任意字符 + + email: + title: 更改邮箱 + new: 新邮箱 + password: 当前密码 + button: 修改邮箱 + + delete: + title: 删除账号 + notice: 确定要删除你在 :sitename 上的账号吗? + admin: 管理员账号不能被删除哟 + button: 删除我的账户 + + modal-title: 这是危险操作,输入密码以继续 + modal-notice: | + 此操作不可恢复! + 你所上传至皮肤库的材质仍会被保留,但你的角色将被永久删除。 + 我们不提供任何备份,或者神奇的撤销按钮。 + 我们警告过你了,确定要这样做吗? + password: 当前密码 + +config: + mod-requirement: MOD 需求 + mod-intro: | +

本站支持的皮肤 MOD 有 UniSkinModCustomSkinLoader 各自的新版和旧版,以及任何支持传统皮肤加载链接的皮肤 MOD。

+

详细教程:@GitHub

+ version: 版本 + config-file: 配置文件 diff --git a/resources/src/js/user.js b/resources/src/js/user.js index 593e5c8b..657c7238 100644 --- a/resources/src/js/user.js +++ b/resources/src/js/user.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-16 10:02:24 * @Last Modified by: printempw - * @Last Modified time: 2016-09-10 21:42:29 + * @Last Modified time: 2016-09-15 21:26:27 */ 'use strict'; @@ -95,7 +95,7 @@ function show2dPreview() { $('#preview-msg').remove(); $('.operations').hide(); $('#preview-2d').show(); - $('#preview-switch').html('切换 3D 预览').attr('onclick', 'show3dPreview();'); + $('#preview-switch').html(trans('user.switch3dPreview')).attr('onclick', 'show3dPreview();'); } function show3dPreview() { @@ -106,7 +106,7 @@ function show3dPreview() { init3dCanvas(); $('#preview-2d').hide(); $('.operations').show(); - $('#preview-switch').html('切换 2D 预览').attr('onclick', 'show2dPreview();'); + $('#preview-switch').html(trans('user.switch2dPreview')).attr('onclick', 'show2dPreview();'); } // Change 3D preview status @@ -147,7 +147,7 @@ $('body').on('click', '.item', function() { function removeFromCloset(tid) { swal({ - text: '确定要从衣柜中移除此材质吗?', + text: trans('user.removeFromCloset'), type: 'warning', showCancelButton: true }).then(function() { @@ -175,8 +175,8 @@ function removeFromCloset(tid) { function setAsAvatar(tid) { swal({ - title: '确定要将此材质设置为用户头像吗?', - text: '将会自动截取皮肤头部', + title: trans('user.setAvatar'), + text: trans('user.setAvatarNotice'), type: 'question', showCancelButton: true }).then(function() { @@ -206,8 +206,8 @@ $(document).ready(function() { radioClass: 'iradio_square-blue' }); swal.setDefaults({ - confirmButtonText: '确定', - cancelButtonText: '取消' + confirmButtonText: trans('general.confirm'), + cancelButtonText: trans('general.cancel') }); }); @@ -221,9 +221,9 @@ function setTexture() { var tid = $('.item-selected').attr('tid'); if (!pid) { - toastr.info('你还没有选择角色哦'); + toastr.info(trans('user.noSelectedPlayer')); } else if (!tid) { - toastr.info('你还没有选择要应用的材质哦'); + toastr.info(trans('user.noSelectedTexture')); } else { $.ajax({ type: "POST", @@ -241,9 +241,7 @@ function setTexture() { toastr.warning(json.msg); } }, - error: function(json) { - showModal(json.responseText.replace(/\n/g, '
'), 'Fatal Error(请联系作者)', 'danger'); - } + error: showAjaxError }); } } @@ -266,10 +264,10 @@ $('body').on('change', '#preference', function() { }); }); -function changePlayerMame(pid, current_player_name) { +function changePlayerName(pid, current_player_name) { swal({ - title: '请输入角色名:', - text: '允许数字、字母以及下划线,是否支持中文角色名请参考本站设置', + title: trans('user.changePlayerName'), + text: trans('user.playerNameRule'), inputValue: current_player_name, input: 'text', showCancelButton: true, @@ -278,7 +276,7 @@ function changePlayerMame(pid, current_player_name) { if (value) { resolve(); } else { - reject('你还没有填写名称哦'); + reject(trans('user.emptyPlayerName')); } }); } @@ -309,7 +307,7 @@ function changePlayerMame(pid, current_player_name) { function clearTexture(pid) { swal({ - text: "确定要重置该用户的皮肤/披风吗?", + text: trans('user.clearTexture'), type: 'warning', showCancelButton: true }).then(function() { @@ -338,8 +336,8 @@ function clearTexture(pid) { function deletePlayer(pid) { swal({ - title: "真的要删除该玩家吗?", - text: "这将是永久性的删除", + title: trans('user.deletePlayer'), + text: trans('user.deletePlayerNotice'), type: 'warning', showCancelButton: true, cancelButtonColor: '#3085d6', @@ -399,13 +397,13 @@ function changeNickName() { if (!new_nickname) { swal({ type: 'error', - html: '你还没有填写新昵称啊' + html: trans('user.emptyNewNickname') }); return; } swal({ - text: '确定要将昵称设置为 ' + new_nickname + ' 吗?', + text: trans('user.changeNickName', { new_nickname: new_nickname }), type: 'question', showCancelButton: true }).then(function() { @@ -433,8 +431,6 @@ function changeNickName() { error: showAjaxError }); }); - - } function changePassword() { @@ -443,16 +439,16 @@ function changePassword() { var new_passwd = $('#new-passwd').val(); if (password == "") { - toastr.info('原密码不能为空'); + toastr.info(trans('user.emptyPassword')); $('#passwd').focus(); } else if (new_passwd == "") { - toastr.info('新密码要好好填哦'); + toastr.info(trans('user.emptyNewPassword')); $('#new-passwd').focus(); } else if ($('#confirm-pwd').val() == "") { - toastr.info('确认密码不能为空'); + toastr.info(trans('auth.emptyConfirmPwd')); $('#confirm-pwd').focus(); } else if (new_passwd != $('#confirm-pwd').val()) { - toastr.warning('新密码和确认的密码不一样诶?'); + toastr.warning(trans('auth.invalidConfirmPwd')); $('#confirm-pwd').focus(); } else { $.ajax({ @@ -498,7 +494,7 @@ function changeEmail() { if (!new_email) { swal({ type: 'error', - html: '你还没有填写新邮箱啊' + html: trans('user.emptyNewEmail') }); return; } @@ -506,12 +502,12 @@ function changeEmail() { if (!/\S+@\S+\.\S+/.test(new_email)) { swal({ type: 'warning', - html: '邮箱格式不正确' + html: trans('auth.invalidEmail') }); return; } swal({ - text: '确定要将用户邮箱更改为 '+new_email+' 吗?', + text: trans('user.changeEmail', { new_email: new_email }), type: 'question', showCancelButton: true }).then(function() { @@ -548,7 +544,7 @@ function deleteAccount() { if (!password) { swal({ type: 'warning', - html: '请先输入当前用户密码' + html: trans('user.emptyDeletePassword') }); return; } @@ -576,32 +572,6 @@ function deleteAccount() { }); } -$('#mod-select').change(function() { - $('#version-select').children().each(function() { $(this).remove(); }); - - if ($(this).val() == "csl") { - $('#version-select').append(''); - $('#version-select').append(''); - } else if ($(this).val() == "usm") { - $('#version-select').append(''); - $('#version-select').append(''); - $('#version-select').append(''); - } - - showConfig(); -}); - -function showConfig() { - $('#config-13_1-upper').hide(); - $('#config-13_1-lower').hide(); - $('#config-1_4-upper').hide(); - $('#config-1_2-1_3').hide(); - $('#config-1_2-lower').hide(); - $('#config-'+$('#version-select').val()).show(); -} - -$('#version-select').change(showConfig); - function sign() { $.ajax({ type: "POST", @@ -614,7 +584,7 @@ function sign() { html: json.msg }).then(function() { $('#score').html(json.score); - var dom = '  '+json.remaining_time+' 小时后可签到'; + var dom = '  ' + trans('user.signRemainTime', { time: json.remaining_time }); $('#sign-button').attr('disabled', 'disabled').html(dom); }); } else { diff --git a/resources/src/js/utils.js b/resources/src/js/utils.js index 6a583c6b..af2e18fb 100644 --- a/resources/src/js/utils.js +++ b/resources/src/js/utils.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-16 09:02:32 * @Last Modified by: printempw - * @Last Modified time: 2016-09-15 10:39:49 + * @Last Modified time: 2016-09-15 21:48:24 */ $.locales = {}; @@ -42,11 +42,13 @@ function loadLocales() { } } -function trans(key) { +function trans(key, parameters) { if (isEmpty(locale)) { loadLocales(); } + parameters = parameters || {}; + var segments = key.split('.'); var temp = locale || {}; @@ -58,6 +60,12 @@ function trans(key) { } } + for (i in parameters) { + if (!isEmpty(parameters[i])) { + temp = temp.replace(':'+i, parameters[i]); + } + } + return temp; } diff --git a/resources/views/admin/customize.tpl b/resources/views/admin/customize.tpl index 735c0e86..06f14395 100644 --- a/resources/views/admin/customize.tpl +++ b/resources/views/admin/customize.tpl @@ -111,7 +111,7 @@ 首页图片地址 - + @@ -120,14 +120,14 @@ 版权文字 - +

自定义版权文字内可使用占位符,{site_name} 将会被自动替换为站点名称,{site_url} 会被替换为站点地址。

@@ -162,13 +162,13 @@ CSS - + JavaScript - + @@ -188,7 +188,7 @@ @endsection diff --git a/resources/views/admin/index.tpl b/resources/views/admin/index.tpl index 96a799e8..627eeeb0 100644 --- a/resources/views/admin/index.tpl +++ b/resources/views/admin/index.tpl @@ -1,6 +1,6 @@ @extends('admin.master') -@section('title', '仪表盘') +@section('title', trans('general.dashboard')) @section('content') @@ -9,7 +9,7 @@

- 仪表盘 + {{ trans('general.dashboard') }} Dashboard

diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index aeba4fa4..438f3804 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -3,7 +3,7 @@ - @yield('title') - {{ Option::get('site_name') }} + @yield('title') - {{ option('site_name') }} @@ -15,18 +15,18 @@ - +
-

{{ Utils::getNameOrEmail($user) }}

- Online +

{{ bs_nickname($user) }}

+ {{ trans('general.online') }}
@@ -119,14 +111,14 @@
- @if (Option::get('show_footer_copyright')) + @if (option('show_footer_copyright')) @endif - {!! Utils::getStringReplaced(Option::get('copyright_text'), ['{site_name}' => Option::get('site_name'), '{site_url}' => Option::get('site_url')]) !!} + {!! bs_copyright() !!}
@@ -134,7 +126,7 @@ {!! bs_footer('admin') !!} - @if (Option::get('check_update') == '1') + @if (option('check_update') == '1') @endsection diff --git a/resources/views/user/index.tpl b/resources/views/user/index.tpl index 2cb7b9ae..90a2a696 100644 --- a/resources/views/user/index.tpl +++ b/resources/views/user/index.tpl @@ -1,6 +1,6 @@ @extends('user.master') -@section('title', '仪表盘') +@section('title', trans('general.dashboard')) @section('content') @@ -9,7 +9,7 @@

- 仪表盘 + {{ trans('general.dashboard') }} Dashboard

@@ -25,15 +25,15 @@
-

使用情况

+

{{ trans('user.used.title') }}

- 角色数量 + {{ trans('user.used.players') }} getPlayers()) + floor($user->getScore() / Option::get('score_per_player')); + $players_available = count($user->getPlayers()) + floor($user->getScore() / option('score_per_player')); $percent = ($players_available == 0) ? 0 : count($user->getPlayers()) / $players_available * 100 ?> {{ count($user->getPlayers()) }}/{{ $players_available }} @@ -42,8 +42,8 @@
- 存储空间 - + {{ trans('user.used.storage') }} + @if ($user->getStorageUsed() > 1024) {{ round($user->getStorageUsed() / 1024, 1) }}/ @@ -63,23 +63,23 @@

- 当前积分 + {{ trans('user.cur-score') }}

{{ $user->getScore() }}

-

点击积分查看说明

+

{{ trans('user.score-notice') }}

@@ -89,10 +89,10 @@
-

公告

+

{{ trans('user.announcement') }}

- {!! nl2br(Option::get('announcement')) !!} + {!! nl2br(option('announcement')) !!}
@@ -107,36 +107,29 @@
diff --git a/resources/views/user/master.tpl b/resources/views/user/master.tpl index 75e69ed5..ebf4cede 100644 --- a/resources/views/user/master.tpl +++ b/resources/views/user/master.tpl @@ -3,7 +3,7 @@ - @yield('title') - {{ Option::get('site_name') }} + @yield('title') - {{ option('site_name') }} @@ -13,18 +13,18 @@ @yield('style') - +
-

{{ Utils::getNameOrEmail($user) }}

- Online +

{{ bs_nickname($user) }}

+ {{ trans('general.online') }}
@@ -120,14 +114,14 @@
- @if (Option::get('show_footer_copyright')) + @if (option('show_footer_copyright')) @endif - {!! Utils::getStringReplaced(Option::get('copyright_text'), ['{site_name}' => Option::get('site_name'), '{site_url}' => Option::get('site_url')]) !!} + {!! bs_copyright() !!}
diff --git a/resources/views/user/player.tpl b/resources/views/user/player.tpl index b4ddbcbf..93da28d0 100644 --- a/resources/views/user/player.tpl +++ b/resources/views/user/player.tpl @@ -1,6 +1,6 @@ @extends('user.master') -@section('title', '角色管理') +@section('title', trans('general.player-manage')) @section('content') @@ -9,7 +9,7 @@

- 角色管理 + {{ trans('general.player-manage') }} Player Management

@@ -24,10 +24,10 @@ PID - 角色名称 - 优先模型 - 编辑 - 操作 + {{ trans('user.player.player-name') }} + {{ trans('user.player.preference') }} + {{ trans('user.player.edit') }} + {{ trans('user.player.operation') }} @@ -43,11 +43,11 @@ - 修改角色名 + {{ trans('user.player.edit-pname') }} - 删除材质 - 删除角色 + {{ trans('user.player.delete-texture') }} + {{ trans('user.player.delete-player') }} @endforeach @@ -56,54 +56,53 @@
-

提示

+

{{ trans('general.notice') }}

-

你现在可以使用你所拥有的角色名来登录皮肤站啦~

+

{{ trans('user.player.login-notice') }}

-

角色信息 - (点击角色名以查看预览) +

{!! trans('user.player.player-info') !!}
- - - + + +

-

Steve 模型的皮肤: - 未上传 +

{{ trans('user.player.textures.steve') }} + {{ trans('user.player.textures.empty') }}

-

Alex 模型的皮肤: - 未上传 +

{{ trans('user.player.textures.alex') }} + {{ trans('user.player.textures.empty') }}

-

披风: - 未上传 +

{{ trans('user.player.textures.cape') }} + {{ trans('user.player.textures.empty') }}

@@ -117,25 +116,25 @@ @@ -149,7 +148,6 @@ @section('script')