Skip to content

Commit

Permalink
* Make sort option text translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Oct 21, 2023
1 parent bf09e46 commit dbcd9fd
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ const SORT_BY_VALUES = {
LatestUpdatedFirst: 'latest_updated_first',
EarliestUpdatedFirst: 'earliest_updated_first',
}
const SORT_BY_NAMES = {
NameAscending: 'A-Z',
NameDescending: 'Z-A',

LatestCreatedFirst: 'Recently Created',
EarliestCreatedFirst: 'Earliest Created',

LatestUpdatedFirst: 'Recently Updated',
EarliestUpdatedFirst: 'Earliest Updated',
}

export default Vue.extend({
name: 'FtPlaylistAddVideoPrompt',
Expand Down Expand Up @@ -139,7 +129,25 @@ export default Vue.extend({
},

sortBySelectNames() {
return Object.keys(SORT_BY_VALUES).map(k => SORT_BY_NAMES[k])
return Object.values(SORT_BY_VALUES).map((k) => {
switch (k) {
case SORT_BY_VALUES.NameAscending:
return this.$t('User Playlists.Sort By.NameAscending')
case SORT_BY_VALUES.NameDescending:
return this.$t('User Playlists.Sort By.NameDescending')
case SORT_BY_VALUES.LatestCreatedFirst:
return this.$t('User Playlists.Sort By.LatestCreatedFirst')
case SORT_BY_VALUES.EarliestCreatedFirst:
return this.$t('User Playlists.Sort By.EarliestCreatedFirst')
case SORT_BY_VALUES.LatestUpdatedFirst:
return this.$t('User Playlists.Sort By.LatestUpdatedFirst')
case SORT_BY_VALUES.EarliestUpdatedFirst:
return this.$t('User Playlists.Sort By.EarliestUpdatedFirst')
default:
console.error(`Unknown sortBy: ${k}`)
return k
}
})
},
sortBySelectValues() {
return Object.values(SORT_BY_VALUES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:value="sortBy"
:select-names="sortBySelectNames"
:select-values="sortBySelectValues"
:placeholder="'Sort By'"
:placeholder="$t('User Playlists.Sort By.Sort By')"
@change="sortBy = $event"
/>
<div class="playlists-container">
Expand Down
37 changes: 23 additions & 14 deletions src/renderer/views/UserPlaylists/UserPlaylists.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ const SORT_BY_VALUES = {
LatestPlayedFirst: 'latest_played_first',
EarliestPlayedFirst: 'earliest_played_first',
}
const SORT_BY_NAMES = {
NameAscending: 'A-Z',
NameDescending: 'Z-A',

LatestCreatedFirst: 'Recently Created',
EarliestCreatedFirst: 'Earliest Created',

LatestUpdatedFirst: 'Recently Updated',
EarliestUpdatedFirst: 'Earliest Updated',

LatestPlayedFirst: 'Recently Played',
EarliestPlayedFirst: 'Earliest Played',
}

export default defineComponent({
name: 'UserPlaylists',
Expand Down Expand Up @@ -149,7 +136,29 @@ export default defineComponent({
},

sortBySelectNames() {
return Object.keys(SORT_BY_VALUES).map(k => SORT_BY_NAMES[k])
return Object.values(SORT_BY_VALUES).map((k) => {
switch (k) {
case SORT_BY_VALUES.NameAscending:
return this.$t('User Playlists.Sort By.NameAscending')
case SORT_BY_VALUES.NameDescending:
return this.$t('User Playlists.Sort By.NameDescending')
case SORT_BY_VALUES.LatestCreatedFirst:
return this.$t('User Playlists.Sort By.LatestCreatedFirst')
case SORT_BY_VALUES.EarliestCreatedFirst:
return this.$t('User Playlists.Sort By.EarliestCreatedFirst')
case SORT_BY_VALUES.LatestUpdatedFirst:
return this.$t('User Playlists.Sort By.LatestUpdatedFirst')
case SORT_BY_VALUES.EarliestUpdatedFirst:
return this.$t('User Playlists.Sort By.EarliestUpdatedFirst')
case SORT_BY_VALUES.LatestPlayedFirst:
return this.$t('User Playlists.Sort By.LatestPlayedFirst')
case SORT_BY_VALUES.EarliestPlayedFirst:
return this.$t('User Playlists.Sort By.EarliestPlayedFirst')
default:
console.error(`Unknown sortBy: ${k}`)
return k
}
})
},
sortBySelectValues() {
return Object.values(SORT_BY_VALUES)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/UserPlaylists/UserPlaylists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:value="sortBy"
:select-names="sortBySelectNames"
:select-values="sortBySelectValues"
:placeholder="'Sort By'"
:placeholder="$t('User Playlists.Sort By.Sort By')"
@change="sortBy = $event"
/>
</div>
Expand Down
15 changes: 15 additions & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ User Playlists:
Delete Playlist: Delete Playlist
Are you sure you want to delete this playlist? This cannot be undone.: Are you sure you want to delete this playlist? This cannot be undone.

Sort By:
Sort By: Sort By

NameAscending: 'A-Z'
NameDescending: 'Z-A'

LatestCreatedFirst: 'Recently Created'
EarliestCreatedFirst: 'Earliest Created'

LatestUpdatedFirst: 'Recently Updated'
EarliestUpdatedFirst: 'Earliest Updated'

LatestPlayedFirst: 'Recently Played'
EarliestPlayedFirst: 'Earliest Played'

AddVideoPrompt:
Select a playlist to add your N videos to: 'Select a playlist to add your video to | Select a playlist to add your {videoCount} videos to'
N playlists selected: '{playlistCount} Selected'
Expand Down

0 comments on commit dbcd9fd

Please sign in to comment.