src/Core/I18N.php
public static function __($message, $textdomain=false) {
        global $CFG, $PDOX, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD, $TSUGI_TRANSLATE;
    
        // If we have been asked to do some translation
        if ( isset($CFG->checktranslation) && $CFG->checktranslation && isset($PDOX) ) 
        {
            $string_sha = U::lti_sha256($message);
            $domain = $textdomain;
            if ( ! $domain ) $domain = textdomain(NULL);
            if ( $domain ) {
                $stmt = $PDOX->queryReturnError("INSERT INTO {$CFG->dbprefix}tsugi_string
                        (domain, string_text, string_sha256) VALUES ( :DOM, :TEXT, :SHA)
                        ON DUPLICATE KEY UPDATE updated_at = NOW()",
                    array(
                        ':DOM' => $domain,
                        ':TEXT' => $message,
                        ':SHA' => $string_sha
                    )
                );
            }
        }

        // Setup Text domain late...
        if ( $TSUGI_LOCALE_RELOAD ) {
            self::setupTextDomain();
        }

        if ( isset($TSUGI_TRANSLATE) && $TSUGI_TRANSLATE ) {
            $retval = $TSUGI_TRANSLATE->trans($message);
            // error_log("DOM=$TSUGI_LOCALE msg=$message trans=$retval");
            return $retval;
        }

        if ( ! function_exists('gettext')) return $message;
        if ( $textdomain === false ) {
            return gettext($message);
        } else {
            return dgettext($textdomain, $message);
        }
    }
public static function __($message, $textdomain=false) {
        global $CFG, $PDOX, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD, $TSUGI_TRANSLATE;
    
        // If we have been asked to do some translation
        if ( isset($CFG->checktranslation) && $CFG->checktranslation && isset($PDOX) ) 
        {
            $string_sha = U::lti_sha256($message);
            $domain = $textdomain;
            if ( ! $domain ) $domain = textdomain(NULL);
            if ( $domain ) {
                $stmt = $PDOX->queryReturnError("INSERT INTO {$CFG->dbprefix}tsugi_string
                        (domain, string_text, string_sha256) VALUES ( :DOM, :TEXT, :SHA)
                        ON DUPLICATE KEY UPDATE updated_at = NOW()",
                    array(
                        ':DOM' => $domain,
                        ':TEXT' => $message,
                        ':SHA' => $string_sha
                    )
                );
            }
        }

        // Setup Text domain late...
        if ( $TSUGI_LOCALE_RELOAD ) {
            self::setupTextDomain();
        }

        if ( isset($TSUGI_TRANSLATE) && $TSUGI_TRANSLATE ) {
            $retval = $TSUGI_TRANSLATE->trans($message);
            // error_log("DOM=$TSUGI_LOCALE msg=$message trans=$retval");
            return $retval;
        }

        if ( ! function_exists('gettext')) return $message;
        if ( $textdomain === false ) {
            return gettext($message);
        } else {
            return dgettext($textdomain, $message);
        }
    }
public static function __ ( $ message , $ textdomain = false ) { global $ CFG , $ PDOX , $ TSUGI_LOCALE , $ TSUGI_LOCALE_RELOAD , $ TSUGI_TRANSLATE ; // If we have been asked to do some translation if ( isset ( $ CFG -> checktranslation ) && $ CFG -> checktranslation && isset ( $ PDOX ) ) { $ string_sha = U :: lti_sha256 ( $ message ) ; $ domain = $ textdomain ; if ( ! $ domain ) $ domain = textdomain ( NULL ) ; if ( $ domain ) { $ stmt = $ PDOX -> queryReturnError ( "INSERT INTO {$CFG->dbprefix}tsugi_string
                        (domain, string_text, string_sha256) VALUES ( :DOM, :TEXT, :SHA)
                        ON DUPLICATE KEY UPDATE updated_at = NOW()" , array ( ':DOM' => $ domain , ':TEXT' => $ message , ':SHA' => $ string_sha ) ) ; } } // Setup Text domain late... if ( $ TSUGI_LOCALE_RELOAD ) { self :: setupTextDomain ( ) ; } if ( isset ( $ TSUGI_TRANSLATE ) && $ TSUGI_TRANSLATE ) { $ retval = $ TSUGI_TRANSLATE -> trans ( $ message ) ; // error_log("DOM=$TSUGI_LOCALE msg=$message trans=$retval"); return $ retval ; } if ( ! function_exists ( 'gettext' ) ) return $ message ; if ( $ textdomain === false ) { return gettext ( $ message ) ; } else { return dgettext ( $ textdomain , $ message ) ; } }
Translate a messege from the master domain

Pattern borrowed from WordPress
Translate a messege from the master domain