/*
 * Copyright (c) 2013 - 2017 xxyy (Philipp Nowak; xyc@l1t.li). All rights reserved.
 *
 * Any usage, including, but not limited to, compiling, running, redistributing, printing,
 *  copying and reverse-engineering is strictly prohibited without explicit written permission
 *  from the original author and may result in legal steps being taken.
 *
 * See the included LICENSE file (core/src/main/resources) for details.
 */

package li.l1t.common.i18n;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

public class Utf8Control extends ResourceBundle.Control {
    public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
            throws IllegalAccessException, InstantiationException, IOException {
        // below is basically a copy of the default implementation that just uses UTF-8
        String bundleName = toBundleName(baseName, locale);
        String resourceName = toResourceName(bundleName, "properties");
        InputStream stream = null;
        if (reload) {
            URL url = loader.getResource(resourceName);
            if (url != null) {
                URLConnection connection = url.openConnection();
                if (connection != null) {
                    connection.setUseCaches(false);
                    stream = connection.getInputStream();
                }
            }
        } else {
            stream = loader.getResourceAsStream(resourceName);
        }
        if (stream != null) {
            try (InputStreamReader reader = new InputStreamReader(stream, "UTF-8")) {
                return new PropertyResourceBundle(reader);
            }
        }
        return null;
    }
}

@@ -696,65 +696,1607 @@
 e;%0A%0A
-public class Utf8Control extends ResourceBundle.Control %7B
+/**%0A * A Resource Bundle Control which loads bundles in UTF-8 instead of the default encoding. This allows for maximum%0A * portability and ensures that a future-proof encoding is used. Further, it allows to specify the time-to-live value%0A * for the bundle, which specifies caching behaviour. See %7B@link #getTimeToLive(String, Locale)%7D for details.%0A */%0Apublic class Utf8Control extends ResourceBundle.Control %7B%0A    /**%0A     * A reusable control instance constructed using the %7B@link #Utf8Control() default constructor%7D.%0A     */%0A    public static final Utf8Control INSTANCE = new Utf8Control();%0A%0A    /**%0A     * A reusable control instance with a %7B@link #getTimeToLive(String, Locale) time to live%7D of%0A     * %7B@link #TTL_DONT_CACHE%7D, which disables the bundle cache.%0A     *%0A     * @see #Utf8Control(long)%0A     */%0A    public static final Utf8Control NO_CACHE = new Utf8Control();%0A%0A    private final long timeToLive;%0A%0A    /**%0A     * Creates a new UTF-8 control with the default time to live of %7B@link #TTL_NO_EXPIRATION_CONTROL%7D.%0A     */%0A    public Utf8Control() %7B%0A        this(TTL_NO_EXPIRATION_CONTROL);%0A    %7D%0A%0A    /**%0A     * Creates a new UTF-8 control.%0A     *%0A     * @param timeToLive the %7B@link #getTimeToLive(String, Locale) time to live%7D to use for all created bundles%0A     */%0A    public Utf8Control(long timeToLive) %7B%0A        this.timeToLive = timeToLive;%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     * %3Cp%3E%7B@link Utf8Control%7D returns the time to live passed to its constructor.%3C/p%3E%0A     */%0A    @Override%0A    public long getTimeToLive(String baseName, Locale locale) %7B%0A        return timeToLive;%0A    %7D%0A
 %0A   

Add TTL support to Uf8Control