Add language translation system and weather widget with admin controls
This commit is contained in:
+159
@@ -0,0 +1,159 @@
|
||||
// Simple translation utility for La Huasca website
|
||||
|
||||
// Define languages
|
||||
export type Language = 'en' | 'es';
|
||||
|
||||
// Translation data
|
||||
export const translations = {
|
||||
en: {
|
||||
// Common
|
||||
'common.hotel': 'Hotel',
|
||||
'common.restaurant': 'Restaurant',
|
||||
'common.andean_highlands': 'Andean Highlands',
|
||||
'common.rooms_suites': 'Rooms & Suites',
|
||||
'common.social_events': 'Social Events',
|
||||
'common.coffee': 'Coffee',
|
||||
'common.landscape': 'Landscape',
|
||||
'common.comments': 'Comments',
|
||||
'common.user_portal': 'User Portal',
|
||||
'common.login': 'Login',
|
||||
'common.logout': 'Logout',
|
||||
|
||||
// Navigation
|
||||
'nav.brand': 'Brand',
|
||||
'nav.gallery': 'Images',
|
||||
'nav.slideshow': 'Slideshow',
|
||||
'nav.calendar': 'Calendar',
|
||||
'nav.social_events': 'Social Events',
|
||||
'nav.rooms': 'Rooms',
|
||||
'nav.menu': 'Menu',
|
||||
'nav.places': 'Places',
|
||||
'nav.reviews': 'Reviews',
|
||||
'nav.users': 'Users',
|
||||
'nav.weather': 'Weather',
|
||||
|
||||
// Weather widget
|
||||
'weather.currently': 'Currently',
|
||||
'weather.today': 'Today',
|
||||
'weather.max': 'Max',
|
||||
'weather.min': 'Min',
|
||||
'weather.wind': 'Wind',
|
||||
'weather.kmh': 'km/h',
|
||||
'weather_updated': 'Updated',
|
||||
|
||||
// Admin panel
|
||||
'admin.brand': 'Brand',
|
||||
'admin.gallery': 'Images',
|
||||
'admin.slideshow': 'Slideshow',
|
||||
'admin.calendar': 'Calendar',
|
||||
'admin.social_events': 'Social Events',
|
||||
'admin.rooms': 'Rooms',
|
||||
'admin.menu': 'Menu',
|
||||
'admin.places': 'Places',
|
||||
'admin.reviews': 'Reviews',
|
||||
'admin.users': 'Users',
|
||||
'admin.weather': 'Weather',
|
||||
|
||||
// Weather admin
|
||||
'admin.weather.title': 'Weather Widget',
|
||||
'admin.weather.description': 'Configure the weather widget displayed on the homepage',
|
||||
'admin.weather.enabled': 'Enable Weather Widget',
|
||||
'admin.weather.cities': 'Cities',
|
||||
'admin.weather.add_city': 'Add City',
|
||||
'admin.weather.city_name': 'City Name',
|
||||
'admin.weather.latitude': 'Latitude',
|
||||
'admin.weather.longitude': 'Longitude',
|
||||
'admin.weather.save': 'Save Settings',
|
||||
},
|
||||
es: {
|
||||
// Common
|
||||
'common.hotel': 'Hotel',
|
||||
'common.restaurant': 'Restaurante',
|
||||
'common.andean_highlands': 'Tierras Altas Andinas',
|
||||
'common.rooms_suites': 'Habitaciones & Suites',
|
||||
'common.social_events': 'Eventos Sociales',
|
||||
'common.coffee': 'Café',
|
||||
'common.landscape': 'Paisaje',
|
||||
'common.comments': 'Comentarios',
|
||||
'common.user_portal': 'Portal de Usuario',
|
||||
'common.login': 'Iniciar Sesión',
|
||||
'common.logout': 'Cerrar Sesión',
|
||||
|
||||
// Navigation
|
||||
'nav.brand': 'Marca',
|
||||
'nav.gallery': 'Imágenes',
|
||||
'nav.slideshow': 'Presentación',
|
||||
'nav.calendar': 'Calendario',
|
||||
'nav.social_events': 'Eventos Sociales',
|
||||
'nav.rooms': 'Habitaciones',
|
||||
'nav.menu': 'Menú',
|
||||
'nav.places': 'Lugares',
|
||||
'nav.reviews': 'Reseñas',
|
||||
'nav.users': 'Usuarios',
|
||||
'nav.weather': 'Clima',
|
||||
|
||||
// Weather widget
|
||||
'weather.currently': 'Actualmente',
|
||||
'weather.today': 'Hoy',
|
||||
'weather.max': 'Máx',
|
||||
'weather.min': 'Mín',
|
||||
'weather.wind': 'Viento',
|
||||
'weather.kmh': 'km/h',
|
||||
'weather_updated': 'Actualizado',
|
||||
|
||||
// Admin panel
|
||||
'admin.brand': 'Marca',
|
||||
'admin.gallery': 'Imágenes',
|
||||
'admin.slideshow': 'Presentación',
|
||||
'admin.calendar': 'Calendario',
|
||||
'admin.social_events': 'Eventos Sociales',
|
||||
'admin.rooms': 'Habitaciones',
|
||||
'admin.menu': 'Menú',
|
||||
'admin.places': 'Lugares',
|
||||
'admin.reviews': 'Reseñas',
|
||||
'admin.users': 'Usuarios',
|
||||
'admin.weather': 'Clima',
|
||||
|
||||
// Weather admin
|
||||
'admin.weather.title': 'Widget del Clima',
|
||||
'admin.weather.description': 'Configurar el widget del clima mostrado en la página de inicio',
|
||||
'admin.weather.enabled': 'Habilitar Widget del Clima',
|
||||
'admin.weather.cities': 'Ciudades',
|
||||
'admin.weather.add_city': 'Agregar Ciudad',
|
||||
'admin.weather.city_name': 'Nombre de la Ciudad',
|
||||
'admin.weather.latitude': 'Latitud',
|
||||
'admin.weather.longitude': 'Longitud',
|
||||
'admin.weather.save': 'Guardar Configuración',
|
||||
}
|
||||
};
|
||||
|
||||
// Simple translation function
|
||||
export function t(key: string, language: Language = 'en'): string {
|
||||
if (language === 'es' && key in translations.es) {
|
||||
return translations.es[key as keyof typeof translations.es];
|
||||
}
|
||||
|
||||
if (key in translations.en) {
|
||||
return translations.en[key as keyof typeof translations.en];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
// Get language from localStorage or default to 'en'
|
||||
export function getLanguage(): Language {
|
||||
if (typeof window !== 'undefined') {
|
||||
const savedLang = localStorage.getItem('language');
|
||||
if (savedLang && (savedLang === 'en' || savedLang === 'es')) {
|
||||
return savedLang as Language;
|
||||
}
|
||||
}
|
||||
return 'en';
|
||||
}
|
||||
|
||||
// Set language in localStorage
|
||||
export function setLanguage(lang: Language) {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem('language', lang);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user