var arrLang = {
    "en": {
        "HOME": "HOME",
        "ABOUT": "ABOUT US",
        "ADVANTAGE": "ADVANTAGE",
        "CUSTOMER_SAID": "FEEDBACK",
        "INTERFACE": "INTERFACE",
        "DOWNLOAD": "DOWNLOAD",
        "CONTACT": "CONTACT",

        "IMAGE1": "assets/img/gef/ios_download_en.png",
        "IMAGE2": "assets/img/gef/Android_download_en.png",
        "IMAGE3": "assets/img//gef/download_en.png",

        "IMAGE4": "assets/img/gef/home_en.png",
        "IMAGE5": "assets/img/gef/dynamic_en.png",
        "IMAGE6": "assets/img/gef/team_en.png",
        "IMAGE7": "assets/img/gef/my_en.png",
        "IMAGE8": "assets/img/gef/yj_en.png",
        "IMAGE_TX1": "assets/img/gef/tx1.jpg",
        "IMAGE_TX": "assets/img/gef/tx.png",

        "TEXT1": "A comprehensive platform in golf industry",
        "TEXT2": "Specialized in scoring, tournament organizing and team managing",
        "TEXT3": "Covering the majority of golf courses in the Philippines, the most favorite online scoring system. user-friendly and entertaining",
        "TEXT4": "Awesome functions",
        "TEXT5": "Developed by a top team with big investment, took over a year in the making just to provide you an excellent golfing experience",
        "TEXT6": "Scorecard",
        "TEXT7": "scoring, amending and team mate score checking",
        "TEXT8": "Team management",
        "TEXT9": "organize or join a team to start your game",
        "TEXT10": "Tournaments",
        "TEXT11": "easily to organize or join a tournament",
        "TEXT12": "Explore",
        "TEXT13": "share your golf life",
        "TEXT14": "Moments",
        "TEXT15": "to see more funs in golfing",
        "TEXT16": "Best of the month",
        "TEXT17": "record your best score each month, monitor your progress",
        "TEXT18": "The thrilling experience",
        "TEXT19": "Record score anytime, help to organize your team",
        "TEXT20": "show all games and tournaments, easily to start a game with",
        "TEXT21": "show the highlight moment of the players",
        "TEXT22": "show the present day games, enjoy watching them play",
        "TEXT23": "to join a game which you like or who you want to  partner with",
        "TEXT24": "to organize or join a team",
        "TEXT25": "More functions",
        "TEXT26": "obviously our other functions are also very usable",
        "TEXT27": "Real time",
        "TEXT28": "recent score and real time",
        "TEXT29": "Watch the game",
        "TEXT30": "no time to play, then watch your friends' game",
        "TEXT31": "More uses",
        "TEXT32": "more functions to launch later on",
        "TEXT33": "Application Interface",
        "TEXT34": "Main function interface views",
        "TEXT35": "Comment",
        "TEXT36": "Users comment sharing",
        "TEXT37": "Easygolf has been a great platform for golf enthusiast. Great way to communicate and socialize with other players plus they have cool features and variety of functions. It is always nice to see other golfers sharing their scores and moments here. Best app ever!",
        "TEXT371": "I so love this app, everything that you need is HERE. I made more new friends and golf buddies here",
        "TEXT372": "Abrasham",
        "TEXT373": "Brant",

        "TEXT38": "Golfer",
        "TEXT39": "Applicable to the systems below",
        "TEXT40": "Easygolf is dedicated in golf field, focus on each niche market. we are committed to provide you a best experience in golf including socialization, information and technology support ",
        "TEXT401": "download to experience more exclusive functions and enjoy more in your golf life",


        "TEXT41": "Subscribe to our news",
        "TEXT42": "although you've done reading until the last page, may you be interested in us? subscribe now to receive the latest news and infos from us",
        "TEXT43": "Submit now",
        "TEXT44": "Please enter your email address",
        "TEXT45": "Unit 2502, Entrata Building, Civic Drive, Filinvest City, Brgy. Alabang, Muntinlupa City, Philippines",
        "TEXT46": "© Copyright 2021-2023 Easygolf All Rights Reserved."

    },
    "zh": {
        "HOME": "首页",
        "ABOUT": "关于",
        "ADVANTAGE": "优势",
        "CUSTOMER_SAID": "客户说",
        "INTERFACE": "界面",
        "DOWNLOAD": "下载",
        "CONTACT": "联系",

        "IMAGE1": "assets/img/gef/ios_download.png",
        "IMAGE2": "assets/img/gef/Android_download.png",
        "IMAGE3": "assets/img//gef/download.png",

        "IMAGE4": "assets/img/gef/home.png",
        "IMAGE5": "assets/img/gef/dynamic.png",
        "IMAGE6": "assets/img/gef/team.png",
        "IMAGE7": "assets/img/gef/my.png",
        "IMAGE8": "assets/img/gef/yj.png",

        "IMAGE_TX1": "assets/img/gef/tx2.png",
        "IMAGE_TX": "assets/img/gef/tx3.jpg",

        "TEXT1": "高尔夫领域专业综合平台",
        "TEXT2": "专业计分、赛事举办以及球队管理",
        "TEXT3": "涵盖菲律宾各大球场，无数用户喜爱的线上计分平台，更方便、更快捷、更高效",
        "TEXT4": "惊人的应用功能",
        "TEXT5": "顶级团队斥资千万打造，随时记录打球分数、组建团队，获得千万人的喜爱",
        "TEXT6": "记分卡",
        "TEXT7": "快速记载成绩和查询队友成绩",
        "TEXT8": "高尔夫球队",
        "TEXT9": "组建和加入球队 和球员一起纵横球场",
        "TEXT10": "高尔夫比赛",
        "TEXT11": "快速组建或加入比赛",
        "TEXT12": "动态",
        "TEXT13": "分享高球信息",
        "TEXT14": "精彩时刻",
        "TEXT15": "收录高分球随时看见精彩",
        "TEXT16": "月最佳总杆",
        "TEXT17": "收录每月最佳总杆一键看到进步",
        "TEXT18": "Easygolf 最难忘的体验",
        "TEXT19": "随时记录打球分数、组建团队，获得无数人的喜爱",
        "TEXT20": "首页展示进行中比赛，快速进入比赛计分",
        "TEXT21": "众多平台用户精彩时刻",
        "TEXT22": "罗列当天所有比赛，围观赛事",
        "TEXT23": "加入热门比赛，与偶像一起打球",
        "TEXT24": "加入/组建球队",
        "TEXT25": "我们的其他功能",
        "TEXT26": "显然，我们的其他功能也非常牛",
        "TEXT27": "全面响应",
        "TEXT28": "实时响应最新计分",
        "TEXT29": "围观比赛",
        "TEXT30": "没有时间去球场可以围观比赛",
        "TEXT31": "无限功能",
        "TEXT32": "后期功能 陆续上线",
        "TEXT33": "应用截图",
        "TEXT34": "更多主要功能入口展示",
        "TEXT35": "评论",
        "TEXT36": "很高兴，分享我们的客户的评论",
        "TEXT37": "我的天啊！ 我不敢相信在Easygolf能这么的方便，随时可以填写、修改分数，用Easygolf后我的成绩达到了一个非常不可思议的地步。",
        "TEXT371": "动态这个区域太棒了。遇到许多志同道合的朋友，大家一起讨论高尔夫技巧，晒晒自己的记分卡，非常棒！",
        "TEXT372": "李凯欧",
        "TEXT373": "夏洛特",

        "TEXT38": "高球爱好者",
        "TEXT39": "Easygolf 适用以下相关设备",
        "TEXT40": "Easygolf 专注高尔夫专业领域，深耕各细分市场。致力于打造，建立集交友，资讯和技术服务等全方位的生态圈。适用基于android、ios系统的相关设备。",
        "TEXT401": "下载体验更多专属功能，尽享精彩高尔夫人生。",

        "TEXT41": "订阅我们的消息",
        "TEXT42": "既然已经看到这儿了，对我们感兴趣吧。订阅我们的消息，获得更多软件最新资讯哦",
        "TEXT43": "立即提交",
        "TEXT44": "请输入邮箱号",
        "TEXT45": "Unit 2502, Entrata Building, Civic Drive, Filinvest City, Brgy. Alabang, Muntinlupa City, Philippines",
        "TEXT46": "版权所有2021-2023 Easygolf 保留所有权利。",

    }
};

