class MessageLocalization {

    private static final String BASE_PATH = "com/lowagie/text/error_messages/";
    private static Map<String, String> defaultLanguage = new HashMap<>();
    private static Map<String, String> currentLanguage;

    static {
        try {
            defaultLanguage = getLanguageMessages("en", null);
        } catch (Exception ex) {
            // do nothing
        }
        if (defaultLanguage == null) {
            defaultLanguage = new HashMap<>();
        }
    }

    private MessageLocalization() {
    }

    /**
     * Get a message without parameters.
     *
     * @param key the key to the message
     * @return the message
     */
    public static String getMessage(String key) {
        Map<String, String> cl = currentLanguage;
        String val;
        if (cl != null) {
            val = cl.get(key);
            if (val != null) {
                return val;
            }
        }
        cl = defaultLanguage;
        val = cl.get(key);
        if (val != null) {
            return val;
        }
        return "No message found for " + key;
    }

    /**
     * Get a message without parameters.
     *
     * @param key the key to the message
     * @return the message
     */
    public static String getComposedMessage(String key) {
        return getComposedMessage(key, null, null, null, null);
    }

    /**
     * Get a message with one parameter. The parameter will replace the string "{1}" found in the message.
     *
     * @param key the key to the message
     * @param p1  the parameter
     * @return the message
     */
    public static String getComposedMessage(String key, Object p1) {
        return getComposedMessage(key, p1, null, null, null);
    }

    /**
     * Get a message with one parameter. The parameter will replace the string "{1}" found in the message.
     *
     * @param key the key to the message
     * @param p1  the parameter
     * @return the message
     */
    public static String getComposedMessage(String key, int p1) {
        return getComposedMessage(key, String.valueOf(p1), null, null, null);
    }

    /**
     * Get a message with one parameter. The parameter will replace the string "{1}", "{2}" found in the message.
     *
     * @param key the key to the message
     * @param p1  the parameter
     * @param p2  the parameter
     * @return the message
     */
    public static String getComposedMessage(String key, Object p1, Object p2) {
        return getComposedMessage(key, p1, p2, null, null);
    }

    /**
     * Get a message with one parameter. The parameter will replace the string "{1}", "{2}", "{3}" found in the
     * message.
     *
     * @param key the key to the message
     * @param p1  the parameter
     * @param p2  the parameter
     * @param p3  the parameter
     * @return the message
     */
    public static String getComposedMessage(String key, Object p1, Object p2, Object p3) {
        return getComposedMessage(key, p1, p2, p3, null);
    }

    /**
     * Get a message with two parameters. The parameters will replace the strings "{1}", "{2}", "{3}", "{4}" found in
     * the message.
     *
     * @param key the key to the message
     * @param p1  the parameter
     * @param p2  the parameter
     * @param p3  the parameter
     * @param p4  the parameter
     * @return the message
     */
    public static String getComposedMessage(String key, Object p1, Object p2, Object p3, Object p4) {
        String msg = getMessage(key);
        if (p1 != null) {
            msg = msg.replace("{1}", p1.toString());
        }
        if (p2 != null) {
            msg = msg.replace("{2}", p2.toString());
        }
        if (p3 != null) {
            msg = msg.replace("{3}", p3.toString());
        }
        if (p4 != null) {
            msg = msg.replace("{4}", p4.toString());
        }
        return msg;
    }

    /**
     * Sets the language to be used globally for the error messages. The language is a two letter lowercase country
     * designation like "en" or "pt". The country is an optional two letter uppercase code like "US" or "PT".
     *
     * @param language the language
     * @param country  the country
     * @return true if the language was found, false otherwise
     * @throws IOException on error
     */
    public static boolean setLanguage(String language, String country) throws IOException {
        Map<String, String> lang = getLanguageMessages(language, country);
        if (lang == null) {
            return false;
        }
        currentLanguage = lang;
        return true;
    }

    /**
     * Sets the error messages directly from a Reader.
     *
     * @param r the Reader
     * @throws IOException on error
     */
    public static void setMessages(Reader r) throws IOException {
        currentLanguage = readLanguageStream(r);
    }

    private static Map<String, String> getLanguageMessages(String language, String country) throws IOException {<FILL_FUNCTION_BODY>}

    private static Map<String, String> readLanguageStream(InputStream is) throws IOException {
        return readLanguageStream(new InputStreamReader(is, StandardCharsets.UTF_8));
    }

    private static Map<String, String> readLanguageStream(Reader r) throws IOException {
        Map<String, String> lang = new HashMap<>();
        BufferedReader br = new BufferedReader(r);
        String line;
        while ((line = br.readLine()) != null) {
            int idxeq = line.indexOf('=');
            if (idxeq < 0) {
                continue;
            }
            String key = line.substring(0, idxeq).trim();
            if (key.startsWith("#")) {
                continue;
            }
            lang.put(key, line.substring(idxeq + 1));
        }
        return lang;
    }

    // For tests only
    public static Set<String> getAllKeys() {
        return defaultLanguage.keySet();
    }
}

        if (language == null) {
            throw new IllegalArgumentException("The language cannot be null.");
        }
        InputStream is = null;
        try {
            String file;
            if (country != null) {
                file = language + "_" + country + ".lng";
            } else {
                file = language + ".lng";
            }
            is = BaseFont.getResourceStream(BASE_PATH + file, MessageLocalization.class.getClassLoader());
            if (is != null) {
                return readLanguageStream(is);
            }
            if (country == null) {
                return null;
            }
            file = language + ".lng";
            is = BaseFont.getResourceStream(BASE_PATH + file, MessageLocalization.class.getClassLoader());
            if (is != null) {
                return readLanguageStream(is);
            } else {
                return null;
            }
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (Exception ignored) {
                // do nothing
            }
        }
    
<no_super_class>