working on i18n of controllers

This commit is contained in:
printempw 2016-09-24 22:49:20 +08:00
parent 1cdfb139c1
commit effa0a42df
22 changed files with 461 additions and 176 deletions

View File

@ -59,9 +59,9 @@ class ClosetController extends Controller
$t->likes += 1;
$t->save();
return json('材质 '.$request->input('name').' 收藏成功~', 0);
return json(trans('user.closet.add.success', ['name' => $request->input('name')]), 0);
} else {
return json('你已经收藏过这个材质啦', 1);
return json(trans('user.closet.add.repeated'), 1);
}
}
@ -76,9 +76,9 @@ class ClosetController extends Controller
$t->likes = $t->likes - 1;
$t->save();
return json('材质已从衣柜中移除', 0);
return json(trans('user.closet.remove.success'), 0);
} else {
return json('衣柜中不存在此材质', 0);
return json(trans('user.closet.remove.non-existent'), 0);
}
}

View File

@ -52,10 +52,10 @@ class PlayerController extends Controller
$player_name = $request->input('player_name');
if (!PlayerModel::where('player_name', $player_name)->get()->isEmpty())
return json('该角色名已经被其他人注册掉啦', 6);
return json(trans('user.player.add.repeated'), 6);
if ($this->user->getScore() < Option::get('score_per_player'))
return json('积分不够添加角色啦', 7);
return json(trans('user.player.add.lack-score'), 7);
$player = new PlayerModel();
$player->uid = $this->user->uid;
@ -68,7 +68,7 @@ class PlayerController extends Controller
$this->user->setScore(Option::get('score_per_player'), 'minus');
return json("成功添加了角色 $player_name", 0);
return json(trans('user.player.add.success', ['name' => $player_name]), 0);
}
public function delete(Request $request)
@ -78,7 +78,7 @@ class PlayerController extends Controller
if ($this->player->delete()) {
$this->user->setScore(Option::get('score_per_player'), 'plus');
return json("角色 $player_name 已被删除", 0);
return json("trans('user.player.delete.success', ['name' => $player_name])", 0);
}
}
@ -96,12 +96,12 @@ class PlayerController extends Controller
$new_player_name = $request->input('new_player_name');
if (!PlayerModel::where('player_name', $new_player_name)->get()->isEmpty())
return json('此角色名已被他人使用,换一个吧~', 6);
return json(trans('user.player.rename.repeated'), 6);
$old_player_name = $this->player->player_name;
$this->player->rename($new_player_name);
return json("角色 $old_player_name 已更名为 $new_player_name", 0);
return json(trans('user.player.rename.success', ['old' => $old_player_name, 'new' => $new_player_name]), 0);
}
/**
@ -114,20 +114,20 @@ class PlayerController extends Controller
]);
if (!($texture = Texture::find($request->tid)))
return json('材质不存在', 6);
return json(trans('skinlib.un-existent'), 6);
$field_name = "tid_{$texture->type}";
$this->player->setTexture([$field_name => $request->tid]);
return json('材质已成功应用至角色 '.$this->player->player_name, 0);
return json(trans('user.player.set.success', ['name' => $this->player->player_name]), 0);
}
public function clearTexture()
{
$this->player->clearTexture();
return json('角色 '.$this->player->player_name.' 的材质已被成功重置', 0);
return json(trans('user.player.clear.success', ['name' => $this->player->player_name]), 0);
}
public function setPreference(Request $request)
@ -138,7 +138,7 @@ class PlayerController extends Controller
$this->player->setPreference($request->preference);
return json('角色 '.$this->player->player_name.' 的优先模型已更改至 '.$request->preference, 0);
return json(trans('user.player.preference.success', ['name' => $this->player->player_name, 'preference' => $request->preference]), 0);
}
}

View File

@ -32,7 +32,7 @@ class SkinlibController extends Controller
if ($filter == "skin") {
$textures = Texture::where(function($query) {
$query->where('type', '=', 'steve')
$query->where('type', '=', 'steve')
->orWhere('type', '=', 'alex');
})->orderBy($sort_by, 'desc');
@ -94,7 +94,7 @@ class SkinlibController extends Controller
public function show(Request $request)
{
$this->validate($request, [
'tid' => 'required|integer'
'tid' => 'required|integer'
]);
$texture = Texture::find($_GET['tid']);
@ -104,14 +104,14 @@ class SkinlibController extends Controller
if ($texture)
$texture->delete();
abort(404, '请求的材质文件已经被删除');
abort(404, trans('skinlib.show.deleted'));
}
abort(404, '请求的材质文件已经被删除,请联系管理员删除该条目');
abort(404, trans('skinlib.show.deleted').trans('skinlib.show.contact-admin'));
}
if ($texture->public == "0") {
if (is_null($this->user) || ($this->user->uid != $texture->uploader && !$this->user->is_admin))
abort(404, '请求的材质已经设为隐私,仅上传者和管理员可查看');
abort(404, trans('skinlib.show.private'));
}
return view('skinlib.show')->with('texture', $texture)->with('with_out_filter', true)->with('user', $this->user);
@ -144,7 +144,7 @@ class SkinlibController extends Controller
$cost = $t->size * (($t->public == "1") ? Option::get('score_per_storage') : Option::get('private_score_per_storage'));
if ($this->user->getScore() < $cost)
return json('积分不够啦', 7);
return json(trans('skinlib.upload.lack-score'), 7);
$results = Texture::where('hash', $t->hash)->get();
@ -153,7 +153,7 @@ class SkinlibController extends Controller
if ($result->type == $t->type) {
return json([
'errno' => 0,
'msg' => '已经有人上传过这个材质了,直接添加到衣柜使用吧~',
'msg' => trans('skinlib.upload.repeated'),
'tid' => $result->tid
]);
}
@ -167,7 +167,7 @@ class SkinlibController extends Controller
if ($this->user->closet->add($t->tid, $t->name)) {
return json([
'errno' => 0,
'msg' => '材质 '.$request->input('name').' 上传成功',
'msg' => trans('skinlib.upload.success', ['name' => $request->input('name')]),
'tid' => $t->tid
]);
}
@ -178,10 +178,10 @@ class SkinlibController extends Controller
$result = Texture::find($request->tid);
if (!$result)
return json('材质不存在', 1);
return json(trans('skinlib.non-existent'), 1);
if ($result->uploader != $this->user->uid && !$this->user->is_admin)
return json('你不是这个材质的上传者哦', 1);
return json(trans('skinlib.no-permission'), 1);
// check if file occupied
if (Texture::where('hash', $result['hash'])->count() == 1)
@ -190,7 +190,7 @@ class SkinlibController extends Controller
$this->user->setScore($result->size * Option::get('score_per_storage'), 'plus');
if ($result->delete())
return json('材质已被成功删除', 0);
return json(trans('skinlib.delete.success'), 0);
}
public function privacy($tid, Request $request)
@ -198,15 +198,15 @@ class SkinlibController extends Controller
$t = Texture::find($request->tid);
if (!$t)
return json('材质不存在', 1);
return json(trans('skinlib.non-existent'), 1);
if ($t->uploader != $this->user->uid && !$this->user->is_admin)
return json('你不是这个材质的上传者哦', 1);
return json(trans('skinlib.no-permission'), 1);
if ($t->setPrivacy(!$t->public)) {
return json([
'errno' => 0,
'msg' => '材质已被设为'.($t->public == "0" ? "隐私" : "公开"),
'msg' => trans('skinlib.privacy.success', ['privacy' => ($t->public == "0" ? trans('general.private') : trans('general.public'))]),
'public' => $t->public
]);
}
@ -221,15 +221,15 @@ class SkinlibController extends Controller
$t = Texture::find($request->input('tid'));
if (!$t)
return json('材质不存在', 1);
return json(trans('skinlib.non-existent'), 1);
if ($t->uploader != $this->user->uid && !$this->user->is_admin)
return json('你不是这个材质的上传者哦', 1);
return json(trans('skinlib.no-permission'), 1);
$t->name = $request->input('new_name');
if ($t->save()) {
return json('材质名称已被成功设置为'.$request->input('new_name'), 0);
return json(trans('skinlib.rename.success', ['name' => $request->input('new_name')]), 0);
}
}
@ -248,7 +248,7 @@ class SkinlibController extends Controller
]);
if ($_FILES['file']['type'] != "image/png" || $_FILES['file']['type'] != "image/x-png") {
return json("文件格式不对哦", 1);
return json(trans('skinlib.upload.type-error'), 1);
}
// if error occured while uploading file
@ -261,12 +261,12 @@ class SkinlibController extends Controller
if ($type == "steve" || $type == "alex") {
if ($ratio != 2 && $ratio != 1)
return json("不是有效的皮肤文件(宽 {$size[0]},高 {$size[1]}", 1);
return json(trans('skinlib.upload.invalid-size', ['type' => trans('general.skin'), 'width' => $size[0], 'height' => $size[1]]), 1);
} elseif ($type == "cape") {
if ($ratio != 2)
return json("不是有效的披风文件(宽 {$size[0]},高 {$size[1]}", 1);
return json(trans('skinlib.upload.invalid-size', ['type' => trans('general.cape'), 'width' => $size[0], 'height' => $size[1]]), 1);
} else {
return json('非法参数', 1);
return json(trans('general.illegal-parameters'), 1);
}
}

View File

@ -26,21 +26,21 @@ class UserController extends Controller
}
/**
* Handle User Signing
* Handle User Checking In
*
* @return void
*/
public function sign()
public function checkIn()
{
if ($aquired_score = $this->user->sign()) {
if ($aquired_score = $this->user->checkIn()) {
return json([
'errno' => 0,
'msg' => "签到成功,获得了 $aquired_score 积分~",
'msg' => trans('user.checkin-success', ['score' => $aquired_score]),
'score' => $this->user->getScore(),
'remaining_time' => $this->user->canSign(true)
'remaining_time' => $this->user->canCheckIn(true)
]);
} else {
return json($this->user->canSign(true).' 小时后才能再次签到哦~', 1);
return json(trans('user.cant-checkin-until', ['time' => $this->user->canCheckIn(true)]), 1);
}
}
@ -66,7 +66,7 @@ class UserController extends Controller
$nickname = $request->input('new_nickname');
if ($this->user->setNickName($nickname))
return json("昵称已成功设置为 $nickname", 0);
return json(trans('user.profile.nickname.success', ['nickname' => $nickname]), 0);
break;
@ -77,10 +77,10 @@ class UserController extends Controller
]);
if (!$this->user->checkPasswd($request->input('current_password')))
return json('原密码错误', 1);
return json(trans('user.profile.password.wrong-password'), 1);
if ($this->user->changePasswd($request->input('new_password')))
return json('密码修改成功,请重新登录', 0);
return json(trans('user.profile.password.success'), 0);
break;
@ -91,10 +91,10 @@ class UserController extends Controller
]);
if (!$this->user->checkPasswd($request->input('password')))
return json('密码错误', 1);
return json(trans('user.profile.email.wrong-password'), 1);
if ($this->user->setEmail($request->input('new_email')))
return json('邮箱修改成功,请重新登录', 0);
return json(trans('user.profile.email.success'), 0);
break;
@ -104,7 +104,7 @@ class UserController extends Controller
]);
if (!$this->user->checkPasswd($request->input('password')))
return json('密码错误', 1);
return json(trans('user.profile.delete.wrong-password'), 1);
if ($this->user->delete()) {
setcookie('uid', '', time() - 3600, '/');
@ -112,13 +112,13 @@ class UserController extends Controller
Session::flush();
return json('账号已被成功删除', 0);
return json(trans('user.profile.delete.success'), 0);
}
break;
default:
return json('非法参数', 1);
return json(trans('general.illegal-parameters'), 1);
break;
}
@ -144,13 +144,13 @@ class UserController extends Controller
if ($result) {
if ($result->type == "cape")
return json('披风可不能设置为头像哦~', 1);
return json(trans('user.profile.avatar.wrong-type'), 1);
if ($this->user->setAvatar($request->input('tid'))) {
return json('设置成功!', 0);
return json(trans('user.profile.avatar.success'), 0);
}
} else {
return json('材质不存在。', 1);
return json(trans('user.profile.avatar.non-existent'), 1);
}
}

