[web] Fix for error messages not displaying #1500

This commit is contained in:
Alain Nussbaumer 2022-06-19 16:32:46 +02:00 committed by ejurgensen
parent 40ac39b6df
commit 879feab518
6 changed files with 52 additions and 27 deletions

View File

@ -85,7 +85,12 @@
<span class="heading" v-text="$t('dialog.queue-item.type')" /> <span class="heading" v-text="$t('dialog.queue-item.type')" />
<span class="title is-6"> <span class="title is-6">
<span <span
v-text="[item.media_kind, item.data_kind].join(' - ')" v-text="
[
$t('media.kind.' + item.media_kind),
$t('data.kind.' + item.data_kind)
].join(' - ')
"
/> />
<span <span
v-if="item.data_kind === 'spotify'" v-if="item.data_kind === 'spotify'"

View File

@ -1,4 +1,7 @@
import { DateTime, Duration } from 'luxon' import { DateTime, Duration } from 'luxon'
import i18n from '@/i18n'
const { t, locale } = i18n.global
export const filters = { export const filters = {
durationInHours: function (value_ms) { durationInHours: function (value_ms) {
@ -31,11 +34,11 @@ export const filters = {
}, },
date: function (value) { date: function (value) {
return DateTime.fromISO(value).toLocaleString(DateTime.DATE_FULL) return DateTime.fromISO(value).setLocale(locale.value).toLocaleString(DateTime.DATE_FULL)
}, },
datetime: function (value) { datetime: function (value) {
return DateTime.fromISO(value).toLocaleString(DateTime.DATETIME_MED) return DateTime.fromISO(value).setLocale(locale.value).toLocaleString(DateTime.DATETIME_MED)
}, },
timeFromNow: function (value) { timeFromNow: function (value) {
@ -45,19 +48,19 @@ export const filters = {
}, },
number: function (value) { number: function (value) {
return value.toLocaleString() return value.toLocaleString(locale.value)
}, },
channels: function (value) { channels: function (value) {
if (value === 1) { if (value === 1) {
return 'mono' return t('filter.mono')
} }
if (value === 2) { if (value === 2) {
return 'stereo' return t('filter.stereo')
} }
if (!value) { if (!value) {
return '' return ''
} }
return value + ' channels' return t('filter.channels', { value })
} }
} }

View File

@ -1,3 +1,6 @@
import i18n from '@/i18n'
const { t, locale } = i18n.global
const GROUP_KEY_NONE = 'GROUP_KEY_NONE' const GROUP_KEY_NONE = 'GROUP_KEY_NONE'
export function noop() { export function noop() {
@ -29,7 +32,7 @@ export function byName(field, defaultValue = '_') {
const fieldA = a[field] || defaultValue const fieldA = a[field] || defaultValue
const fieldB = b[field] || defaultValue const fieldB = b[field] || defaultValue
return fieldA.localeCompare(fieldB) return fieldA.localeCompare(fieldB, locale.value)
}, },
groupKeyFn: (item) => { groupKeyFn: (item) => {
@ -45,7 +48,7 @@ export function byYear(field, { direction = 'asc', defaultValue = '0000' }) {
const fieldA = a[field] || defaultValue const fieldA = a[field] || defaultValue
const fieldB = b[field] || defaultValue const fieldB = b[field] || defaultValue
const result = fieldA.localeCompare(fieldB) const result = fieldA.localeCompare(fieldB, locale.value)
return direction === 'asc' ? result : result * -1 return direction === 'asc' ? result : result * -1
}, },
@ -62,7 +65,7 @@ export function byDateSinceToday(field, defaultValue = '0000') {
const fieldA = a[field] || defaultValue const fieldA = a[field] || defaultValue
const fieldB = b[field] || defaultValue const fieldB = b[field] || defaultValue
return fieldB.localeCompare(fieldA) return fieldB.localeCompare(fieldA, locale.value)
}, },
groupKeyFn: (item) => { groupKeyFn: (item) => {
@ -76,13 +79,13 @@ export function byDateSinceToday(field, defaultValue = '0000') {
if (diff < 86400000) { if (diff < 86400000) {
// 24h // 24h
return 'Today' return t('group-by-list.today')
} else if (diff < 604800000) { } else if (diff < 604800000) {
// 7 days // 7 days
return 'Last week' return t('group-by-list.last-week')
} else if (diff < 2592000000) { } else if (diff < 2592000000) {
// 30 days // 30 days
return 'Last month' return t('group-by-list.last-month')
} }
return fieldValue.substring(0, 4) return fieldValue.substring(0, 4)
} }

View File

@ -150,7 +150,7 @@
"added-on": "Added On", "added-on": "Added On",
"album-artist": "Album Artist", "album-artist": "Album Artist",
"album": "Album", "album": "Album",
"bitrate": " {'|'} {rate} Kb/s", "bitrate": " {'|'} {rate} kbit/s",
"channels": " {'|'} {channels}", "channels": " {'|'} {channels}",
"comment": "Comment", "comment": "Comment",
"composer": "Composer", "composer": "Composer",
@ -543,5 +543,10 @@
"today": "Today", "today": "Today",
"last-week": "Last week", "last-week": "Last week",
"last-month": "Last month" "last-month": "Last month"
},
"filter": {
"mono": "mono",
"stereo": "stereo",
"channels": "{count} channels"
} }
} }

