"use strict";
/*
 * SomonScript CLI Internationalization Module
 * Copyright (c) 2025 LindenTech IT Consulting
 *
 * Licensed under the MIT License. See the LICENSE file for details.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.t = exports.i18n = void 0;
class I18n {
    constructor() {
        this.language = 'en';
        this.translations = new Map();
        this.detectLanguage();
        this.loadTranslations();
    }
    detectLanguage() {
        // Check environment variables
        const envLang = process.env.SOMON_LANG || process.env.LANG || process.env.LC_ALL || process.env.LC_MESSAGES;
        if (envLang) {
            if (envLang.includes('tj') || envLang.includes('tg')) {
                this.language = 'tj';
            }
            else if (envLang.includes('ru')) {
                this.language = 'ru';
            }
            else {
                this.language = 'en';
            }
        }
        // Check CLI argument for language override
        const langIndex = process.argv.indexOf('--lang');
        if (langIndex !== -1 && process.argv[langIndex + 1]) {
            const lang = process.argv[langIndex + 1];
            if (lang === 'tj' || lang === 'ru' || lang === 'en') {
                this.language = lang;
            }
        }
    }
    loadTranslations() {
        // Lazy load translations based on selected language
        this.translations.set('en', require('./translations/en').default);
        this.translations.set('tj', require('./translations/tj').default);
        this.translations.set('ru', require('./translations/ru').default);
    }
    setLanguage(lang) {
        this.language = lang;
    }
    getLanguage() {
        return this.language;
    }
    t() {
        return this.translations.get(this.language) || this.translations.get('en');
    }
    get isRTL() {
        // Tajik and Russian both use left-to-right writing
        return false;
    }
}
// Singleton instance
exports.i18n = new I18n();
const t = () => exports.i18n.t();
exports.t = t;
//# sourceMappingURL=index.js.map