fix(api): respect user locale for artist biography
- Add locale field to QobuzClient for API language preference - Pass lang parameter to Qobuz artist detail endpoints - Create set_api_locale command to update client locale - Sync API locale with UI i18n settings automatically - Render artist biography HTML tags properly using @html - Fix syntax error in FavoritesView (missing comma) cp
This commit is contained in:
1 parent
72693e184f
commit
42349f14dd
6 files changed
+49
-7
No files matched your search
@@ -468,9 +468,9 @@
|
||||
<!-- Biography -->
|
||||
{#if bioText}
|
||||
<div class="biography">
|
||||
<p class="bio-text">
|
||||
{bioExpanded ? bioText : truncatedBio}
|
||||
</p>
|
||||
<div class="bio-text">
|
||||
{@html bioExpanded ? bioText : truncatedBio}
|
||||
</div>
|
||||
{#if bioText.length > 300}
|
||||
<button class="bio-toggle" onclick={() => bioExpanded = !bioExpanded}>
|
||||
{#if bioExpanded}
|
||||
|
||||
@@ -879,7 +879,7 @@
|
||||
onRemoveDownload={onTrackRemoveDownload ? () => onTrackRemoveDownload(track.id) : undefined}
|
||||
menuActions={{
|
||||
onPlayNow: () => handleTrackClick(track, globalIndex),
|
||||
onPlayNext: onTrackPlayNext ? () => onTrackPlayNext(displayTrack) : undefined}
|
||||
onPlayNext: onTrackPlayNext ? () => onTrackPlayNext(displayTrack) : undefined,
|
||||
onPlayLater: onTrackPlayLater ? () => onTrackPlayLater(displayTrack) : undefined,
|
||||
onAddToPlaylist: onTrackAddToPlaylist ? () => onTrackAddToPlaylist(track.id) : undefined,
|
||||
onShareQobuz: onTrackShareQobuz ? () => onTrackShareQobuz(track.id) : undefined,
|
||||
|
||||
+17
-2
@@ -1,5 +1,6 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { init, register, getLocaleFromNavigator, locale } from 'svelte-i18n';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
// Register locales
|
||||
register('en', () => import('./locales/en.json'));
|
||||
@@ -7,10 +8,18 @@ register('es', () => import('./locales/es.json'));
|
||||
|
||||
// Initialize i18n
|
||||
export function initI18n() {
|
||||
const initialLocale = browser ? getStoredLocale() || getLocaleFromNavigator() : 'en';
|
||||
init({
|
||||
fallbackLocale: 'en',
|
||||
initialLocale: browser ? getStoredLocale() || getLocaleFromNavigator() : 'en',
|
||||
initialLocale,
|
||||
});
|
||||
|
||||
// Set the API locale to match
|
||||
if (browser) {
|
||||
invoke('set_api_locale', { locale: initialLocale }).catch((err) => {
|
||||
console.warn('Failed to set API locale:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Get stored locale from localStorage
|
||||
@@ -20,9 +29,15 @@ function getStoredLocale(): string | null {
|
||||
}
|
||||
|
||||
// Set and persist locale
|
||||
export function setLocale(newLocale: string) {
|
||||
export async function setLocale(newLocale: string) {
|
||||
if (browser) {
|
||||
localStorage.setItem('qbz-locale', newLocale);
|
||||
// Also update the API client locale
|
||||
try {
|
||||
await invoke('set_api_locale', { locale: newLocale });
|
||||
} catch (err) {
|
||||
console.warn('Failed to update API locale:', err);
|
||||
}
|
||||
}
|
||||
locale.set(newLocale);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user