fix: Add new localizations (#722)

Co-authored-by: bakerbunker <bakerbunker@nwpu.edu.cn>
This commit is contained in:
BakerBunker 2021-05-30 18:25:35 +08:00 committed by GitHub
parent 5869f889f9
commit 347bc1665d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 17 deletions

View File

@ -18,6 +18,7 @@
</template> </template>
<script> <script>
import locale from '@/locale';
import { mapMutations, mapState, mapActions } from 'vuex'; import { mapMutations, mapState, mapActions } from 'vuex';
import { dailyRecommendTracks } from '@/api/playlist'; import { dailyRecommendTracks } from '@/api/playlist';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
@ -61,7 +62,7 @@ export default {
}, },
playDailyTracks() { playDailyTracks() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
let trackIDs = this.dailyTracks.map(t => t.id); let trackIDs = this.dailyTracks.map(t => t.id);

View File

@ -30,6 +30,7 @@
<script> <script>
import { mapActions, mapMutations, mapState } from 'vuex'; import { mapActions, mapMutations, mapState } from 'vuex';
import Modal from '@/components/Modal.vue'; import Modal from '@/components/Modal.vue';
import locale from '@/locale';
import { addOrRemoveTrackFromPlaylist } from '@/api/playlist'; import { addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui'; import { disableScrolling, enableScrolling } from '@/utils/ui';
@ -84,7 +85,7 @@ export default {
}).then(data => { }).then(data => {
if (data.body.code === 200) { if (data.body.code === 200) {
this.show = false; this.show = false;
this.showToast('已添加到歌单'); this.showToast(locale.t('toast.savedToPlaylist'));
} else { } else {
this.showToast(data.body.message); this.showToast(data.body.message);
} }

View File

@ -30,6 +30,7 @@
<script> <script>
import Modal from '@/components/Modal.vue'; import Modal from '@/components/Modal.vue';
import locale from '@/locale';
import { mapMutations, mapState, mapActions } from 'vuex'; import { mapMutations, mapState, mapActions } from 'vuex';
import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist'; import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui'; import { disableScrolling, enableScrolling } from '@/utils/ui';
@ -86,7 +87,7 @@ export default {
tracks: this.modals.newPlaylistModal.afterCreateAddTrackID, tracks: this.modals.newPlaylistModal.afterCreateAddTrackID,
}).then(data => { }).then(data => {
if (data.body.code === 200) { if (data.body.code === 200) {
this.showToast('已添加到歌单'); this.showToast(locale.t('toast.savedToPlaylist'));
} else { } else {
this.showToast(data.body.message); this.showToast(data.body.message);
} }

View File

@ -32,7 +32,9 @@
@click="removeTrackFromPlaylist" @click="removeTrackFromPlaylist"
>从歌单中删除</div >从歌单中删除</div
> >
<div class="item" @click="addTrackToPlaylist">添加到歌单</div> <div class="item" @click="addTrackToPlaylist">{{
$t('contextMenu.addToPlaylist')
}}</div>
</ContextMenu> </ContextMenu>
<div :style="listStyles"> <div :style="listStyles">
<TrackListItem <TrackListItem
@ -54,6 +56,7 @@ import { isAccountLoggedIn } from '@/utils/auth';
import TrackListItem from '@/components/TrackListItem.vue'; import TrackListItem from '@/components/TrackListItem.vue';
import ContextMenu from '@/components/ContextMenu.vue'; import ContextMenu from '@/components/ContextMenu.vue';
import locale from '@/locale';
export default { export default {
name: 'TrackList', name: 'TrackList',
@ -183,7 +186,7 @@ export default {
}, },
addTrackToPlaylist() { addTrackToPlaylist() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
this.updateModal({ this.updateModal({
@ -199,7 +202,7 @@ export default {
}, },
removeTrackFromPlaylist() { removeTrackFromPlaylist() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
if (confirm(`确定要从歌单删除 ${this.rightClickedTrack.name}`)) { if (confirm(`确定要从歌单删除 ${this.rightClickedTrack.name}`)) {
@ -210,7 +213,9 @@ export default {
tracks: trackID, tracks: trackID,
}).then(data => { }).then(data => {
this.showToast( this.showToast(
data.body.code === 200 ? '已从歌单中删除' : data.body.message data.body.code === 200
? locale.t('toast.removedFromPlaylist')
: data.body.message
); );
this.$parent.removeTrack(trackID); this.$parent.removeTrack(trackID);
}); });

View File

@ -168,12 +168,16 @@ export default {
saveToLibrary: 'Save to library', saveToLibrary: 'Save to library',
removeFromLibrary: 'Remove from library', removeFromLibrary: 'Remove from library',
addToPlaylist: 'Add to playlist', addToPlaylist: 'Add to playlist',
searchInPlaylist: 'Search in playlist',
copyUrl: 'Copy URL', copyUrl: 'Copy URL',
}, },
toast: { toast: {
savedToPlaylist: 'Saved to playlist',
removedFromPlaylist: 'Removed from playlist',
savedToMyLikedSongs: 'Saved to my Liked Songs', savedToMyLikedSongs: 'Saved to my Liked Songs',
removedFromMyLikedSongs: 'Removed from my Liked Songs', removedFromMyLikedSongs: 'Removed from my Liked Songs',
copied: 'Copied', copied: 'Copied',
copyFailed: 'Copy failed: ', copyFailed: 'Copy failed: ',
needToLogin: 'Need to log into netease account',
}, },
}; };

View File

@ -169,12 +169,16 @@ export default {
saveToLibrary: '保存到音乐库', saveToLibrary: '保存到音乐库',
removeFromLibrary: '从音乐库删除', removeFromLibrary: '从音乐库删除',
addToPlaylist: '添加到歌单', addToPlaylist: '添加到歌单',
searchInPlaylist: '歌单内搜索',
copyUrl: '复制链接', copyUrl: '复制链接',
}, },
toast: { toast: {
savedToPlaylist: '已添加到歌单',
removedFromPlaylist: '已从歌单中删除',
savedToMyLikedSongs: '已添加到我喜欢的音乐', savedToMyLikedSongs: '已添加到我喜欢的音乐',
removedFromMyLikedSongs: '已从喜欢的音乐中删除', removedFromMyLikedSongs: '已从喜欢的音乐中删除',
copied: '已复制', copied: '已复制',
copyFailed: '复制失败:', copyFailed: '复制失败:',
needToLogin: '此操作需要登录网易云帐号',
}, },
}; };

View File

@ -217,7 +217,7 @@ export default {
}, },
likeAlbum(toast = false) { likeAlbum(toast = false) {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
likeAAlbum({ likeAAlbum({

View File

@ -312,7 +312,7 @@ export default {
}, },
followArtist() { followArtist() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
followAArtist({ followAArtist({

View File

@ -136,6 +136,7 @@ import { getLyric } from '@/api/track';
import { randomNum, dailyTask } from '@/utils/common'; import { randomNum, dailyTask } from '@/utils/common';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import locale from '@/locale';
import ContextMenu from '@/components/ContextMenu.vue'; import ContextMenu from '@/components/ContextMenu.vue';
import TrackList from '@/components/TrackList.vue'; import TrackList from '@/components/TrackList.vue';
@ -228,7 +229,7 @@ export default {
}, },
updateCurrentTab(tab) { updateCurrentTab(tab) {
if (!isAccountLoggedIn() && tab !== 'playlists') { if (!isAccountLoggedIn() && tab !== 'playlists') {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
this.currentTab = tab; this.currentTab = tab;
@ -247,7 +248,7 @@ export default {
}, },
openAddPlaylistModal() { openAddPlaylistModal() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
this.updateModal({ this.updateModal({

View File

@ -35,6 +35,7 @@
import { mvDetail, mvUrl, simiMv, likeAMV } from '@/api/mv'; import { mvDetail, mvUrl, simiMv, likeAMV } from '@/api/mv';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import locale from '@/locale';
import '@/assets/css/plyr.css'; import '@/assets/css/plyr.css';
import Plyr from 'plyr'; import Plyr from 'plyr';
@ -116,7 +117,7 @@ export default {
}, },
likeMV() { likeMV() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
likeAMV({ likeAMV({

View File

@ -186,9 +186,13 @@
<ContextMenu ref="playlistMenu"> <ContextMenu ref="playlistMenu">
<!-- <div class="item">{{ $t('contextMenu.addToQueue') }}</div> --> <!-- <div class="item">{{ $t('contextMenu.addToQueue') }}</div> -->
<div class="item" @click="likePlaylist(true)">{{ <div class="item" @click="likePlaylist(true)">{{
playlist.subscribed ? '从音乐库删除' : '保存到音乐库' playlist.subscribed
? $t('contextMenu.removeFromLibrary')
: $t('contextMenu.saveToLibrary')
}}</div>
<div class="item" @click="searchInPlaylist()">{{
$t('contextMenu.searchInPlaylist')
}}</div> }}</div>
<div class="item" @click="searchInPlaylist()">歌单内搜索</div>
<div <div
v-if="playlist.creator.userId === data.user.userId" v-if="playlist.creator.userId === data.user.userId"
class="item" class="item"
@ -216,6 +220,7 @@ import {
import { getTrackDetail } from '@/api/track'; import { getTrackDetail } from '@/api/track';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import nativeAlert from '@/utils/nativeAlert'; import nativeAlert from '@/utils/nativeAlert';
import locale from '@/locale';
import { disableScrolling, enableScrolling } from '@/utils/ui'; import { disableScrolling, enableScrolling } from '@/utils/ui';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue'; import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
@ -409,7 +414,7 @@ export default {
}, },
likePlaylist(toast = false) { likePlaylist(toast = false) {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
subscribePlaylist({ subscribePlaylist({
@ -486,7 +491,7 @@ export default {
}, },
deletePlaylist() { deletePlaylist() {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
let confirmation = confirm(`确定要删除歌单 ${this.playlist.name}`); let confirmation = confirm(`确定要删除歌单 ${this.playlist.name}`);
@ -517,7 +522,7 @@ export default {
}, },
removeTrack(trackID) { removeTrack(trackID) {
if (!isAccountLoggedIn()) { if (!isAccountLoggedIn()) {
this.showToast('此操作需要登录网易云账号'); this.showToast(locale.t('toast.needToLogin'));
return; return;
} }
this.tracks = this.tracks.filter(t => t.id !== trackID); this.tracks = this.tracks.filter(t => t.id !== trackID);