Added service/translation.js -> Implements a translation service that dynamically loads phrases based on user language preference.
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
// src/service/translation.js
|
||||||
|
import en from '../locales/en.json';
|
||||||
|
import fr from '../locales/fr.json';
|
||||||
|
|
||||||
|
const translations = { en, fr };
|
||||||
|
|
||||||
|
export const t = (key, lang = 'en') => {
|
||||||
|
return translations[lang][key] || key; // Fallback to key if missing
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user