Update the language files.

@param bool $register
333693
private function publishLanguages($register)
    {
        // read language files from folder
        $langPath = $this->path . '/lang';
        if (!file_exists($langPath)) {
            return;
        }
        $files = [];
        list_files($files, $langPath, ['php'], false);

        // update manifest
        $manifest = $this->getManifest('languages');
        /** @noinspection PhpIncludeInspection */
        $list = file_exists($manifest) ? include $manifest : [];
        $basePathLength = strlen(base_path()) + 1;
        foreach ($files as $file) {
            $locale = basename($file, '.php');
            if ($register) {
                if (!isset($list[$locale])) {
                    $list[$locale] = [];
                }
                $list[$locale][$this->plugin] = substr($file, $basePathLength);
            }
            else {
                if (isset($list[$locale])) {
                    unset($list[$locale][$this->plugin]);
                    if (empty($list[$locale])) {
                        unset($list[$locale]);
                    }
                }
            }
        }
        $this->saveArray($manifest, $list);
    }
767763
def update_translations(self, project_id, file_path=None,
                            language_code=None, overwrite=False, fuzzy_trigger=None):
        
        return self._upload(
            project_id=project_id,
            updating=self.UPDATING_TRANSLATIONS,
            file_path=file_path,
            language_code=language_code,
            overwrite=overwrite,
            fuzzy_trigger=fuzzy_trigger
        )
149219
public function setLanguage($value)
    {
        $value = strtolower($value);
        if (!isset($this->_models[$value])) {
            $this->_models[$value] = $this->loadTranslation($value);
        }
        $this->_language = $value;
    }
141
private function getTranslationGroups($lang = 'en'): void
    {
        $dir = resource_path('lang/'. $lang . '/');
        $files = array_diff(scandir($dir), array('..', '.'));

        foreach($files as $index => $filename){
            $groupname = str_replace(".php", "", $filename);
            $this->updateTranslationGroups($groupname);
        }

    }
214179
public function updateRegistry()
    {
        if (is_cli()) {
            output()->verbose(
                (new Format())
                    ->setContextualClass(Format::WARNING)
                    ->setString(language()->getLine('CLI_REGISTRY_LANGUAGE_VERB_UPDATE_START'))
                    ->setNewLinesBefore(1)
                    ->setNewLinesAfter(2)
            );
        }

        $cacheItemPool = cache()->getObject('default');

        if (cache()->exists('registry')) {
            $cacheItemPool = cache()->getObject('registry');
        }

        if ($cacheItemPool instanceof CacheItemPoolInterface) {
            $this->registry = $this->fetchRegistry();
            $cacheItemPool->save(new Item('o2languages', $this->registry, false));
        }

        if (count($this->registry) and is_cli()) {
            output()->verbose(
                (new Format())
                    ->setContextualClass(Format::SUCCESS)
                    ->setString(language()->getLine('CLI_REGISTRY_LANGUAGE_VERB_UPDATE_SUCCESS'))
                    ->setNewLinesBefore(1)
                    ->setNewLinesAfter(2)
            );
        } elseif (is_cli()) {
            output()->verbose(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString(language()->getLine('CLI_REGISTRY_LANGUAGE_VERB_UPDATE_FAILED'))
                    ->setNewLinesBefore(1)
                    ->setNewLinesAfter(2)
            );
        }
    }
404713
function updateGlobalTypographyMixin() {

		$languages = $this->_getRequiredLanguages();

		// Auto-create SCSS files

		// TODO: Use self::getThemeFontStacks() to parse if stack has $serif or $sans-serif strings

		foreach ( [ 'prince', 'epub', 'web' ] as $type ) {
			$this->_sassify( $type, $languages );
		}

		$this->getFonts( $languages );

	}
1373883
public function addLanguage($language)
    {
        $this->backup();

        file_put_contents($this->languageFilesPath.DIRECTORY_SEPARATOR."$language.json",
            json_encode((object) [], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
        );
    }
369681
public static function setLanguage($language)
    {
        if (in_array($language, self::$languages)) {
            self::$language = $language;
            self::$strings = self::loadLanguage();
            return true;
        }

        return false;
    }
1358997
public function update_all_installed_languages() {
        global $CFG;

        if (!$availablelangs = $this->installer->get_remote_list_of_languages()) {
            $this->errors[] = get_string('cannotdownloadlanguageupdatelist', 'error');
            return false;
        }

        $md5array = array();    // Convert to (string)langcode => (string)md5.
        foreach ($availablelangs as $alang) {
            $md5array[$alang[0]] = $alang[1];
        }

        // Filter out unofficial packs.
        $currentlangs = array_keys(get_string_manager()->get_list_of_translations(true));
        $updateablelangs = array();
        foreach ($currentlangs as $clang) {
            if (!array_key_exists($clang, $md5array)) {
                $this->info[] = get_string('langpackupdateskipped', 'tool_langimport', $clang);
                continue;
            }
            $dest1 = $CFG->dataroot.'/lang/'.$clang;
            $dest2 = $CFG->dirroot.'/lang/'.$clang;

            if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')) {
                $updateablelangs[] = $clang;
            }
        }

        // Filter out packs that have the same md5 key.
        $neededlangs = array();
        foreach ($updateablelangs as $ulang) {
            if (!$this->is_installed_lang($ulang, $md5array[$ulang])) {
                $neededlangs[] = $ulang;
            }
        }

        try {
            $updated = $this->install_languagepacks($neededlangs, true);
        } catch (\moodle_exception $e) {
            $this->errors[] = 'An exception occurred while installing language packs: ' . $e->getMessage();
            return false;
        }

        if ($updated) {
            $this->info[] = get_string('langupdatecomplete', 'tool_langimport');
            // The strings have been changed so we need to purge their cache to ensure users see the changes.
            get_string_manager()->reset_caches();
        } else {
            $this->info[] = get_string('nolangupdateneeded', 'tool_langimport');
        }

        return true;
    }
