i18n: Add greeting and toast translations
- Add time-based greeting translations (goodMorning, goodAfternoon, goodEvening, goodNight) to homeSettings section - Update homeSettingsStore to export getGreetingInfo for i18n support - Update HomeView.svelte to use translated greetings - Add comprehensive toast translations (~60 keys) for all user-facing notifications including queue, playback, offline, favorites, etc. - Update +page.svelte to use $t() for all showToast calls - Complete Spanish translations for all new keys
This commit is contained in:
1 parent
a742c22c8f
commit
2dc9989d22
5 files changed
+356
-89
No files matched your search
@@ -280,7 +280,7 @@ export function setCustomGreeting(text: string | null): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get greeting text for display
|
||||
* Get greeting text for display (legacy - use getGreetingInfo for i18n support)
|
||||
*/
|
||||
export function getGreetingText(userName: string): string {
|
||||
if (settings.greeting.customText) {
|
||||
@@ -290,7 +290,45 @@ export function getGreetingText(userName: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time-based greeting
|
||||
* Get greeting info for i18n-aware display
|
||||
* Returns either custom text or a translation key with params
|
||||
*/
|
||||
export function getGreetingInfo(userName: string): { type: 'custom'; text: string } | { type: 'key'; key: string; name: string } {
|
||||
const firstName = getFirstName(userName);
|
||||
|
||||
if (settings.greeting.customText) {
|
||||
return {
|
||||
type: 'custom',
|
||||
text: settings.greeting.customText.replace('{name}', firstName)
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'key',
|
||||
key: getTimeBasedGreetingKey(),
|
||||
name: firstName
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time-based greeting translation key
|
||||
*/
|
||||
export function getTimeBasedGreetingKey(): string {
|
||||
const hour = new Date().getHours();
|
||||
|
||||
if (hour >= 5 && hour < 12) {
|
||||
return 'homeSettings.goodMorning';
|
||||
} else if (hour >= 12 && hour < 17) {
|
||||
return 'homeSettings.goodAfternoon';
|
||||
} else if (hour >= 17 && hour < 21) {
|
||||
return 'homeSettings.goodEvening';
|
||||
} else {
|
||||
return 'homeSettings.goodNight';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time-based greeting (legacy)
|
||||
*/
|
||||
function getTimeBasedGreeting(userName: string): string {
|
||||
const hour = new Date().getHours();
|
||||
|
||||
Reference in new issue
Block a user