public static function setupTextDomain() {
        global $CFG, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD, $TSUGI_TRANSLATE;

        $domain = $CFG->getScriptFolder();
        $folder = $CFG->getScriptPathFull()."/locale";

        // error_log("setupTextDomain($domain, $folder, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD)");

        $TSUGI_LOCALE_RELOAD = false;
        $TSUGI_TRANSLATE = false;

        if ( isset($CFG->legacytranslation) && $CFG->legacytranslation ) {
            if (function_exists('bindtextdomain')) {
                bindtextdomain("master", $CFG->dirroot."/locale");
                bindtextdomain($domain, $folder);
            }
            if (function_exists('textdomain')) {
                textdomain($domain);
            }
            return;
        }

        $lang = substr($TSUGI_LOCALE, 0, 2);
        // error_log("lang=$lang");
        $master_file = $CFG->dirroot."/locale/$lang/LC_MESSAGES/master.mo";
        $domain_file = $CFG->getScriptPathFull()."/locale/$lang/LC_MESSAGES/$domain.mo";
        $TSUGI_TRANSLATE = new Translator($lang, new MessageSelector());
        if ( file_exists($master_file) ) {
            $TSUGI_TRANSLATE->addLoader('master', new MoFileLoader());
            $TSUGI_TRANSLATE->addResource('master', $master_file, $lang);
        }

        if ( file_exists($domain_file) ) {
            $TSUGI_TRANSLATE->addLoader($domain, new MoFileLoader());
            $TSUGI_TRANSLATE->addResource($domain, $domain_file, $lang);
        }

    }