package com.epimorphics.registry.language;

import com.epimorphics.registry.language.message.FileMessageManager;
import com.epimorphics.registry.language.message.MessageManager;
import com.epimorphics.registry.language.message.Messages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.List;

/**
 * Multilingual registry support.
 */
public interface LanguageManager {
    /**
     * Determine whether the registry is configured to support multiple languages.
     * @return True if and only if multiple languages are supported.
     */
    Boolean isMultilingual();

    /**
     * @return All of the supported languages.
     */
    List<Language> getLanguages();

    /**
     * Determines whether to use cookies to store users' language preference.
     * @return True if and only if cookies should be used. Otherwise, false.
     */
    Boolean getUseCookies();

    /**
     * @return The default language in which to render messages and registry content.
     */
    String getDefaultLanguage();

    /**
     * @param lang The two-letter code for the language.
     * @return The messages for the requested language, if available. Otherwise, a default language.
     */
    Messages getMessages(String lang);

    class Default implements LanguageManager {
        private final Logger log = LoggerFactory.getLogger(Default.class);
        private final MessageManager msgManager = new FileMessageManager();
        private final String defaultLang = "en";
        private final Messages defaultMsgs;

        Default() {
            Messages defaultMsgs = msgManager.getMessages(defaultLang);
            if (defaultMsgs == null) {
                log.warn("Messages for default language (" + defaultLang + ") are not configured.");
                defaultMsgs = new Messages.Empty();
            }

            this.defaultMsgs = defaultMsgs;
        }

        @Override public Boolean isMultilingual() { return false; }
        @Override public List<Language> getLanguages() { return Collections.emptyList(); }

        @Override public Boolean getUseCookies() { return false; }
        @Override public String getDefaultLanguage() { return defaultLang; }

        @Override public Messages getMessages(String lang) {
            return defaultMsgs;
        }
    }
}
@@ -1568,16 +1568,23 @@
         
+public 
 Default(

FIX class visibility