static function loadModeLanguagePack($mode, $output_encoding = "utf-8", $replace = false)
    {
        $langfile = ReporticoUtility::findBestLocationInIncludePath("language");

        // Look for encoding specific language file
        if (ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") && ReporticoApp::getConfig("SW_OUTPUT_ENCODING") != "UTF8" && is_dir($langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::getConfig("SW_OUTPUT_ENCODING") . "/" . $mode)) {
            $langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . ReporticoApp::isSetConfig("SW_OUTPUT_ENCODING") . "/" . $mode . ".php";
            require $langfile;
        } else {
            $langfile = $langfile . "/" . ReporticoApp::getConfig("language") . "/" . $mode . ".php";
            if (!is_file($langfile)) {
                trigger_error("Language pack for mode  $mode, language " . ReporticoApp::getConfig("language") . " not found", E_USER_ERROR);
            } else {
                require $langfile;
                // Convert UTF-8 mode to output character set if differen from native language pack
                if (strtolower($output_encoding) != "utf-8") {
                    foreach ($locale_arr["template"] as $k => $v) {
                        $locale_arr["template"][$k] = iconv("utf-8", $output_encoding, $v);
                    }
                }
                
                $local = ReporticoApp::get("locale");
                if (!($local) || !is_array(($local)) || $replace) {
                    ReporticoApp::set("locale", $locale_arr);
                } else {
                    if (is_array($local["template"]) && is_array($locale_arr) && is_array($locale_arr["template"])) {
                        $arr = array("template" => array_merge($local["template"], $locale_arr["template"]));
                        ReporticoApp::set("locale", $arr);
                    }
                }
            }
        }
    }