Start simple translation approach
This commit is contained in:
15
translations/translations.js
Normal file
15
translations/translations.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const loadTranslation = (languageCode) => {
|
||||
try {
|
||||
const filePath = path.join(__dirname, 'translations', `${languageCode}.json`);
|
||||
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
} catch (error) {
|
||||
console.error('Error loading translation:', error);
|
||||
if(languageCode !== 'en') {
|
||||
return loadTranslation('en'); // Fallback to English if the specific language file is missing
|
||||
}
|
||||
return {}; // Fallback to empty object if language file is missing
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user