SimpleHistory::filter_gettext_storeLatestTranslations PHP Method

filter_gettext_storeLatestTranslations() public method

public filter_gettext_storeLatestTranslations ( $translation, $text, $domain )
    function filter_gettext_storeLatestTranslations($translation, $text, $domain)
    {
        // Check that translation is a string or integer, i.ex. the valid values for an array key
        if (!is_string($translation) || !is_integer($translation)) {
            return $translation;
        }
        $array_max_size = 5;
        // Keep a listing of the n latest translation
        // when SimpleLogger->log() is called from anywhere we can then search for the
        // translated string among our n latest things and find it there, if it's translated
        // global $sh_latest_translations;
        $sh_latest_translations = $this->gettextLatestTranslations;
        $sh_latest_translations[$translation] = array("translation" => $translation, "text" => $text, "domain" => $domain);
        $arr_length = sizeof($sh_latest_translations);
        if ($arr_length > $array_max_size) {
            $sh_latest_translations = array_slice($sh_latest_translations, $arr_length - $array_max_size);
        }
        $this->gettextLatestTranslations = $sh_latest_translations;
        return $translation;
    }
SimpleHistory