1052572
public function registerTranslations($app)
    {
        if(!isset($app->get('i18n')->translations['tecnocen/oauth2/*'])) {
            $app->get('i18n')->translations['tecnocen/oauth2/*'] = [
                'class'    => PhpMessageSource::class,
                'basePath' => __DIR__ . '/messages',
                'fileMap' => [
                    'tecnocen/oauth2/oauth2server' => 'oauth2server.php',
                ],
            ];
        }
    }
1141503
public function optionUpdate($type = null)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    modules()->updateRegistry();
                    break;

                case 'languages':
                    language()->updateRegistry();
                    break;
            }
        } else {
            modules()->updateRegistry();
            language()->updateRegistry();
        }

        exit(EXIT_SUCCESS);
    }
1179086
public function setCurrentLanguage($language)
    {
        if (!$this->isAvailable($language)) {
            return false;
        }

        $this->session->put('language', $language);

        $this->setLanguage($language);

        return true;
    }
369789
public function update($module)
    {
        $module = $this->module->findOrFail($module);

        chdir(base_path());

        $this->installRequires($module);
        $this->installDevRequires($module);
        $this->copyScriptsToMainComposerJson($module);
    }
25321
function set_language($language, $force_reset = false) {
        if ($force_reset) {
            $this->loaded_language = false;
        }

        //Clean up the language name to prevent malicious code injection
        $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);

        $language = strtolower($language);

        //Retreive the full filename
        $file_name = $this->language_path . $language . '.php';
        if ($file_name == $this->loaded_language) {
            // this language is already loaded!
            return;
        }

        $this->language = $language;

        $this->error = false;
        $this->strict_mode = GESHI_NEVER;

        //Check if we can read the desired file
        if (!is_readable($file_name)) {
            $this->error = GESHI_ERROR_NO_SUCH_LANG;
            return;
        }

        // Load the language for parsing
        $this->load_language($file_name);
    }
367006
public function compile(): void {
    $lang = $this->loader->getLang();
    foreach($this->languages as $language) {
      $this->loader->setLang($language);
      $texts = $this->loader->getTexts();
      if(!$this->isCatalogueExpired($language)) {
        continue;
      }
      $texts["__resources"] = $this->loader->getResources();
      $content = "<?php
return " . Helpers::dump($texts) . ";
?>";
      $filename = $this->getCatalogueFilename($language);
      FileSystem::write($filename, $content);
      $this->onCompile($this, $language);
    }
    $this->loader->setLang($lang);
  }
1236055
private function publishBootstraps($register)
    {
        $classes = [];
        if (file_exists($this->path . '/src/Bootstraps')) {
            list_classes($classes, $this->path . '/src/Bootstraps', $this->namespace . 'Bootstraps');
        }
        if (empty($classes)) {
            return;
        }

        // Read enabled packages and add/remove the current plugin.

        $packages = $this->listPackages($register);

        // update manifest

        $dest = '';
        foreach ($packages as $package => $relativePath) {
            $path = base_path($relativePath);
            $classes = [];
            if (file_exists($path . '/src/Bootstraps')) {
                $namespace = $this->getNamespace($path . '/composer.json');
                list_classes($classes, $path . '/src/Bootstraps', $namespace . 'Bootstraps');
            }
            if (empty($classes)) {
                continue;
            }
            $dest .= PHP_EOL .
                '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL .
                '// ' . $package . PHP_EOL .
                PHP_EOL;
            foreach ($classes as $class) {
                $dest .= '(new ' . $class . ')->boot();' . PHP_EOL;
            }
        }

        $this->saveContent($this->getManifest('bootstrap'), '<?php' . PHP_EOL . $dest);
    }
284526
private function publishPublicFolder($register)
    {
        // read files
        $publicPath = $this->path . '/public';
        if (!file_exists($publicPath)) {
            return;
        }
        $files = [];
        list_files($files, $publicPath);

        // copy files
        $publicPathLength = strlen($publicPath) + 1;
        foreach ($files as $file) {
            $destDir = public_path(substr(dirname($file), $publicPathLength));
            if (!file_exists($destDir)) {
                if (!make_dir($destDir, 0755)) {
                    throw new RuntimeException('Unable to create directory ' . $destDir); //@codeCoverageIgnore
                }
            } //@codeCoverageIgnore
            $dest = $destDir . DIRECTORY_SEPARATOR . basename($file);
            if ($register) {
                copy($file, $dest);
            }
            else {
                if (file_exists($dest)) {
                    unlink($dest);
                }
            }
        }
    }