View File

@ -150,7 +150,7 @@
"added-on": "Ajouté le", "added-on": "Ajouté le",
"album-artist": "Artiste de lalbum", "album-artist": "Artiste de lalbum",
"album": "Album", "album": "Album",
"bitrate": " {'|'} {rate} Kb/s", "bitrate": " {'|'} {rate} kbit/s",
"channels": " {'|'} {channels}", "channels": " {'|'} {channels}",
"comment": "Commentaire", "comment": "Commentaire",
"composer": "Compositeur", "composer": "Compositeur",
@ -543,5 +543,10 @@
"today": "Aujourdhui", "today": "Aujourdhui",
"last-week": "La semaine dernière", "last-week": "La semaine dernière",
"last-month": "Le mois dernier" "last-month": "Le mois dernier"
},
"filter": {
"mono": "mono",
"stereo": "stéréo",
"channels": "{count} canaux"
} }
} }

View File

@ -1,14 +1,18 @@
import axios from 'axios' import axios from 'axios'
import store from '@/store' import store from '@/store'
import i18n from '@/i18n'
const { t } = i18n.global
axios.interceptors.response.use( axios.interceptors.response.use(
function (response) { function (response) {
return response return response
}, },
function (error) { function (error) {
console.log(i18n)
if (error.request.status && error.request.responseURL) { if (error.request.status && error.request.responseURL) {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.request-failed', { text: t('server.request-failed', {
status: error.request.status, status: error.request.status,
cause: error.request.statusText, cause: error.request.statusText,
url: error.request.responseURL url: error.request.responseURL
@ -81,7 +85,7 @@ export default {
queue_add(uri) { queue_add(uri) {
return axios.post('./api/queue/items/add?uris=' + uri).then((response) => { return axios.post('./api/queue/items/add?uris=' + uri).then((response) => {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.appended-tracks', { count: response.data.count }), text: t('server.appended-tracks', { count: response.data.count }),
type: 'info', type: 'info',
timeout: 2000 timeout: 2000
}) })
@ -98,7 +102,7 @@ export default {
.post('./api/queue/items/add?uris=' + uri + '&position=' + position) .post('./api/queue/items/add?uris=' + uri + '&position=' + position)
.then((response) => { .then((response) => {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.appended-tracks', { text: t('server.appended-tracks', {
count: response.data.count count: response.data.count
}), }),
type: 'info', type: 'info',
@ -116,7 +120,7 @@ export default {
.post('./api/queue/items/add', undefined, { params: options }) .post('./api/queue/items/add', undefined, { params: options })
.then((response) => { .then((response) => {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.appended-tracks', { text: t('server.appended-tracks', {
count: response.data.count count: response.data.count
}), }),
type: 'info', type: 'info',
@ -138,7 +142,7 @@ export default {
.post('./api/queue/items/add', undefined, { params: options }) .post('./api/queue/items/add', undefined, { params: options })
.then((response) => { .then((response) => {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.appended-tracks', { text: t('server.appended-tracks', {
count: response.data.count count: response.data.count
}), }),
type: 'info', type: 'info',
@ -153,7 +157,7 @@ export default {
.post('./api/queue/save', undefined, { params: { name: name } }) .post('./api/queue/save', undefined, { params: { name: name } })
.then((response) => { .then((response) => {
store.dispatch('add_notification', { store.dispatch('add_notification', {
text: this.$t('server.queue-saved', { name: name }), text: t('server.queue-saved', { name: name }),
type: 'info', type: 'info',
timeout: 2000 timeout: 2000
}) })