From 197009cf2c2c4b70951e21690d4e56d617d0ca10 Mon Sep 17 00:00:00 2001 From: g-plane Date: Sun, 18 Sep 2016 13:30:58 +0800 Subject: [PATCH 1/3] working on i18n of skin library --- resources/lang/en/locale.js | 20 ++++++++++ resources/lang/en/skinlib.yml | 61 ++++++++++++++++++++++++++++++ resources/lang/zh-CN/locale.js | 20 ++++++++++ resources/lang/zh-CN/skinlib.yml | 61 ++++++++++++++++++++++++++++++ resources/src/js/skinlib.js | 50 ++++++++++++------------ resources/views/skinlib/index.tpl | 24 ++++++------ resources/views/skinlib/item.tpl | 8 ++-- resources/views/skinlib/master.tpl | 26 ++++++------- resources/views/skinlib/search.tpl | 24 ++++++------ resources/views/skinlib/show.tpl | 58 ++++++++++++++-------------- resources/views/skinlib/upload.tpl | 38 +++++++++---------- 11 files changed, 276 insertions(+), 114 deletions(-) create mode 100644 resources/lang/en/skinlib.yml create mode 100644 resources/lang/zh-CN/skinlib.yml diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index 7e8ae450..e1cff844 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -31,6 +31,26 @@ 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.', + 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.', + + }, user: { switch2dPreview: 'Switch to 2D Preview', switch3dPreview: 'Switch to 3D Preview', diff --git a/resources/lang/en/skinlib.yml b/resources/lang/en/skinlib.yml new file mode 100644 index 00000000..15d19f9e --- /dev/null +++ b/resources/lang/en/skinlib.yml @@ -0,0 +1,61 @@ +index: + now-showing: Now showing + any-model: (Any model) + steve-model: Steve Model + alex-model: Alex Model + uploader: User( :name )uploaded + newest-uploaded: Newestly uploaded + most-likes: Most likes + no-result: No result. + +item: + remove-from-closet: Remove from closet. + add-to-closet: Add to closet. + not-logged-in: Please login. + private: Private + +master: + filter: Filter + my-upload: My upload + sort: Sorting + search-textures: Search textures + upload-new-skin: Upload new skin + +search: + title: Result + no-given-keywords: No keywords + no-result: No result. + +show: + title: Details of texture + login-before-using-closet: Please login before using closet. + number-of-likes: Number of likes + detail: Details + name: Name + modify-name: Modify name + suitable-model: Suitable model + download-raw: Right-click and choose SAVE AS then you can download raw skin file. + size-of-file: Size of file + uploader: Uploader + upload-at: Date of upload + delete-texture: Delete texture + change-privacy: Change privacy + message: Textures setted to be private or deleted will be removed from all collectors'' closets. + set-private: Be private + set-public: Be publuc + set-message: You can make this texture private or delete it, which will remove it from all collectors'' closets. + comment: Comments + no-comment: We have not enable comment service. + +upload: + title: Upload texture + button: Confirm uploading + upload: Upload + texture-name: Texture name + name-message: Length of texture name should be less than 32 bytes and it cannot contain invaild character. + texture-type: Texture type + choose-file: Choose file + 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. + \ No newline at end of file diff --git a/resources/lang/zh-CN/locale.js b/resources/lang/zh-CN/locale.js index 5eece609..71f8b2f8 100644 --- a/resources/lang/zh-CN/locale.js +++ b/resources/lang/zh-CN/locale.js @@ -31,6 +31,26 @@ reset: '重置', resetting: '重置中' }, + skinlib: { + setSkinName: '给你的皮肤起个名字吧~', + removeFromCloset: '从衣柜中移除', + addToCloset: '添加至衣柜', + encodingError: '错误:这张图片编码不对哦', + formatError: '错误:皮肤文件必须为 PNG 格式', + chooseTextureType: '请选择材质的类型', + noUploadFile: '你还没有上传任何文件哦', + setTextureName: '给你的材质起个名字吧', + choosePNG: '请选择 PNG 格式的图片', + uploading: '上传中', + redirecting: '正在跳转...', + confirmUpload: '确认上传', + inputTextureName: '请输入新的材质名称:', + warningPublic: '要将此材质设置为公开吗?', + setPrivate: '设为隐私', + setPublic: '设为公开', + warningDelete: '真的要删除此材质吗?积分将会被返还', + + }, user: { switch2dPreview: '切换 2D 预览', switch3dPreview: '切换 3D 预览', diff --git a/resources/lang/zh-CN/skinlib.yml b/resources/lang/zh-CN/skinlib.yml new file mode 100644 index 00000000..df990184 --- /dev/null +++ b/resources/lang/zh-CN/skinlib.yml @@ -0,0 +1,61 @@ +index: + now-showing: 当前正显示 + any-model: (任意模型) + steve-model: Steve 模型 + alex-model: Alex 模型 + uploader: 用户( :name )上传 + newest-uploaded: 最新上传 + most-likes: 最多收藏 + no-result: 无结果 + +item: + remove-from-closet: 从衣柜中移除 + add-to-closet: 添加至衣柜 + not-logged-in: 请先登录 + private: 私密 + +master: + filter: 过滤器 + my-upload: 我的上传 + sort: 排序 + search-textures: 搜索材质 + upload-new-skin: 上传新皮肤 + +search: + title: 搜索结果 + no-given-keywords: 未指定关键字 + no-result: 无结果 + +show: + title: 材质详情 + login-before-using-closet: 登录后才能使用衣柜哦 + number-of-likes: 收藏人数 + detail: 详细信息 + name: 名称 + modify-name: 修改名称 + suitable-model: 适用模型 + download-raw: 右键另存为即可下载原始皮肤文件 + size-of-file: 文件大小 + uploader: 上传者 + upload-at: 上传日期 + delete-texture: 删除材质 + change-privacy: 设置隐私 + message: 材质设为隐私或被删除后将会从每一个收藏者的衣柜中移除。 + set-private: 设为隐私 + set-public: 设为公开 + set-message: 你可以将此材质设为隐私或删除。这将会使此材质从每一个收藏者的衣柜中移除。 + comment: 评论区 + no-comment: 本站未开启评论服务 + +upload: + title: 上传材质 + button: 确认上传 + upload: 上传 + texture-name: 材质名称 + name-message: 材质名称应该小于 32 个字节且不能包含奇怪的符号 + texture-type: 材质类型 + choose-file: 选择文件 + storage-message: 私密材质将会消耗更多的积分:每 KB 存储空间 :score 积分 + privacy-message: 其他人将不会在皮肤库中看到此材质 + set-private: 设置为私密材质 + \ No newline at end of file diff --git a/resources/src/js/skinlib.js b/resources/src/js/skinlib.js index 46e0a390..c283a7cb 100644 --- a/resources/src/js/skinlib.js +++ b/resources/src/js/skinlib.js @@ -11,8 +11,8 @@ var base_url = location.pathname.endsWith('skinlib') ? "." : ".."; $(document).ready(function() { swal.setDefaults({ - confirmButtonText: '确定', - cancelButtonText: '取消' + confirmButtonText: trans('general.confirm'), + cancelButtonText: trans('general.cancel') }); }); @@ -40,7 +40,7 @@ $('#type-skin').on('ifToggled', function() { function addToCloset(tid) { $.getJSON(base_url + '/skinlib/info/'+tid, function(json) { swal({ - title: '给你的皮肤起个名字吧~', + title: trans('skinlib.setSkinName'), inputValue: json.name, input: 'text', showCancelButton: true, @@ -49,7 +49,7 @@ function addToCloset(tid) { if (value) { resolve(); } else { - reject('你还没有填写名称哦'); + reject(trans('user.emptyPlayerName')); } }); } @@ -79,8 +79,8 @@ function ajaxAddToCloset(tid, name) { }); $('.modal').modal('hide'); - $('a[tid='+tid+']').attr('href', 'javascript:removeFromCloset('+tid+');').attr('title', '从衣柜中移除').addClass('liked'); - $('#'+tid).attr('href', 'javascript:removeFromCloset('+tid+');').html('从衣柜中移除'); + $('a[tid='+tid+']').attr('href', 'javascript:removeFromCloset('+tid+');').attr('title', trans('skinlib.removeFromCloset')).addClass('liked'); + $('#'+tid).attr('href', 'javascript:removeFromCloset('+tid+');').html(trans('skinlib.removeFromCloset')); $('#likes').html(parseInt($('#likes').html()) + 1); } else { toastr.warning(json.msg); @@ -92,7 +92,7 @@ function ajaxAddToCloset(tid, name) { function removeFromCloset(tid) { swal({ - text: '确定要从衣柜中移除此材质吗?', + text: trans('user.removeFromCloset'), type: 'warning', showCancelButton: true, cancelButtonColor: '#3085d6', @@ -110,8 +110,8 @@ function removeFromCloset(tid) { html: json.msg }); - $('a[tid='+tid+']').attr('href', 'javascript:addToCloset('+tid+');').attr('title', '添加至衣柜').removeClass('liked'); - $('#'+tid).attr('href', 'javascript:addToCloset('+tid+');').html('添加至衣柜'); + $('a[tid='+tid+']').attr('href', 'javascript:addToCloset('+tid+');').attr('title', trans('skinlib.addToCloset')).removeClass('liked'); + $('#'+tid).attr('href', 'javascript:addToCloset('+tid+');').html(trans('skinlib.addToCloset')); $('#likes').html(parseInt($('#likes').html()) - 1); } else { toastr.warning(json.msg); @@ -176,13 +176,13 @@ function handleFiles(files, type) { $('#name').val(file.name.split('.png')[0]) }; img.onerror = function() { - toastr.warning('错误:这张图片编码不对哦'); + toastr.warning(trans('skinlib.encodingError')); }; img.src = this.result; }; reader.readAsDataURL(file); } else { - toastr.warning('错误:皮肤文件必须为 PNG 格式'); + toastr.warning(trans('skinlib.formatError')); } } }; @@ -198,18 +198,18 @@ function upload() { } else if ($('#type-cape').prop('checked')) { form_data.append('type', 'cape'); } else { - toastr.info('请选择材质的类型'); return; + toastr.info(trans('skinlib.chooseTextureType')); return; } // quick fix for browsers which don't support FormData.get() if ($('#file').prop('files')[0] == 'undefined') { - toastr.info('你还没有上传任何文件哦'); + toastr.info(trans('skinlib.noUploadFile')); $('#file').focus(); } else if ($('#name').val() == "") { - toastr.info('给你的材质起个名字吧'); + toastr.info(trans('skinlib.setTextureName')); $('#name').focus(); } else if ($('#file').prop('files')[0].type !== "image/png") { - toastr.warning('请选择 PNG 格式的图片'); + toastr.warning(trans('skinlib.choosePNG')); $('#file').focus(); } else { $.ajax({ @@ -220,7 +220,7 @@ function upload() { data: form_data, processData: false, beforeSend: function() { - $('#upload-button').html(' 上传中').prop('disabled', 'disabled'); + $('#upload-button').html(' ' + trans('skinlib.uploading')).prop('disabled', 'disabled'); }, success: function(json) { if (json.errno == 0) { @@ -228,7 +228,7 @@ function upload() { type: 'success', html: json.msg }).then(function() { - toastr.info('正在跳转...'); + toastr.info(trans('skinlib.redirecting')); window.setTimeout('window.location = "./show?tid='+json.tid+'"', 1000); }); } else { @@ -236,12 +236,12 @@ function upload() { type: 'warning', html: json.msg }).then(function() { - $('#upload-button').html('确认上传').prop('disabled', ''); + $('#upload-button').html(trans('skinlib.confirmUpload')).prop('disabled', ''); }); } }, error: function(json) { - $('#upload-button').html('确认上传').prop('disabled', ''); + $('#upload-button').html(trans('skinlib.confirmUpload')).prop('disabled', ''); showAjaxError(json); } }); @@ -251,7 +251,7 @@ function upload() { function changeTextureName(tid) { swal({ - text: '请输入新的材质名称:', + text: trans('skinlib.inputTextureName'), input: 'text', showCancelButton: true, inputValidator: function(value) { @@ -259,7 +259,7 @@ function changeTextureName(tid) { if (value) { resolve(); } else { - reject('你还没有填写名称哦'); + reject(trans('user.emptyPlayerName')); } }); } @@ -285,7 +285,7 @@ function changeTextureName(tid) { $('.private-label').click(function() { var object = $(this); swal({ - text: '要将此材质设置为公开吗?', + text: trans('skinlib.warningPublic'), type: 'warning', showCancelButton: true }).then(function() { @@ -303,9 +303,9 @@ function changePrivacy(tid) { if (json.errno == 0) { toastr.success(json.msg); if (json.public == "0") - $('a:contains("设为隐私")').html('设为公开'); + $('a:contains("' + trans('skinlib.setPrivate') + '")').html(trans('skinlib.setPublic')); else - $('a:contains("设为公开")').html('设为隐私'); + $('a:contains("' + trans('skinlib.setPublic') + '")').html(trans('skinlib.setPrivate')); } else { toastr.warning(json.msg); } @@ -316,7 +316,7 @@ function changePrivacy(tid) { function deleteTexture(tid) { swal({ - text: '真的要删除此材质吗?积分将会被返还', + text: trans('skinlib.warningDelete'), type: 'warning', showCancelButton: true }).then(function() { diff --git a/resources/views/skinlib/index.tpl b/resources/views/skinlib/index.tpl index 8eb5f2dc..31fd73e1 100644 --- a/resources/views/skinlib/index.tpl +++ b/resources/views/skinlib/index.tpl @@ -1,6 +1,6 @@ @extends('skinlib.master') -@section('title', '皮肤库') +@section('title', trans('general.skinlib')) @section('content') @@ -9,29 +9,29 @@

- 皮肤库 + {{ trans('general.skinlib') }} Skin Library

@@ -46,7 +46,7 @@ @include('skinlib.item') @empty -

无结果

+

{{ trans('skinlib.index.no-result') }}

@endforelse
diff --git a/resources/views/skinlib/item.tpl b/resources/views/skinlib/item.tpl index 88b56ef6..ce72b63f 100644 --- a/resources/views/skinlib/item.tpl +++ b/resources/views/skinlib/item.tpl @@ -12,17 +12,17 @@ @if (Session::has('uid')) @if ($user->closet->has($texture['tid'])) - + @else - + @endif @else - + @endif @if ($texture['public'] == "0") - 私密 + {{ trans('skinlib.item.private') }} @endif diff --git a/resources/views/skinlib/master.tpl b/resources/views/skinlib/master.tpl index e69d4bd0..2de54947 100644 --- a/resources/views/skinlib/master.tpl +++ b/resources/views/skinlib/master.tpl @@ -29,40 +29,40 @@ @@ -81,7 +81,7 @@ -
  • 上传新皮肤
  • +
  • {{ trans('skinlib.master.upload-new-skin') }}
  • @if (!is_null($user))