@@ -0,0 +1,2564 @@
+package com.wizzardo.http.framework.message;%0A%0Aimport java.util.*;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0A/**%0A * Created by wizzardo on 22.05.15.%0A */%0Apublic class MessageBundle implements MessageSource %7B%0A%0A    protected List%3CString%3E sourcesNames = new ArrayList%3C%3E();%0A    protected TemplateMessageSource defaultSource = new TemplateMessageSource();%0A    protected Map%3CLocale, TemplateMessageSource%3E sources = new ConcurrentHashMap%3C%3E();%0A    protected TemplateMessageSource defaultLocalizedSource;%0A    protected Locale defaultLocale;%0A%0A    @Override%0A    public String get(String key, Object... args) %7B%0A        return get(defaultLocalizedSource, key, args);%0A    %7D%0A%0A    public String get(Locale locale, String key, Object... args) %7B%0A        TemplateMessageSource messageSource;%0A        if (locale.equals(defaultLocale))%0A            messageSource = defaultLocalizedSource;%0A        else%0A            messageSource = getMessageSource(locale);%0A%0A        return get(messageSource, key, args);%0A    %7D%0A%0A    protected String get(MessageSource messageSource, String key, Object... args) %7B%0A        if (messageSource != null) %7B%0A            String result = messageSource.get(key, args);%0A            if (result != null)%0A                return result;%0A        %7D%0A%0A        return defaultSource.get(key, args);%0A    %7D%0A%0A    public MessageBundle load(String name) %7B%0A        sourcesNames.add(name);%0A        sources.clear();%0A%0A        load(name, defaultSource);%0A%0A        if (defaultLocale != null)%0A            setDefaultLocale(defaultLocale);%0A%0A        return this;%0A    %7D%0A%0A    protected TemplateMessageSource getMessageSource(Locale locale) %7B%0A        TemplateMessageSource messageSource = sources.get(locale);%0A        if (messageSource == null) %7B%0A            messageSource = new TemplateMessageSource();%0A            sources.put(locale, messageSource);%0A            for (String sourcesName : sourcesNames) %7B%0A                load(sourcesName + %22_%22 + locale.getLanguage(), messageSource);%0A            %7D%0A        %7D%0A        return messageSource;%0A    %7D%0A%0A    protected void load(String name, TemplateMessageSource messageSource) %7B%0A        try %7B%0A            PropertiesMessageSource temp = new PropertiesMessageSource(name);%0A            messageSource.templates.putAll(temp.templates);%0A        %7D catch (Exception ignored) %7B%0A        %7D%0A    %7D%0A%0A    public MessageBundle setDefaultLocale(Locale locale) %7B%0A        defaultLocale = locale;%0A        defaultLocalizedSource = getMessageSource(defaultLocale);%0A        return this;%0A    %7D%0A%0A    public Locale getDefaultLocale() %7B%0A        return defaultLocale;%0A    %7D%0A%7D%0A

add MessageBundle