[web] Fix missing translation. Detect user locale

This commit is contained in:
Alain Nussbaumer 2022-06-05 19:19:00 +02:00 committed by chme
parent c828549b85
commit f11c66c42d
9 changed files with 63 additions and 33 deletions

View File

@ -24,9 +24,7 @@
<li :class="{ 'is-active': isActive }">
<a @click="navigate" @keypress.enter="navigate">
<span
v-text="
$t('page.settings.tabs.remotes-and-outputs')
"
v-text="$t('page.settings.tabs.remotes-and-outputs')"
/>
</a>
</li>
@ -49,9 +47,7 @@
>
<li :class="{ 'is-active': isActive }">
<a @click="navigate" @keypress.enter="navigate">
<span
v-text="$t('page.settings.tabs.online-services')"
/>
<span v-text="$t('page.settings.tabs.online-services')" />
</a>
</li>
</router-link>

View File

@ -9,7 +9,9 @@ import messages from '@intlify/vite-plugin-vue-i18n/messages'
export default createI18n({
legacy: false,
globalInjection: true,
locale: 'en',
locale: navigator.language,
fallbackLocale: 'en',
fallbackWarn: false,
missingWarn: false,
messages
})

View File

@ -311,14 +311,14 @@
"browse": {
"albums": "albums",
"show-more": "Afficher plus",
"pistes": "pistes",
"tracks": "pistes",
"recently-added": {
"albums": "albums",
"title": "Ajouts récents"
},
"recently-played": {
"title": "Lectures récentes",
"pistes": "pistes"
"tracks": "pistes"
},
"tabs": {
"albums": "Albums",

View File

@ -41,28 +41,40 @@
<table class="table">
<tbody>
<tr>
<th class="has-text-left" v-text="$t('page.about.artists')" />
<th
class="has-text-left"
v-text="$t('page.about.artists')"
/>
<td
class="has-text-right"
v-text="$filters.number(library.artists)"
/>
</tr>
<tr>
<th class="has-text-left" v-text="$t('page.about.albums')" />
<th
class="has-text-left"
v-text="$t('page.about.albums')"
/>
<td
class="has-text-right"
v-text="$filters.number(library.albums)"
/>
</tr>
<tr>
<th class="has-text-left" v-text="$t('page.about.tracks')" />
<th
class="has-text-left"
v-text="$t('page.about.tracks')"
/>
<td
class="has-text-right"
v-text="$filters.number(library.songs)"
/>
</tr>
<tr>
<th class="has-text-left" v-text="$t('page.about.total-playtime')" />
<th
class="has-text-left"
v-text="$t('page.about.total-playtime')"
/>
<td
class="has-text-right"
v-text="
@ -71,7 +83,10 @@
/>
</tr>
<tr>
<th class="has-text-left" v-text="$t('page.about.updated')" />
<th
class="has-text-left"
v-text="$t('page.about.updated')"
/>
<td class="has-text-right">
<span
v-text="
@ -87,7 +102,10 @@
</td>
</tr>
<tr>
<th class="has-text-left" v-text="$t('page.about.uptime')" />
<th
class="has-text-left"
v-text="$t('page.about.uptime')"
/>
<td class="has-text-right">
<span
v-text="$filters.timeFromNow(library.started_at, true)"
@ -110,7 +128,10 @@
<div class="columns is-centered">
<div class="column is-four-fifths">
<div class="content has-text-centered-mobile">
<p class="is-size-7" v-text="$t('page.about.version', { version: config.version })" />
<p
class="is-size-7"
v-text="$t('page.about.version', { version: config.version })"
/>
<p
class="is-size-7"
v-text="

View File

@ -26,11 +26,15 @@
<a
class="has-text-link"
@click="open_artist"
v-text="$t('page.artist.album-count', { count: artist.album_count })"
v-text="
$t('page.artist.album-count', { count: artist.album_count })
"
/>
<span>&nbsp;|&nbsp;</span>
<span
v-text="$t('page.artist.track-count', { count: artist.track_count })"
v-text="
$t('page.artist.track-count', { count: artist.track_count })
"
/>
</p>
<list-tracks :tracks="tracks.items" :uris="track_uris" />

View File

@ -26,9 +26,7 @@
<a
class="has-text-link"
@click="open_genre"
v-text="
$t('page.genre.album-count', { count: genre.album_count })
"
v-text="$t('page.genre.album-count', { count: genre.album_count })"
/>
<span>&nbsp;|&nbsp;</span>
<span

View File

@ -53,7 +53,7 @@
@click="open_search_tracks"
v-text="
$t('page.search.show-tracks', {
count: tracks.total.toLocaleString()
count: tracks.total.toLocaleString($i18n.locale)
})
"
/>
@ -82,7 +82,7 @@
@click="open_search_artists"
v-text="
$t('page.search.show-artists', {
count: artists.total.toLocaleString()
count: artists.total.toLocaleString(i18n.locale)
})
"
/>
@ -111,7 +111,7 @@
@click="open_search_albums"
v-text="
$t('page.search.show-albums', {
count: albums.total.toLocaleString()
count: albums.total.toLocaleString($i18n.locale)
})
"
/>
@ -140,7 +140,7 @@
@click="open_search_composers"
v-text="
$t('page.search.show-composers', {
count: composers.total.toLocaleString()
count: composers.total.toLocaleString($i18n.locale)
})
"
/>
@ -169,7 +169,7 @@
@click="open_search_playlists"
v-text="
$t('page.search.show-playlists', {
count: playlists.total.toLocaleString()
count: playlists.total.toLocaleString($i18n.locale)
})
"
/>
@ -198,7 +198,7 @@
@click="open_search_podcasts"
v-text="
$t('page.search.show-podcasts', {
count: podcasts.total.toLocaleString()
count: podcasts.total.toLocaleString($i18n.locale)
})
"
/>
@ -228,7 +228,7 @@
@click="open_search_audiobooks"
v-text="
$t('page.search.show-audiobooks', {
count: audiobooks.total.toLocaleString()
count: audiobooks.total.toLocaleString($i18n.locale)
})
"
/>

View File

@ -194,7 +194,16 @@ export default {
},
locale: {
get() {
return this.$i18n.locale
let languages = this.$i18n.availableLocales
let locale = languages.find(lang => lang === this.$i18n.locale)
let partial = this.$i18n.locale.split('-')[0]
if (!locale) {
locale = languages.find(lang => lang === partial)
}
if (!locale) {
locale = languages.forEach(lang => lang.split('-')[0] === partial)
}
return locale
},
set(locale) {
this.$i18n.locale = locale

View File

@ -79,7 +79,7 @@
@click="open_search_tracks"
v-text="
$t('page.spotify.search.show-all-tracks', {
count: tracks.total.toLocaleString()
count: tracks.total.toLocaleString($i18n.locale)
})
"
/>
@ -133,7 +133,7 @@
@click="open_search_artists"
v-text="
$t('page.spotify.search.show-all-artists', {
count: artists.total.toLocaleString()
count: artists.total.toLocaleString($i18n.locale)
})
"
/>
@ -199,7 +199,7 @@
@click="open_search_albums"
v-text="
$t('page.spotify.search.show-all-albums', {
count: albums.total.toLocaleString()
count: albums.total.toLocaleString($i18n.locale)
})
"
/>
@ -253,7 +253,7 @@
@click="open_search_playlists"
v-text="
$t('page.spotify.search.show-all-playlists', {
count: playlists.total.toLocaleString()
count: playlists.total.toLocaleString($i18n.locale)
})
"
/>