initial commit
This commit is contained in:
103
frontend/src/contexts/LanguageContext.jsx
Normal file
103
frontend/src/contexts/LanguageContext.jsx
Normal file
@@ -0,0 +1,103 @@
|
||||
import React, { createContext, useContext, useState } from 'react';
|
||||
|
||||
const LanguageContext = createContext();
|
||||
|
||||
export const useLanguage = () => {
|
||||
const context = useContext(LanguageContext);
|
||||
if (!context) {
|
||||
throw new Error('useLanguage must be used within a LanguageProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
const translations = {
|
||||
en: {
|
||||
// Header
|
||||
home: 'Home',
|
||||
about: 'About',
|
||||
contact: 'Contact',
|
||||
|
||||
// CTA Section
|
||||
readyToStart: 'Ready to get started?',
|
||||
ctaSubtitle: 'Join thousands of developers building amazing applications with our modern stack.',
|
||||
startBuilding: 'Start Building',
|
||||
|
||||
// Language Switcher
|
||||
language: 'Language',
|
||||
english: 'English',
|
||||
finnish: 'Finnish',
|
||||
|
||||
// Search Page
|
||||
searchPlaceholder: 'Enter your search query...',
|
||||
searchButton: 'Search',
|
||||
searchResults: 'Search Results',
|
||||
searchResultsSubtitle: 'Here are the results for your search query.',
|
||||
searchResultsPlaceholder: 'Search results will appear here. Try entering a search term above to get started.',
|
||||
|
||||
// Search Filters
|
||||
dogFriendly: 'Dog Friendly',
|
||||
accessible: 'Accessible',
|
||||
familyFriendly: 'Family Friendly',
|
||||
peopleCount: 'People',
|
||||
priceRange: 'Price',
|
||||
any: 'Any',
|
||||
|
||||
// Footer
|
||||
footerDescription: 'Find fun things to do!',
|
||||
},
|
||||
fi: {
|
||||
// Header
|
||||
home: 'Koti',
|
||||
about: 'Tietoja',
|
||||
contact: 'Yhteystiedot',
|
||||
|
||||
|
||||
// CTA Section
|
||||
readyToStart: 'Valmiina aloittamaan?',
|
||||
ctaSubtitle: 'Liity tuhansien kehittäjien joukkoon, jotka rakentavat upeita sovelluksia modernilla teknologiapinoamme.',
|
||||
startBuilding: 'Aloita rakentaminen',
|
||||
|
||||
// Language Switcher
|
||||
language: 'Kieli',
|
||||
english: 'Englanti',
|
||||
finnish: 'Suomi',
|
||||
|
||||
// Search Page
|
||||
searchPlaceholder: 'Syötä hakukyselysi...',
|
||||
searchButton: 'Hae',
|
||||
searchResults: 'Hakutulokset',
|
||||
searchResultsSubtitle: 'Tässä ovat hakutulokset kyselysi perusteella.',
|
||||
searchResultsPlaceholder: 'Hakutulokset näkyvät täällä. Kokeile syöttää hakusana yllä aloittaaksesi.',
|
||||
|
||||
// Search Filters
|
||||
dogFriendly: 'Koiraystävällinen',
|
||||
accessible: 'Esteetön',
|
||||
familyFriendly: 'Lapsiystävällinen',
|
||||
peopleCount: 'Henkilöt',
|
||||
priceRange: 'Hinta',
|
||||
any: 'Mikä tahansa',
|
||||
|
||||
// Footer
|
||||
footerDescription: 'Löydä hauskaa tekemistä!',
|
||||
}
|
||||
};
|
||||
|
||||
export const LanguageProvider = ({ children }) => {
|
||||
const [language, setLanguage] = useState('en');
|
||||
|
||||
const t = (key) => {
|
||||
return translations[language][key] || key;
|
||||
};
|
||||
|
||||
const value = {
|
||||
language,
|
||||
setLanguage,
|
||||
t
|
||||
};
|
||||
|
||||
return (
|
||||
<LanguageContext.Provider value={value}>
|
||||
{children}
|
||||
</LanguageContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user