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

View File

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

View File

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

View File

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

View File

@ -26,11 +26,15 @@
<a <a
class="has-text-link" class="has-text-link"
@click="open_artist" @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>&nbsp;|&nbsp;</span>
<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> </p>
<list-tracks :tracks="tracks.items" :uris="track_uris" /> <list-tracks :tracks="tracks.items" :uris="track_uris" />

View File

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

View File

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

View File

@ -194,7 +194,16 @@ export default {
}, },
locale: { locale: {
get() { 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) { set(locale) {
this.$i18n.locale = locale this.$i18n.locale = locale

View File

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