checks the md5 of the zip file, grabbed from download.moodle.org,
against the md5 of the local language file from last update
@param string $lang language code
@param string $md5check md5 to check
@return bool true if installed
484101
public function is_installed_lang($lang, $md5check) {
        global $CFG;
        $md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
        if (file_exists($md5file)) {
            return (file_get_contents($md5file) == $md5check);
        }
        return false;
    }
898570
public function getLanguageURLPrefix($lang = null)
    {
        // if active lang is not passed in, use current active
        if (!$lang) {
            $lang = $this->getLanguage();
        }

        return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : '';
    }
749442
public static function isValidDirectory( $dir_lang , $lang )
	{
		if ( ! in_array( $lang , array( "." , ".." ) ) )
		{
			if ( is_dir( $dir_lang . DIRECTORY_SEPARATOR . $lang ) )
			{
				return true;
			}
		}

		return false;
	}
1110119
function get_local_md5() {
        global $CFG;

    /// Check requisites are passed
        if (!$this->requisitesok) {
            return false;
        }

        $return_value = 'needtobeinstalled';   /// Fake value to force new installation

    /// Calculate source to read
       $source = $CFG->dataroot.'/'.$this->destpath.'/'.$this->componentname.'/'.$this->componentname.'.md5';
    /// Read md5 value stored (if exists)
       if (file_exists($source)) {
           if ($temp = file_get_contents($source)) {
               $return_value = $temp;
           }
        }
        return $return_value;
    }
266389
public function load($langfile, $lang=null) {

        if (!$lang) {
            $lang = $this->locale;
        }

        if ($path = $this->app->path($langfile)){

            if (!isset($this->_languages[$lang])){
                $this->_languages[$lang] = [];
            }

            $langtable = include($path);

            $this->_languages[$lang] = \array_merge($this->_languages[$lang], (array)$langtable);

            return true;
        }

        return false;
    }
66274
public static function isValidLanguageRegex(string $language)
    {
        $match = false;

        if (preg_match(self::$validISOLanguageRegex, $language)) {
            $match = true;
        }

        if (preg_match(self::$validBCP47LanguageRegex, $language)) {
            $match = true;
        }

        return $match;
    }
70955
public function isRtl( $lang = null ) {
		static $rtlLanguages = null;

		$lang = $lang ? $this->normalizeLang( $lang ) : $this->getLang();

		if ( $rtlLanguages === null ) {
			$file = $this->localBaseDir . '/language/rtl.json';
			$rtlLanguages = json_decode( file_get_contents( $file ), true );
		}

		return in_array( $lang, $rtlLanguages );
	}
1107811
public function set_language( $lang = 'en-US' ) {
		if ( isset( $this->language ) && $this->language === $lang ) {
			return true; // Bail out, no need to do anything.
		}

		$success            = false;
		$language_file_name = \dirname( __FILE__ ) . '/lang/' . $lang . '.json';

		if ( \file_exists( $language_file_name ) ) {
			$raw_language_file = \file_get_contents( $language_file_name );

			if ( false !== $raw_language_file ) {
				$language_file = \json_decode( $raw_language_file, true );

				if ( false !== $language_file ) {
					$this->language           = $lang;
					$this->pattern_trie       = Trie_Node::build_trie( $language_file['patterns'] );
					$this->pattern_exceptions = $language_file['exceptions'];

					$success = true;
				}
			}
		}

		// Clean up.
		if ( ! $success ) {
			$this->language           = null;
			$this->pattern_trie       = null;
			$this->pattern_exceptions = [];
		}

		// Make sure hyphenationExceptions is not set to force remerging of patgen and custom exceptions.
		$this->merged_exception_patterns = null;

		return $success;
	}
520839
public function checkLanguage(string $key): bool
    {
        $locale = $this->getOption('locale', []);

        if (array_key_exists($key, Arr::wrap($locale))) {
            return filter_var($locale[$key], FILTER_VALIDATE_BOOLEAN);
        }

        return false;
    }
537240
public function setActive($lang)
    {
        if ($this->validate($lang)) {
            $this->active = $lang;

            return $lang;
        }

        return false;
    }
549814
public function getShopUrlByLanguage($lang, $ssl = false)
    {
        $configParameter = $ssl ? 'aLanguageSSLURLs' : 'aLanguageURLs';
        $lang = isset($lang) ? $lang : Registry::getLang()->getBaseLanguage();
        $languageURLs = $this->getConfigParam($configParameter);
        if (isset($lang) && isset($languageURLs[$lang]) && !empty($languageURLs[$lang])) {
            $languageURLs[$lang] = Registry::getUtils()->checkUrlEndingSlash($languageURLs[$lang]);
            return $languageURLs[$lang];
        }
    }
1057539
public static function getMd5($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return false;
        }

        return md5_file($path);
    }
994640
protected function md5Encrypt($key, $msg)
    {
        $blocksize = 64;
        if (strlen($key) > $blocksize) {
            $key = pack('H*', md5($key));
        }

        $key = str_pad($key, $blocksize, "\0");
        $ipadk = $key ^ str_repeat("\x36", $blocksize);
        $opadk = $key ^ str_repeat("\x5c", $blocksize);

        return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg))));
    }
1190720
public function createRoot(Lang $lang) : void
    {
        if (php_sapi_name() !== 'cli')
        {
            throw new \Exception("Method createRoot() is allowed only in CLI mode.");
        }

        $root = $this->pageRepository->findOneAbsoluteRoot();

        if ($root === NULL)
        {
            $root = new Page;
            $root->setName('root');
            $root->setView('root');
            $root->makeRoot();
            $root->save();
        }

        $langRoot = $this->pageRepository->findOneLangRoot($lang, TRUE);

        if ($langRoot === NULL)
        {
            $langRootName = 'root-' . $lang->getName();

            $langRoot = new Page;
            $langRoot->setName($langRootName);
            $langRoot->setView($langRootName);
            $langRoot->setParent($root);
            $langRoot->insertAsLastChildOf($root);
            $langRoot->save();

            $this->pageUrlManager->saveUrl($lang, $langRoot, '__a@&*^-9' . $langRootName);
        }
    }
142
function isLocalized($name,$lang=NULL) {
		if (!isset($lang))
			$lang=$this->current;
		return !$this->isGlobal($name) && array_key_exists($name,$this->_aliases) &&
				(!isset($this->rules[$lang][$name]) || $this->rules[$lang][$name]!==FALSE);
	}
502189
function &checkWords($lang, $words) {
		$r = enchant_broker_init();
		
		if (enchant_broker_dict_exists($r,$lang)) {
			$d = enchant_broker_request_dict($r, $lang);
			
			$returnData = array();
			foreach($words as $key => $value) {
				$correct = enchant_dict_check($d, $value);
				if(!$correct) {
					$returnData[] = trim($value);
				}
			}
	
			return $returnData;
			enchant_broker_free_dict($d);
		} else {

		}
		enchant_broker_free($r);
	}
38530
static function ModuleTranslationsFile(ModuleBase $module, $lang)
    {
        $folder = self::ModuleTranslationsFolder($module);
        $file = Path::Combine($folder, $lang);
        return Path::AddExtension($file, 'php');
    }