package eu.dnetlib.efg1914.various.utils;

import eu.dnetlib.efg1914.authoring.components.dao.ItemDAO;
import eu.dnetlib.efg1914.authoring.components.dao.ThemeDAO;
import eu.dnetlib.efg1914.various.locales.MyLocale;
import org.apache.velocity.VelocityContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import java.io.IOException;

/**
 * Created by argirok on 28/7/2014.
 */
public class SetLocalesVariables {

    public static void setContextVariables(VelocityContext context, String lan, String locale, String locale2, String showLanguages) {
        try {

            MyLocale myLocale = new MyLocale(lan);
            context.put("home", myLocale.getValue("menu.home"));
            context.put("chronology", myLocale.getValue("menu.chronology"));
            context.put("credits", myLocale.getValue("menu.credits"));
            context.put("tooltip", myLocale.getValue("menu.tooltip"));

            if(lan.equals(locale)){
                context.put("class", myLocale.getValue("selectedLanguage"));
                context.put("class2", myLocale.getValue(" "));

            }else{
                context.put("class2", myLocale.getValue("selectedLanguage"));
                context.put("class", myLocale.getValue(" "));

            }
            MyLocale l1 = new MyLocale(locale);
            context.put("language", l1.getLanguage());
            context.put("locale", l1.getLocale());
            context.put("languageTooltip", l1.getTooltip());
            MyLocale l2 = new MyLocale(locale2);
            context.put("language2", l2.getLanguage());
            context.put("locale2", l2.getLocale());
            context.put("languageTooltip2", l2.getTooltip());
            context.put("showLanguages", showLanguages);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
