mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-24 06:07:45 -06:00
refactor: update TypeScript build process and dependencies
- Changed the build command in package.json to use TypeScript compiler (tsc) with noEmit option. - Added @swc/core and @swc/helpers as development dependencies for improved performance. refactor: clean up WhatsApp Baileys service - Removed unused properties and interfaces related to message keys. - Simplified message handling logic by removing redundant checks and conditions. - Updated message timestamp handling for consistency. - Improved readability and maintainability by restructuring code and removing commented-out sections. refactor: optimize Chatwoot service - Streamlined database queries by reusing PostgreSQL client connection. - Enhanced conversation creation logic with better cache handling. - Removed unnecessary methods and improved existing ones for clarity. - Updated message sending logic to handle file streams instead of buffers. fix: improve translation loading mechanism - Simplified translation file loading by removing environment variable checks. - Ensured translations are loaded from a consistent path within the project structure.
This commit is contained in:
@@ -3,37 +3,21 @@ import fs from 'fs';
|
||||
import i18next from 'i18next';
|
||||
import path from 'path';
|
||||
|
||||
// Make translations base directory configurable via environment variable
|
||||
const envBaseDir = process.env.TRANSLATIONS_BASE_DIR;
|
||||
let baseDir: string;
|
||||
|
||||
if (envBaseDir) {
|
||||
// Use explicitly configured base directory
|
||||
baseDir = envBaseDir;
|
||||
} else {
|
||||
// Fallback to auto-detection if env variable is not set
|
||||
const isProduction = fs.existsSync(path.join(process.cwd(), 'dist'));
|
||||
baseDir = isProduction ? 'dist' : 'src/utils';
|
||||
}
|
||||
|
||||
const translationsPath = path.join(process.cwd(), baseDir, 'translations');
|
||||
|
||||
const languages = ['en', 'pt-BR', 'es'];
|
||||
const translationsPath = path.join(__dirname, 'translations');
|
||||
const configService: ConfigService = new ConfigService();
|
||||
|
||||
const resources: any = {};
|
||||
|
||||
if (translationsPath) {
|
||||
languages.forEach((language) => {
|
||||
const languagePath = path.join(translationsPath, `${language}.json`);
|
||||
if (fs.existsSync(languagePath)) {
|
||||
const translationContent = fs.readFileSync(languagePath, 'utf8');
|
||||
resources[language] = {
|
||||
translation: JSON.parse(translationContent),
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
languages.forEach((language) => {
|
||||
const languagePath = path.join(translationsPath, `${language}.json`);
|
||||
if (fs.existsSync(languagePath)) {
|
||||
const translationContent = fs.readFileSync(languagePath, 'utf8');
|
||||
resources[language] = {
|
||||
translation: JSON.parse(translationContent),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
i18next.init({
|
||||
resources,
|
||||
|
||||
Reference in New Issue
Block a user