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:
vicrodh committed 2026-01-15 08:57:13 -06:00
1 parent 72693e184f
commit 42349f14dd
6 files changed
+49 -7

No files matched your search

+17 -2
View File
@@ -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);
}