View File

@ -21,7 +21,7 @@ class CheckPlayerExistMiddleware
Event::fire(new CheckPlayerExists($player_name));
if (PlayerModel::where('player_name', $player_name)->get()->isEmpty()) {
abort(404, '角色不存在');
abort(404, trans('general.unexistent-player'));
}
return $next($request);

View File

@ -14,7 +14,7 @@ class EncryptCookies extends BaseEncrypter
* @var array
*/
protected $except = [
//
'locale'
];
public function handle($request, Closure $next)

View File

@ -11,7 +11,7 @@ class RedirectIfAuthenticated
{
if (session()->has('uid')) {
if (session('token') != (new User(session('uid')))->getToken()) {
Session::put('msg', '无效的 token请重新登录~');
Session::put('msg', trans('auth.check.token'));
} else {
return redirect('user');
}

View File

@ -118,7 +118,7 @@ class User
public function getNickName()
{
if (!$this->is_registered) {
return "不存在的用户";
return trans('general.unexistent-user');
} else {
return ($this->model->nickname == "") ? $this->email : $this->model->nickname;
}
@ -174,9 +174,9 @@ class User
return $this->storage_used;
}
public function sign()
public function checkIn()
{
if ($this->canSign()) {
if ($this->canCheckIn()) {
$sign_score = explode(',', Option::get('sign_score'));
$aquired_score = rand($sign_score[0], $sign_score[1]);
$this->setScore($aquired_score, 'plus');
@ -188,7 +188,7 @@ class User
}
}
public function canSign($return_remaining_time = false)
public function canCheckIn($return_remaining_time = false)
{
// convert to timestamp
$last_sign_timestamp = strtotime($this->getLastSignTime());

View File

@ -36,3 +36,11 @@ submit: Submit
notice: Notice
switch-2d-preview: Switch to 2D Preview
illegal-parameters: Illegal parameters.
private: Private
public: Public
unexistent-user: Un-existent user
unexistent-player: Un-existent player.

View File

@ -1,5 +1,5 @@
/*!
* Blessing Skin English Translations
* Blessing Skin Chinese Translations
*
* @see https://github.com/printempw/blessing-skin-server
* @author printempw <h@prinzeugen.net>
@ -12,12 +12,15 @@
$.locales['zh-CN'] = {
auth: {
// Login
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.',
// Register
emptyEmail: 'Empty email address.',
invalidEmail: 'Invalid format of email address.',
invalidPassword: 'Invalid password. The length of password should between 8 and 16.',
@ -26,56 +29,70 @@
emptyNickname: 'Empty nickname.',
register: 'Register',
registering: 'Registering',
// Reset Password
send: 'Send',
sending: 'Sending',
reset: 'Reset',
resetting: 'Resetting'
},
skinlib: {
setSkinName: 'Please name your skin~',
removeFromCloset: 'Remove from closet.',
addToCloset: 'Add to closet.',
encodingError: 'Error: Encoding of this picture is incorrect.',
formatError: 'Error: Format of skin file must be PNG.',
chooseTextureType: 'Please choose type of texture.',
noUploadFile: 'You have not uploaded any file.',
setTextureName: 'Please name your texture.',
choosePNG: 'Please choose PNG picture file.',
// Like
addToCloset: 'Add to closet',
removeFromCloset: 'Remove from closet',
setItemName: 'Set a name for this texture',
emptyItemName: 'Empty texture name.',
// Rename
setNewTextureName: 'Please enter the new texture name:',
emptyNewTextureName: 'Empty new texture name.',
// Upload
emptyTextureName: 'Empty texture name.',
emptyTextureType: 'Please select a type for this texture.',
emptyUploadFile: 'You have not uploaded any file.',
encodingError: 'Error: Encoding of this file is not accepted.',
fileExtError: 'Error: Textures should be PNG files.',
upload: 'Upload',
uploading: 'Uploading',
redirecting: 'Redirecting...',
confirmUpload: 'Confirm uploading',
inputTextureName: 'Please input new name of texture.',
warningPublic: 'Are you sure to make this texture public?',
setPrivate: 'Make it private',
setPublic: 'Make it public',
warningDelete: 'Are you sure to delete this texture? Scores will be returned.'
// Change Privacy
setAsPrivate: 'Set as private',
setAsPublic: 'Set as public',
setPublicNotice: 'Sure to set this as public texture?',
deleteNotice: 'Are you sure to delete this texture? Scores will be returned.'
},
user: {
checkinRemainTime: 'Available after :time hours',
// Closet
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.',
removeFromClosetNotice: 'Sure to remove this texture from your closet?',
emptySelectedPlayer: 'No player is selected.',
emptySelectedTexture: 'No texture is selected.',
// Player
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.',
playerNameRule: 'The player name should only contain letters, numbers, and dashes.',
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.',
// Profile
setAvatar: 'Sure to set this as your avatar?',
setAvatarNotice: 'The head segment of skin will bu used.',
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'
emptyDeletePassword: 'Please enter the current password:'
},
utils: {
fatalError: 'Fatal Error (Please contact author.)'
}
config: {
csl13_1Upper: 'v13.1 and upper (recommended)',
csl13_1Lower: 'lower than v13.1',
@ -83,6 +100,37 @@
usm1_2To1_3: 'v1.2 to v1.3',
usm1_2Lower: 'lower than v1.2',
},
admin: {
// Change User Profile
newUserEmail: 'Please enter the new email:',
newUserNickname: 'Please enter the new nickname:',
newUserPassword: 'Please enter the new password:',
deleteUserNotice: 'Are you sure to delete this user? It\' permanent.',
changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
// Status
banned: 'Banned',
normal: 'Normal',
admin: 'Admin',
// Operations
ban: 'Ban',
unban: 'Unban',
setAdmin: 'Set as admin',
unsetAdmin: 'Remove admin',
// Change Player Texture
textureType: 'Texture Type',
skin: 'Skin (:model Model)',
cape: 'Cape',
pid: 'Texture ID',
pidNotice: 'Please enter the tid of texture',
changePlayerTexture: 'Change textures of :player'
},
utils: {
fatalError: 'Fatal Error (Please contact the author)'
},
general: {
confirmLogout: 'Sure to log out?',
confirm: 'OK',

View File

@ -47,9 +47,13 @@ show:
comment: Comments
no-comment: We have not enabled comment service.
deleted: The requested texture file is already deleted.
contact-admin: Please contact the admin to delete this texture.
private: The requested texture is private and is only visible to uploader and admins.
upload:
title: Upload texture
button: Confirm uploading
button: Upload
upload: Upload
texture-name: Texture name
name-message: Length of texture name should be less than 32 bytes and it cannot contain invaild character.
@ -58,4 +62,23 @@ upload:
storage-message: Private texture will cost more scores. Every KB costs :score scores
privacy-message: Others cannot find it in skin library.
set-private: Make it private.
type-error: Incorrect mime type of uploaded file.
invalid-size: Invalid :type file (Width :width, Height :height)
lack-score: You don't have enough score to upload this texture.
repeated: The texture is already uploaded by someone else. You can add it to your closet directly.
success: Texture :name was uploaded successfully.
delete:
success: The texture was deleted successfully.
privacy:
success: The texture was setted to :privacy successfully.
rename:
success: The texture was renamed to :name successfully.
no-permission: You aren't the uploader of this texture.
non-existent: Non-existent texture.

View File

@ -5,9 +5,11 @@ 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
checkin: Check In
checkin-success: Checked in successfully. You got :score scores~
cant-checkin-until: You can only check in after $time hours
last-checkin: Last checked in at :time
checkin-remain-time: Available after :time hours
announcement: Announcement
score-intro:
@ -40,6 +42,14 @@ closet:
empty: It seems that you own no player...
add: Add new player
add:
success: Added :name to closet successfully~
repeated: You have already added this texture.
remove:
success: Texture was removed from closet successfully.
non-existent: The texture does not exist in your closet.
player:
player-name: Player Name
preference: Preference
@ -63,9 +73,34 @@ player:
pname-rule: Could only contain letters, numbers and dashes.
pname-rule-chinese: Could only contain chinese characters, letters, numbers and dashes.
add:
repeated: The player name is already registered.
lack-score: You don't have enough score to add a player.
success: Player :name was added successfully.
delete:
success: Player :name was deleted successfully.
rename:
repeated: This player name is occupied. Please choose another one.
success: Player :old was renamed to :new
set:
success: The texture was applied to player :name successfully.
clear:
success: The textures of player :name was resetted successfully.
preference:
success: The preference of player :name was updated to :preference
profile:
change-avatar: Change Avatar?
avatar-notice: Click the gear icon「<i class="fa fa-cog"></i>」of any skin in your skinlib, then click 「Set as avatar」. We will cut the head segment of that skin for you.
avatar:
title: Change Avatar?
notice: Click the gear icon「<i class="fa fa-cog"></i>」of any skin in your skinlib, then click 「Set as avatar」. We will cut the head segment of that skin for you.
wrong-type: You can't set a cape as avatar
non-existent: Non-existent texture
success: Avatar setted successfully
password:
title: Change Password
@ -73,17 +108,22 @@ profile:
new: New Password
confirm: Repeat Password
button: Change Password
wrong-password: Original password is not correct.
success: Password updated successfully, please log in again.
nickname:
title: Change Nickname
empty: No nickname is setted now.
rule: Whatever you like expect special characters
success: Nickname is successfully updated to :nickname
email:
title: Change Email
new: New Email
password: Current Password
button: Change Email
wrong-password: Wrong password.
success: Email address updated successfully, please log in again.
delete:
title: Delete Account
@ -98,6 +138,9 @@ profile:
We warned you, ok?
password: Current Password
wrong-password: Wrong password.
success: Your account is deleted successfully.
config:
mod-requirement: MOD Requirement
mod-intro: |

View File

@ -36,3 +36,11 @@ submit: 提交
notice: 提示
switch-2d-preview: 切换 2D 预览
illegal-parameters: 非法参数
private: 私密
public: 公开
unexistent-user: 不存在的用户
unexistent-player: 角色不存在

View File

@ -12,12 +12,15 @@
$.locales['zh-CN'] = {
auth: {
// Login
emptyIdentification: '你还没有填写邮箱/角色名哦',
emptyPassword: '密码要好好填哦',
emptyCaptcha: '你还没有填写验证码哦',
login: '登录',
loggingIn: '登录中',
tooManyFails: '你尝试的次数太多啦,请输入验证码',
// Register
emptyEmail: '你还没有填写邮箱哦',
invalidEmail: '邮箱格式不正确!',
invalidPassword: '无效的密码。密码长度应该大于 8 并小于 16。',
@ -26,56 +29,70 @@
emptyNickname: '你还没有填写昵称哦',
register: '注册',
registering: '注册中',
// Reset Password
send: '发送',
sending: '发送中',
reset: '重置',
resetting: '重置中'
},
skinlib: {
setSkinName: '给你的皮肤起个名字吧~',
removeFromCloset: '从衣柜中移除',
// Like
addToCloset: '添加至衣柜',
removeFromCloset: '从衣柜中移除',
setItemName: '给你的皮肤起个名字吧~',
emptyItemName: '你还没有填写要收藏的材质名称啊',
// Rename
setNewTextureName: '请输入新的材质名称:',
emptyNewTextureName: '你还没有输入新名称啊',
// Upload
emptyTextureName: '给你的材质起个名字吧',
emptyTextureType: '请选择材质的类型',
emptyUploadFile: '你还没有上传任何文件哦',
encodingError: '错误:这张图片编码不对哦',
formatError: '错误:皮肤文件必须为 PNG 格式',
chooseTextureType: '请选择材质的类型',
noUploadFile: '你还没有上传任何文件哦',
setTextureName: '给你的材质起个名字吧',
choosePNG: '请选择 PNG 格式的图片',
fileExtError: '错误:皮肤文件必须为 PNG 格式',
upload: '确认上传',
uploading: '上传中',
redirecting: '正在跳转...',
confirmUpload: '确认上传',
inputTextureName: '请输入新的材质名称:',
warningPublic: '要将此材质设置为公开吗?',
setPrivate: '设为隐私',
setPublic: '设为公开',
warningDelete: '真的要删除此材质吗?积分将会被返还'
// Change Privacy
setAsPrivate: '设为隐私',
setAsPublic: '设为公开',
setPublicNotice: '要将此材质设置为公开吗?',
deleteNotice: '真的要删除此材质吗?积分将会被返还'
},
user: {
checkinRemainTime: ':time 小时后可签到',
// Closet
switch2dPreview: '切换 2D 预览',
switch3dPreview: '切换 3D 预览',
removeFromCloset: '确定要从衣柜中移除此材质吗?',
setAvatar: '确定要将此材质设置为用户头像吗?',
setAvatarNotice: '将会自动截取皮肤头部',
noSelectedPlayer: '你还没有选择角色哦',
noSelectedTexture: '你还没有选择要应用的材质哦',
removeFromClosetNotice: '确定要从衣柜中移除此材质吗?',
emptySelectedPlayer: '你还没有选择角色哦',
emptySelectedTexture: '你还没有选择要应用的材质哦',
// Player
changePlayerName: '请输入角色名:',
playerNameRule: '允许数字、字母以及下划线,是否支持中文角色名请参考本站设置',
emptyPlayerName: '你还没有填写名称哦',
clearTexture: '确定要重置该用户的皮肤/披风吗?',
deletePlayer: '真的要删除该玩家吗?',
deletePlayerNotice: '这将是永久性的删除',
// Profile
setAvatar: '确定要将此材质设置为用户头像吗?',
setAvatarNotice: '将会自动截取皮肤头部',
emptyNewNickName: '你还没有填写新昵称啊',
changeNickName: '确定要将昵称设置为 :new_nickname 吗?',
emptyPassword: '原密码不能为空',
emptyNewPassword: '新密码要好好填哦',
emptyNewEmail: '你还没有填写新邮箱啊',
changeEmail: '确定要将用户邮箱更改为 :new_email 吗?',
emptyDeletePassword: '请先输入当前用户密码',
signRemainTime: ':time 小时后可签到'
emptyDeletePassword: '请先输入当前用户密码'
},
utils: {
fatalError: '严重错误(请联系作者)'
}
config: {
csl13_1Upper: '13.1 版及以上(推荐)',
csl13_1Lower: '13.1 版以下',
@ -83,10 +100,41 @@
usm1_2To1_3: '1.2 及 1.3 版',
usm1_2Lower: '1.2 版以下',
},
admin: {
// Change User Profile
newUserEmail: '请输入新邮箱:',
newUserNickname: '请输入新昵称:',
newUserPassword: '请输入新密码:',
deleteUserNotice: '真的要删除此用户吗?此操作不可恢复',
changePlayerOwner: '请输入此角色要让渡至的用户 UID',
deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
// Status
banned: '封禁',
normal: '正常',
admin: '管理员',
// Operations
ban: '封禁',
unban: '解封',
setAdmin: '设为管理员',
unsetAdmin: '解除管理员',
// Change Player Texture
textureType: '材质类型',
skin: '皮肤(:model 模型)',
cape: '披风',
pid: '材质 ID',
pidNotice: '输入要更换的材质的 TID',
changePlayerTexture: '更换角色 :player 的材质'
},
utils: {
fatalError: '严重错误(请联系作者)'
},
general: {
confirmLogout: '确定要登出吗?',
confirm: '确定',
cancel: '取消'
cancel: '取消'
}
};
})(window.jQuery);

View File

@ -47,6 +47,10 @@ show:
comment: 评论区
no-comment: 本站未开启评论服务
deleted: 请求的材质文件已经被删除
contact-admin: 请联系管理员删除该条目
private: 请求的材质已经设为隐私,仅上传者和管理员可查看
upload:
title: 上传材质
button: 确认上传
@ -58,4 +62,22 @@ upload:
storage-message: 私密材质将会消耗更多的积分:每 KB 存储空间 :score 积分
privacy-message: 其他人将不会在皮肤库中看到此材质
set-private: 设置为私密材质
type-error: 文件格式不对哦
invalid-size: 不是有效的 :type 文件(宽 :width高 :height
lack-score: 积分不够啦
repeated: 已经有人上传过这个材质了,直接添加到衣柜使用吧~
success: 材质 :name 上传成功
delete:
success: 材质已被成功删除
privacy:
success: 材质已被设为 :privacy
rename:
success: 材质名称已被成功设置为 :name
no-permission: 你不是这个材质的上传者哦
non-existent: 材质不存在

View File

@ -5,9 +5,11 @@ used:
cur-score: 当前积分
score-notice: 点击积分查看说明
sign: 每日签到
last-sign: 上次签到于 :time
remain-time: :time 小时后可签到
checkin: 每日签到
checkin-success: 签到成功,获得了 :score 积分~
cant-checkin-until: $time 小时后才能再次签到哦~
last-checkin: 上次签到于 :time
checkin-remain-time: :time 小时后可签到
announcement: 公告
score-intro:
@ -46,6 +48,14 @@ closet:
empty: 你好像还没有添加任何角色哦
add: 添加角色
add:
success: 材质 :name 收藏成功~
repeated: 你已经收藏过这个材质啦
remove:
success: 材质已从衣柜中移除
non-existent: 衣柜中不存在此材质
player:
player-name: 角色名称
preference: 优先模型
@ -69,9 +79,34 @@ player:
pname-rule: 只能包含数字、字母以及下划线
pname-rule-chinese: 可使用汉字,字母数字以及下划线
add:
repeated: 该角色名已经被其他人注册掉啦
lack-score: 积分不够添加角色啦
success: 成功添加了角色 :name
delete:
success: 角色 :name 已被删除
rename:
repeated: 此角色名已被他人使用,换一个吧~
success: 角色 :old 已更名为 :new
set:
success: 材质已成功应用至角色 :name
clear:
success: 角色 :name 的材质已被成功重置
preference:
success: 角色 :name 的优先模型已更改至 :preference
profile:
change-avatar: 更改头像?
avatar-notice: 请在衣柜中任意皮肤的右下角「<i class="fa fa-cog"></i>」处选择「设为头像」,将会自动截取该皮肤的头部作为头像哦~
avatar:
title: 更改头像?
notice: 请在衣柜中任意皮肤的右下角「<i class="fa fa-cog"></i>」处选择「设为头像」,将会自动截取该皮肤的头部作为头像哦~
wrong-type: 披风可不能设置为头像哦~
non-existent: 材质不存在。
success: 设置成功!
password:
title: 更改密码
@ -79,17 +114,22 @@ profile:
new: 新密码
confirm: 确认密码
button: 修改密码
wrong-password: 原密码错误
success: 密码修改成功,请重新登录
nickname:
title: 更改昵称
empty: 当前未设置昵称,
rule: 可使用除一些特殊符号外的任意字符
success: 昵称已成功设置为 :nickname
email:
title: 更改邮箱
new: 新邮箱
password: 当前密码
button: 修改邮箱
wrong-password: 密码错误
success: 邮箱修改成功,请重新登录
delete:
title: 删除账号
@ -105,6 +145,9 @@ profile:
我们警告过你了,确定要这样做吗?
password: 当前密码
wrong-password: 密码错误
success: 账号已被成功删除
config:
mod-requirement: MOD 需求
mod-intro: |

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-22 14:02:44
* @Last Modified by: printempw
* @Last Modified time: 2016-09-10 17:04:04
* @Last Modified time: 2016-09-24 19:58:24
*/
'use strict';
@ -50,7 +50,7 @@ $('#page-select').on('change', function() {
});
function changeUserEmail(uid) {
var email = prompt("请输入新邮箱:");
var email = prompt(trans('admin.newUserEmail'));
if (!email) return;
@ -72,7 +72,7 @@ function changeUserEmail(uid) {
}
function changeUserNickName(uid) {
var nickname = prompt("请输入新昵称:");
var nickname = prompt(trans('admin.newUserNickname'));
if (!nickname) return;
@ -94,7 +94,7 @@ function changeUserNickName(uid) {
}
function changeUserPwd(uid) {
var password = prompt("请输入新密码:");
var password = prompt(trans('admin.newUserPassword'));
if (!password) return;
@ -141,10 +141,10 @@ function changeBanStatus(uid) {
if (json.errno == 0) {
var object = $('#'+uid).find('a#ban');
var dom = '<a id="ban" href="javascript:changeBanStatus('+uid+');">' +
(object.text() == '封禁' ? '解封' : '封禁') + '</a>';
(object.text() == trans('admin.ban') ? trans('admin.unban') : trans('admin.ban')) + '</a>';
object.html(dom);
$('#'+uid).find('#permission').text(json.permission == '-1' ? '封禁' : '正常');
$('#'+uid).find('#permission').text(json.permission == '-1' ? trans('admin.banned') : trans('admin.normal'));
toastr.success(json.msg);
} else {
toastr.warning(json.msg);
@ -164,10 +164,10 @@ function changeAdminStatus(uid) {
if (json.errno == 0) {
var object = $('#'+uid).find('a#admin');
var dom = '<a href="javascript:changeAdminStatus('+uid+');">' +
(object.text() == '设为管理员' ? '解除管理员' : '设为管理员') + '</a>';
(object.text() == trans('admin.setAdmin') ? trans('admin.unsetAdmin') : trans('admin.setAdmin')) + '</a>';
object.html(dom);
$('#'+uid).find('#permission').text(json.permission == '1' ? '管理员' : '正常');
$('#'+uid).find('#permission').text(json.permission == '1' ? trans('admin.admin') : trans('admin.normal'));
toastr.success(json.msg);
} else {
toastr.warning(json.msg);
@ -178,7 +178,7 @@ function changeAdminStatus(uid) {
}
function deleteUserAccount(uid) {
if (!window.confirm('真的要删除此用户吗?此操作不可恢复')) return;
if (!window.confirm(trans('admin.deleteUserNotice'))) return;
$.ajax({
type: "POST",
@ -223,20 +223,20 @@ $('body').on('change', '#preference', function() {
function changeTexture(pid) {
var dom = '<div class="form-group">'+
'<label for="model">材质类型</label>'+
'<label for="model">'+trans('admin.textureType')+'</label>'+
'<select class="form-control" id="model">'+
'<option value="steve">皮肤Steve 模型)</option>'+
'<option value="alex">皮肤Alex 模型)</option>'+
'<option value="cape">披风</option>'+
'<option value="steve">'+trans('admin.skin', {'model': 'Steve'})+'</option>'+
'<option value="alex">'+trans('admin.skin', {'model': 'Alex'})+'</option>'+
'<option value="cape">'+trans('admin.cape')+'</option>'+
'</select>'+
'</div>'+
'<div class="form-group">'+
'<label for="tid">材质 ID</label>'+
'<input id="tid" class="form-control" type="text" placeholder="输入要更换的材质的 TID">'+
'<label for="tid">'+trans('admin.pid')+'</label>'+
'<input id="tid" class="form-control" type="text" placeholder="'+trans('admin.pidNotice')+'">'+
'</div>';
var player_name = $('#'+pid).find('#player-name').text();
showModal(dom, '更换角色 '+player_name+' 的材质', 'default', 'ajaxChangeTexture('+pid+')');
showModal(dom, trans('admin.changePlayerTexture', {'player': player_name}), 'default', 'ajaxChangeTexture('+pid+')');
return;
}
@ -269,7 +269,7 @@ function ajaxChangeTexture(pid) {
}
function changeOwner(pid) {
var uid = prompt("请输入此角色要让渡至的用户 UID");
var uid = prompt(trans('admin.changePlayerOwner'));
if (!uid) return;
@ -291,7 +291,7 @@ function changeOwner(pid) {
}
function deletePlayer(pid) {
if (!window.confirm('真的要删除此角色吗?此操作不可恢复')) return;
if (!window.confirm(trans('admin.deletePlayerNotice'))) return;
$.ajax({
type: "POST",

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-19 10:46:38
* @Last Modified by: printempw
* @Last Modified time: 2016-09-10 21:36:10
* @Last Modified time: 2016-09-24 20:09:15
*/
'use strict';
@ -40,7 +40,7 @@ $('#type-skin').on('ifToggled', function() {
function addToCloset(tid) {
$.getJSON(base_url + '/skinlib/info/'+tid, function(json) {
swal({
title: trans('skinlib.setSkinName'),
title: trans('skinlib.setItemName'),
inputValue: json.name,
input: 'text',
showCancelButton: true,
@ -49,7 +49,7 @@ function addToCloset(tid) {
if (value) {
resolve();
} else {
reject(trans('user.emptyPlayerName'));
reject(trans('skinlib.emptyItemName'));
}
});
}
@ -176,7 +176,7 @@ function handleFiles(files, type) {
$('#name').val(file.name.split('.png')[0])
};
img.onerror = function() {
toastr.warning(trans('skinlib.encodingError'));
toastr.warning(trans('skinlib.fileExtError'));
};
img.src = this.result;
};
@ -198,18 +198,18 @@ function upload() {
} else if ($('#type-cape').prop('checked')) {
form_data.append('type', 'cape');
} else {
toastr.info(trans('skinlib.chooseTextureType')); return;
toastr.info(trans('skinlib.emptyTextureType')); return;
}
// quick fix for browsers which don't support FormData.get()
if ($('#file').prop('files')[0] == 'undefined') {
toastr.info(trans('skinlib.noUploadFile'));
toastr.info(trans('skinlib.emptyUploadFile'));
$('#file').focus();
} else if ($('#name').val() == "") {
toastr.info(trans('skinlib.setTextureName'));
toastr.info(trans('skinlib.emptyTextureName'));
$('#name').focus();
} else if ($('#file').prop('files')[0].type !== "image/png") {
toastr.warning(trans('skinlib.choosePNG'));
toastr.warning(trans('skinlib.fileExtError'));
$('#file').focus();
} else {
$.ajax({
@ -251,7 +251,7 @@ function upload() {
function changeTextureName(tid) {
swal({
text: trans('skinlib.inputTextureName'),
text: trans('skinlib.setNewTextureName'),
input: 'text',
showCancelButton: true,
inputValidator: function(value) {
@ -259,7 +259,7 @@ function changeTextureName(tid) {
if (value) {
resolve();
} else {
reject(trans('user.emptyPlayerName'));
reject(trans('skinlib.emptyNewTextureName'));
}
});
}
@ -283,14 +283,14 @@ function changeTextureName(tid) {
}
$('.private-label').click(function() {
var object = $(this);
var self = $(this);
swal({
text: trans('skinlib.warningPublic'),
text: trans('skinlib.setPublicNotice'),
type: 'warning',
showCancelButton: true
}).then(function() {
changePrivacy(object.attr('tid'));
object.remove();
changePrivacy(self.attr('tid'));
self.remove();
});
});
@ -303,9 +303,9 @@ function changePrivacy(tid) {
if (json.errno == 0) {
toastr.success(json.msg);
if (json.public == "0")
$('a:contains("' + trans('skinlib.setPrivate') + '")').html(trans('skinlib.setPublic'));
$('a:contains("' + trans('skinlib.setAsPrivate') + '")').html(trans('skinlib.setAsPublic'));
else
$('a:contains("' + trans('skinlib.setPublic') + '")').html(trans('skinlib.setPrivate'));
$('a:contains("' + trans('skinlib.setAsPublic') + '")').html(trans('skinlib.setAsPrivate'));
} else {
toastr.warning(json.msg);
}
@ -316,7 +316,7 @@ function changePrivacy(tid) {
function deleteTexture(tid) {
swal({
text: trans('skinlib.warningDelete'),
text: trans('skinlib.deleteNotice'),
type: 'warning',
showCancelButton: true
}).then(function() {

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-16 10:02:24
* @Last Modified by: printempw
* @Last Modified time: 2016-09-15 21:26:27
* @Last Modified time: 2016-09-24 21:02:13
*/
'use strict';
@ -147,7 +147,7 @@ $('body').on('click', '.item', function() {
function removeFromCloset(tid) {
swal({
text: trans('user.removeFromCloset'),
text: trans('user.removeFromClosetNotice'),
type: 'warning',
showCancelButton: true
}).then(function() {
@ -221,9 +221,9 @@ function setTexture() {
var tid = $('.item-selected').attr('tid');
if (!pid) {
toastr.info(trans('user.noSelectedPlayer'));
toastr.info(trans('user.emptySelectedPlayer'));
} else if (!tid) {
toastr.info(trans('user.noSelectedTexture'));
toastr.info(trans('user.emptySelectedTexture'));
} else {
$.ajax({
type: "POST",
@ -397,7 +397,7 @@ function changeNickName() {
if (!new_nickname) {
swal({
type: 'error',
html: trans('user.emptyNewNickname')
html: trans('user.emptyNewNickName')
});
return;
}
@ -572,10 +572,10 @@ function deleteAccount() {
});
}
function sign() {
function checkin() {
$.ajax({
type: "POST",
url: "./user/sign",
url: "./user/checkin",
dataType: "json",
success: function(json) {
if (json.errno == 0) {
@ -584,8 +584,8 @@ function sign() {
html: json.msg
}).then(function() {
$('#score').html(json.score);
var dom = '<i class="fa fa-calendar-check-o"></i> &nbsp;' + trans('user.signRemainTime', { time: json.remaining_time });
$('#sign-button').attr('disabled', 'disabled').html(dom);
var dom = '<i class="fa fa-calendar-check-o"></i> &nbsp;' + trans('user.checkinRemainTime', { time: String(json.remaining_time) });
$('#checkin-button').attr('disabled', 'disabled').html(dom);
});
} else {
toastr.warning(json.msg);

View File

@ -2,13 +2,19 @@
* @Author: printempw
* @Date: 2016-07-16 09:02:32
* @Last Modified by: printempw
* @Last Modified time: 2016-09-15 21:48:24
* @Last Modified time: 2016-09-24 18:10:03
*/
$.locales = {};
var locale = {};
/**
* Check if given value is empty.
*
* @param {any} obj
* @return {Boolean}
*/
function isEmpty(obj) {
// null and undefined are "empty"
@ -34,6 +40,11 @@ function isEmpty(obj) {
return true;
}
/**
* Load current selected language.
*
* @return void
*/
function loadLocales() {
for (lang in $.locales) {
if (!isEmpty($.locales[lang])) {
@ -42,6 +53,13 @@ function loadLocales() {
}
}
/**
* Translate according to given key.
*
* @param {string} key
* @param {dict} parameters
* @return {string}
*/
function trans(key, parameters) {
if (isEmpty(locale)) {
loadLocales();
@ -78,15 +96,33 @@ function showModal(msg, title, type, callback) {
$(dom).modal();
}
/**
* Show message to div#msg with level
*
* @param {string} msg
* @param {string} type
* @return {void}
*/
function showMsg(msg, type) {
type = type === undefined ? "info" : type;
type = (type === undefined) ? "info" : type;
$("[id=msg]").removeClass().addClass("callout").addClass('callout-'+type).html(msg);
}
/**
* Show modal if error occured when sending an ajax request.
*
* @param {object} json
* @return {void}
*/
function showAjaxError(json) {
showModal(json.responseText.replace(/\n/g, '<br />'), trans('utils.fatalError'), 'danger');
}
/**
* Check if current environment is mobile.
*
* @return {Boolean}
*/
function isMobile() {
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
return true;
@ -94,6 +130,12 @@ function isMobile() {
return false;
}
/**
* Get parameters in query string with key.
*
* @param {string} key
* @return {string}
*/
function getQueryString(key) {
result = location.search.match(new RegExp('[\?\&]'+key+'=([^\&]+)','i'));

View File

@ -73,13 +73,13 @@
</div><!-- /.row -->
</div><!-- ./box-body -->
<div class="box-footer">
@if ($user->canSign())
<button id="sign-button" class="btn btn-primary pull-left" onclick="sign()">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ trans('user.sign') }}
@if ($user->canCheckIn())
<button id="checkin-button" class="btn btn-primary pull-left" onclick="checkin()">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ trans('user.checkin') }}
</button>
@else
<button class="btn btn-primary pull-left" title="{{ trans('user.last-sign', ['time' => $user->getLastSignTime()]) }}" disabled="disabled">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ trans('user.remain-time', ['time' => $user->canSign(true)]) }}
<button class="btn btn-primary pull-left" title="{{ trans('user.last-checkin', ['time' => $user->getLastSignTime()]) }}" disabled="disabled">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ trans('user.checkin-remain-time', ['time' => $user->canCheckIn(true)]) }}
</button>
@endif
</div><!-- /.box-footer -->

View File

@ -20,10 +20,10 @@
<div class="col-md-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('user.profile.change-avatar') }}</h3>
<h3 class="box-title">{{ trans('user.profile.avatar.title') }}</h3>
</div><!-- /.box-header -->
<div class="box-body">
{!! trans('user.profile.avatar-notice') !!}
{!! trans('user.profile.avatar.notice') !!}
</div><!-- /.box-body -->
</div>