package lighthouse.utils;

import org.slf4j.*;

import javax.annotation.*;
import java.util.*;

import static gnu.gettext.GettextResource.*;

public class I18nUtil {
    private static final Logger log = LoggerFactory.getLogger(I18nUtil.class);
    @Nullable public static ResourceBundle locale;

    static {
        try {
            locale = ResourceBundle.getBundle("lighthouse.locale.lighthouse");
            log.info("Using language translations for {}", locale.getLocale());
        } catch (MissingResourceException e) {
            // Ignore.
        }
    }

    public static String tr(String s) {
        if (locale != null)
            return gettext(locale, s);
        else
            return s;
    }
}

package lighthouse.utils;

import org.jetbrains.annotations.*;
import org.slf4j.*;

import javax.annotation.Nullable;
import java.util.*;

import static gnu.gettext.GettextResource.*;

public class I18nUtil {
    private static final Logger log = LoggerFactory.getLogger(I18nUtil.class);
    @Nullable private static ResourceBundle locale;

    public static ResourceBundle translations = new ResourceBundle() {
        @Override
        protected Object handleGetObject(String key) {
            if (locale == null)
                return key;
            else
                try {
                    return locale.getObject(key);
                } catch (MissingResourceException e) {
                    return key;
                }
        }

        @Override
        public boolean containsKey(String key) {
            return true;
        }

        @NotNull
        @Override
        public Enumeration<String> getKeys() {
            if (locale != null)
                return locale.getKeys();
            else
                return Collections.emptyEnumeration();
        }
    };

    static {
        try {
            locale = ResourceBundle.getBundle("lighthouse.locale.lighthouse");
            log.info("Using language translations for {}", locale.getLocale());
        } catch (MissingResourceException e) {
            // Ignore.
        }
    }

    public static String tr(String s) {
        if (locale != null)
            return gettext(locale, s);
        else
            return s;
    }
}

Fix the case where a translation is missing and it's loaded via FXML with a custom ResourceBundle that never throws an error, it always returns the key (English string) if a real translation is missing.
i18n: Fix the case where a translation is missing and it's loaded via FXML with a custom ResourceBundle that never throws an error, it always returns the key (English string) if a real translation is missing.
