From 1657935ba1e1565d80d4f7632209069b9493bc96 Mon Sep 17 00:00:00 2001 From: qier222 <68148142+qier222@users.noreply.github.com> Date: Tue, 20 Oct 2020 18:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BF=BB=E8=AF=91=E4=BB=A5?= =?UTF-8?q?=E5=8F=8Alocale=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Player.vue | 19 ++--- src/locale/index.js | 19 +++-- src/locale/lang/en.js | 83 ++++++++++++++++++++++ src/locale/lang/zh-CN.js | 87 +++++++++++++++++++++++ src/locale/messages.js | 144 -------------------------------------- src/utils/filters.js | 42 ++++++----- src/views/album.vue | 31 ++++---- src/views/home.vue | 36 +++++----- src/views/library.vue | 61 +++++++++------- src/views/playlist.vue | 35 ++++----- src/views/search.vue | 18 ++--- 11 files changed, 316 insertions(+), 259 deletions(-) create mode 100644 src/locale/lang/en.js create mode 100644 src/locale/lang/zh-CN.js delete mode 100644 src/locale/messages.js diff --git a/src/components/Player.vue b/src/components/Player.vue index f697333..ff59bdb 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -37,7 +37,10 @@
- +
- -
@@ -82,11 +85,11 @@
- + YesPlayMusic's GitHub repository to build and use the self-hosted NetEase Cloud Music API.` + }, + mv: { + moreVideo: "More Videos" + }, + next: { + nowPlaying: "Now Playing", + nextUp: "Next Up" + }, + player: { + like: "Like", + previous: "Previous Song", + next: "Next Song", + repeat: "Repeat", + shuffle: "Shuffle", + play: "Play", + pause: "Pause", + mute: "Mute", + nextUp: "Next Up" + } +}; diff --git a/src/locale/lang/zh-CN.js b/src/locale/lang/zh-CN.js new file mode 100644 index 0000000..10797a5 --- /dev/null +++ b/src/locale/lang/zh-CN.js @@ -0,0 +1,87 @@ +export default { + play: "播放", + nav: { + home: "首页", + explore: "发现", + library: "资料库", + search: "搜索" + }, + footer: { + settings: "设置" + }, + home: { + recommendPlaylist: "推荐歌单", + recommendArtist: "推荐歌手", + newAlbum: "新专速递", + seeMore: "更多", + charts: "排行榜" + }, + library: { + sLibrary: "的资料库", + likedSongs: "我喜欢的歌", + sLikedSongs: "喜欢的歌" + }, + explore: { + explore: "发现", + loadMore: "加载更多" + }, + artist: { + latestRelease: "最新发布", + popularSongs: "热门歌曲", + showMore: "显示更多", + showLess: "收起", + EPSingle: "EP和单曲", + albums: "专辑" + }, + album: { + released: "发行于" + }, + playlist: { + playlist: "歌单", + updatedAt: "最后更新于" + }, + login: { + accessToAll: "可访问全部数据", + loginText: "登录网易云账号", + search: "搜索网易云账号", + readonly: "只能读取账号公开数据", + usernameLogin: "用户名登录", + searchHolder: "请输入你的网易云用户名", + enterTip: "按 Enter 搜索", + choose: "在列表中选中你的账号", + confirm: "确认", + countryCode: "国际区号", + phone: "手机号", + email: "邮箱", + password: "密码", + login: "登录", + usingEmail: "使用邮箱登录", + usingPhone: "使用手机号登录", + // TODO + agreement: `YesPlayMusic 承诺不会保存你的任何账号信息到云端。
+ 你的密码会在本地进行 MD5 加密后再传输到网易云 API。
+ YesPlayMusic 并非网易云官方网站,输入账号信息前请慎重考虑。 你也可以前往 + YesPlayMusic 的 GitHub 源代码仓库 + 自行构建并使用自托管的网易云 API。` + }, + mv: { + moreVideo: "更多视频" + }, + next: { + nowPlaying: "正在播放", + nextUp: "即将播放" + }, + player: { + like: "喜欢", + previous: "上一首", + next: "下一首", + repeat: "单曲循环", + shuffle: "随机播放", + play: "播放", + pause: "暂停", + mute: "静音", + nextUp: "播放列表" + } +}; diff --git a/src/locale/messages.js b/src/locale/messages.js deleted file mode 100644 index aec835c..0000000 --- a/src/locale/messages.js +++ /dev/null @@ -1,144 +0,0 @@ -export default { - en: { - nav: { - home: "Home", - explore: "Explore", - library: "Library", - search: "Search" - }, - footer: { - settings: 'Settings', - }, - home: { - recommendPlaylist: "Recommended Playlist", - recommendArtist: "Recommended Artist", - newAlbum: "Lastest Album", - leaderboard: "Leaderboard", - seeMore: "SEE MORE", - }, - library: "Library", - explore: { - explore: "Explore", - loadMore: "Load More", - }, - artist: { - latestRelease: "Latest Release", - popularSongs: "Popular Songs", - showMore: "SHOW MORE", - showLess: "SHOW LESS", - EPSingle: "EPs & Singles", - albums: "Albums" - }, - album: { - released: "Released", - }, - login: { - accessToAll: "Access to all data", - loginText: "Login in Netease", - search: "Search account", - readonly: "Only access to public data", - usernameLogin: "Username Login", - searchHolder: "Your account username", - enterTip: "Press 'enter' to search", - choose: "Choose your account", - confirm: "confirm", - countrycode: 'countrycode', - phone: 'phone', - email: 'email', - password: 'password', - login: 'Login', - usingEmail: 'Using email', - usingPhone: 'Using phone', - // TODO - agreement: `YesPlayMusic promises not to save any of your account information to the cloud. - Your password will be MD5 encrypted locally and then transmitted to NetEase Cloud API. - YesPlayMusic is not the official website of NetEase Cloud, please consider carefully before entering account information. You can also go to YesPlayMusic's GitHub repository to build and use the self-hosted NetEase Cloud API.` - }, - mv: { - moreVideo: 'More Videos' - }, - next: { - nowPlaying: 'Now Playing', - nextUp: 'Next Up' - }, - playlist: "Playlists", - play: "PLAY", - likedSong: "Liked Songs", - shortIs: "'s", - is: "'s", - updatedAt: "Updated at", - }, - "zh-CN": { - nav: { - home: "首页", - explore: "发现", - library: "歌单", - search: "搜索" - }, - footer: { - settings: '设置', - }, - home: { - recommendPlaylist: "推荐歌单", - recommendArtist: "推荐歌手", - newAlbum: "新专速递", - leaderboard: "排行榜", - seeMore: "更多", - }, - library: "歌单", - explore: { - explore: "发现", - loadMore: "加载更多", - }, - artist: { - latestRelease: "最新发布", - popularSongs: "热门歌曲", - showMore: "显示更多", - showLess: "收起", - EPSingle: "专辑及单曲", - albums: "专辑" - }, - album: { - released: "发布于", - }, - login: { - accessToAll: "可访问全部数据", - loginText: "登录网易云账号", - search: "搜索网易云账号", - readonly: "只能读取账号公开数据", - usernameLogin: '用户名登录', - searchHolder: "请输入你的网易云用户名", - enterTip: "按 Enter 搜索", - choose: "在列表中选中你的账号", - confirm: "确认", - countrycode: '国际区号', - phone: '手机号', - email: '邮箱', - password: '密码', - login: '登录', - usingEmail: '使用邮箱登录', - usingPhone: '使用手机号登录', - // TODO - agreement: `YesPlayMusic 承诺不会保存你的任何账号信息到云端。
- 你的密码会在本地进行 MD5 加密后再传输到网易云 API。
- YesPlayMusic 并非网易云官方网站,输入账号信息前请慎重考虑。 你也可以前往 - YesPlayMusic 的 GitHub 源代码仓库 - 自行构建并使用自托管的网易云 API。` - }, - mv: { - moreVideo: '更多视频' - }, - next: { - nowPlaying: '正在播放', - nextUp: '即将播放' - }, - playlist: "播放列表", - play: "播放", - likedSong: "我喜欢的音乐", - shortIs: "", - is: "的", - updatedAt: "更新于" - } -}; \ No newline at end of file diff --git a/src/utils/filters.js b/src/utils/filters.js index 109ff35..8760dc9 100644 --- a/src/utils/filters.js +++ b/src/utils/filters.js @@ -2,6 +2,7 @@ import Vue from "vue"; import dayjs from "dayjs"; import duration from "dayjs/plugin/duration"; import relativeTime from "dayjs/plugin/relativeTime"; +import locale from "@/locale"; Vue.filter("formatTime", (Milliseconds, format = "HH:MM:SS") => { if (!Milliseconds) return ""; @@ -27,6 +28,7 @@ Vue.filter("formatTime", (Milliseconds, format = "HH:MM:SS") => { Vue.filter("formatDate", (timestamp, format = "MMM D, YYYY") => { if (!timestamp) return ""; + if (locale.locale === "zh-CN") format = "YYYY年MM月DD日"; return dayjs(timestamp).format(format); }); @@ -52,26 +54,34 @@ Vue.filter("resizeImage", (imgUrl, size = 512) => { return `${httpsImgUrl}?param=${size}y${size}`; }); -Vue.filter("formatPlayCount", (count) => { +Vue.filter("formatPlayCount", count => { if (!count) return ""; - if (count > 100000000) { - return `${~~(count / 100000000)}亿`; + if (locale.locale === "zh-CN") { + if (count > 100000000) { + return `${Math.floor((count / 100000000) * 100) / 100}亿`; // 2.32 亿 + } + if (count > 100000) { + return `${Math.floor((count / 10000) * 10) / 10}万`; // 232.1 万 + } + if (count > 10000) { + return `${Math.floor((count / 10000) * 100) / 100}万`; // 2.3 万 + } + return count; + } else { + if (count > 10000000) { + return `${Math.floor((count / 1000000) * 10) / 10}M`; // 233.2M + } + if (count > 1000000) { + return `${Math.floor((count / 1000000) * 100) / 100}M`; // 2.3M + } + if (count > 1000) { + return `${Math.floor((count / 1000) * 100) / 100}K`; // 233.23K + } + return count; } - if (count > 10000) { - return `${~~(count / 10000)}万`; - } - return count; - - // if (count > 1000000) { - // return `${Math.floor((count / 1000000) * 100) / 100}M`; - // } - // if (count > 1000) { - // return `${~~(count / 1000)}K`; - // } - // return count; }); -Vue.filter("toHttps", (url) => { +Vue.filter("toHttps", url => { if (!url) return ""; return url.replace(/^http:/, "https:"); }); diff --git a/src/views/album.vue b/src/views/album.vue index a0d21dd..21a1d06 100644 --- a/src/views/album.vue +++ b/src/views/album.vue @@ -38,7 +38,7 @@ @click.native="playAlbumByID(album.id)" :iconClass="`play`" > - {{ $t('play') }} + {{ $t("play") }}
@@ -47,7 +47,8 @@
- {{ $t("album.released") }} {{ album.publishTime | formatDate("MMMM D, YYYY") }} + {{ $t("album.released") }} + {{ album.publishTime | formatDate("MMMM D, YYYY") }}