// The default language is English
var lang = "en";
// Check for localStorage support
if ('localStorage' in window) {
    var lang = localStorage.getItem('lang') || navigator.language.slice(0, 2);
    if (!Object.keys(arrLang).includes(lang)) lang = 'en';
}

$(document).ready(function() {
    $(".lang").each(function(index, element) {
        $(this).text(arrLang[lang][$(this).attr("key")]);
        if (lang === 'en' && $(window).width() <= 767) {
            if ($(this).attr("key") == 'TEXT2') {
                console.log($(this).parent())
                $(this).parent()[0].setAttribute("style", "margin-top: 10px;font-size: 38px;font-weight: 100;line-height: 43px;");
            }
            if ($(this).attr("key") == 'TEXT3') {
                $(this).parent()[0].style.cssText = 'font-size: 24px;font-weight: 300;color: #c2c0c0;line-height: 20px;margin-top:60px;';
            }
        }

    });
    $(".img_lang").each(function(index, element) {
        $(this).attr('src', arrLang[lang][$(this).attr("key")]);
    });
    $(".en-zh-input").each(function(index, element) {
        $(this).attr('placeholder', arrLang[lang][$(this).attr("key")]);
    })


    $('#zh').click(function() {
        localStorage.setItem('lang', 'zh')
        window.location.reload()
    })
    $('#en').click(function() {
        localStorage.setItem('lang', 'en')
        window.location.reload()
    })
    $('#fr').click(function() {
        localStorage.setItem('lang', 'fr')
        window.location.reload()
    })
    $('#su').click(function() {
        localStorage.setItem('lang', 'su')
        window.location.reload()
    })

});

// get/set the selected language
$(".translate").click(function() {
    var lang = $(this).attr("id");

    // update localStorage key
    if ('localStorage' in window) {
        localStorage.setItem('lang', lang);
        console.log(localStorage.getItem('lang'));
    }

    $(".lang").each(function(index, element) {
        $(this).text(arrLang[lang][$(this).attr("key")]);
    });
});
