Elgg\I18n\Translator::reloadAllTranslations PHP Method

reloadAllTranslations() public method

This is only called by functions which need to know all possible translations.
public reloadAllTranslations ( ) : void
return void
    public function reloadAllTranslations()
    {
        static $LANG_RELOAD_ALL_RUN;
        if ($LANG_RELOAD_ALL_RUN) {
            return;
        }
        if ($GLOBALS['_ELGG']->i18n_loaded_from_cache) {
            $cache = elgg_get_system_cache();
            $cache_dir = $cache->getVariable("cache_path");
            $filenames = elgg_get_file_list($cache_dir, array(), array(), array(".lang"));
            foreach ($filenames as $filename) {
                // Look for files matching for example 'en.lang', 'cmn.lang' or 'pt_br.lang'.
                // Note that this regex is just for the system cache. The original language
                // files are allowed to have uppercase letters (e.g. pt_BR.php).
                if (preg_match('/(([a-z]{2,3})(_[a-z]{2})?)\\.lang$/', $filename, $matches)) {
                    $language = $matches[1];
                    $data = elgg_load_system_cache("{$language}.lang");
                    if ($data) {
                        $this->addTranslation($language, unserialize($data));
                    }
                }
            }
        } else {
            foreach ($GLOBALS['_ELGG']->language_paths as $path => $dummy) {
                $this->registerTranslations($path, true);
            }
        }
        $LANG_RELOAD_ALL_RUN = true;
    }