import En from '@/static/lang/en.js'
import Zh from '@/static/lang/zh.js'
import Fr from '@/static/lang/fr.js'


// 定义一个对象来映射语言代码和对应的语言包
const languages = {
    'zh': Zh,
    'en': En,
    'fr': Fr
};
const languageData = {
    'zh': {
        label: 'label',
        title: 'titleZh',
        name: 'nameZh',
        guojiaName: 'guojiaName',
        shiName: 'shiName',
        startTitle: 'startTitleZh',
        destTitle: 'destTitleZh',
        attrName: 'attrName',
        content: 'contentZh',
        destCountryTitle: 'destCountryTitleZh',
        prodTitle: 'prodTitleZh',
        remarks: 'remarksZh',
        desc: 'descZh',
        coverImage: 'coverImageZh',
        activityDesc: 'activityDescZh',
    },
    'en': {
        label: 'labelEn',
        title: 'titleEn',
        name: 'nameEn',
        guojiaName: 'guojiaNameEn',
        shiName: 'shiNameEn',
        startTitle: 'startTitleEn',
        destTitle: 'destTitleEn',
        attrName: 'attrNameEn',
        content: 'contentEn',
        destCountryTitle: 'destCountryTitleEn',
        prodTitle: 'prodTitleEn',
        remarks: 'remarksEn',
        desc: 'descEn',
        coverImage: 'coverImageEn',
        activityDesc: 'activityDescEn',
    },
    'fr': {
        label: 'labelFr',
        title: 'titleFr',
        name: 'nameFr',
        guojiaName: 'guojiaNameFr',
        shiName: 'shiNameFr',
        startTitle: 'startTitleFr',
        destTitle: 'destTitleFr',
        attrName: 'attrNameFr',
        content: 'contentFr',
        destCountryTitle: 'destCountryTitleFr',
        prodTitle: 'prodTitleFr',
        remarks: 'remarksFr',
        desc: 'descFr',
        coverImage: 'coverImageFr',
        activityDesc: 'activityDescFr',
    }
};


function getAppLanguages(local = 'zh') {
    return languages[local] || languages['zh']; // 默认返回中文语言包
}

function getLanguageData(local = 'zh') {
    return {
        label: languageData[local].label,
        title: languageData[local].title,
        name: languageData[local].name,
        guojiaName: languageData[local].guojiaName,
        shiName: languageData[local].shiName,
        startTitle: languageData[local].startTitle,
        destTitle: languageData[local].destTitle,
        attrName: languageData[local].attrName,
        content: languageData[local].content,
        destCountryTitle: languageData[local].destCountryTitle,
        prodTitle: languageData[local].prodTitle,
        remarks: languageData[local].remarks,
        desc: languageData[local].desc,
        coverImage: languageData[local].coverImage,
    };
}

export default {
    lang: getAppLanguages(uni.getStorageSync("locale") || 'zh'),
    locale: uni.getStorageSync('locale') || 'zh',
    ...getLanguageData(uni.getStorageSync('locale') || 'zh'),
    setLang(msg) {
        debugger
        this.lang = languages[msg] || languages['zh']; // 默认返回中文语言包
        this.locale = msg
    },

}

