Extracts translatable strings from JS files and creates translation
@param array $scripts
501910
protected function setJsTranslation(array $scripts)
    {
        if (!empty($this->langcode) && !is_file($this->translation->getContextJsFile())) {
            foreach ($scripts as $key => $script) {
                if (strpos($key, 'system/modules/') === 0
                    && strpos($key, '/vendor/') === false
                    && !empty($script['file'])) {
                    $string = file_get_contents($script['file']);
                    $this->translation->createJsTranslation($string);
                }
            }
        }
    }
649103
public function includeExtraScripts(array $keys = array())
    {
        $this->_extraScripts = empty($keys) ? array_keys($this->_confs['extra']) : $keys;
    }
273104
public function extractLanguageCodesFromData(array $rows): array
    {
        $languageMask = 0;
        foreach ($rows as $row) {
            $languageMask |= $row['lang_mask'];
        }

        return $this->languageMaskGenerator->extractLanguageCodesFromMask($languageMask);
    }
152987
function _extractTranslation(regexName, regex, content, file, lineNumber, results) {
      var r;
      _log.debug("---------------------------------------------------------------------------------------------------");
      _log.debug('Process extraction with regex : "' + regexName + '"');
      _log.debug(regex);
      regex.lastIndex = 0;
      while ((r = regex.exec(content)) !== null) {

        // Result expected [STRING, KEY, SOME_REGEX_STUF]
        // Except for plural hack [STRING, KEY, ARRAY_IN_STRING]
        if (r.length >= 2) {
          var translationKey, evalString;
          var translationDefaultValue = "";

          switch (regexName) {
            case 'HtmlDirectivePluralFirst':
              var tmp = r[1];
              r[1] = r[2];
              r[2] = tmp;
              /* falls through */
            case 'HtmlDirectivePluralLast':
              evalString = eval(r[2]);
              if (_.isArray(evalString) && evalString.length >= 2) {
                translationDefaultValue = "{NB, plural, one{" + evalString[0] + "} other{" + evalString[1] + "}" + (evalString[2] ? ' ' + evalString[2] : '');
              }
              translationKey = r[1].trim();
              break;
            default:
              translationKey = r[1].trim();
          }

          // Avoid empty translation
          if (translationKey === "") {
            return;
          }

          switch (regexName) {
            case "commentSimpleQuote":
            case "HtmlFilterSimpleQuote":
            case "JavascriptServiceSimpleQuote":
            case "JavascriptServiceInstantSimpleQuote":
            case "JavascriptFilterSimpleQuote":
            case "HtmlNgBindHtml":
              translationKey = translationKey.replace(/\\\'/g, "'");
              break;
            case "commentDoubleQuote":
            case "HtmlFilterDoubleQuote":
            case "JavascriptServiceDoubleQuote":
            case "JavascriptServiceInstantDoubleQuote":
            case "JavascriptFilterDoubleQuote":
              translationKey = translationKey.replace(/\\\"/g, '"');
              break;
            case "JavascriptServiceArraySimpleQuote":
            case "JavascriptServiceArrayDoubleQuote":
              var key;

              if(regexName === "JavascriptServiceArraySimpleQuote") {
                key = translationKey.replace(/'/g, '');
              } else {
                key = translationKey.replace(/"/g, '');
              }
              key = key.replace(/[\][]/g, '');
              key = key.split(',');

              key.forEach(function(item){
                item = item.replace(/\\\"/g, '"').trim();
                if (results[item]) {
                  results[item].sourceFiles.push({
                    file: file,
                    line: lineNumber
                  });
                } else {
                  results[item] = {
                    defaultValue: translationDefaultValue,
                    sourceFiles: [{
                      file: file,
                      line: lineNumber
                    }]
                  };
                }
              });
              break;
          }

          if( regexName !== "JavascriptServiceArraySimpleQuote" &&
              regexName !== "JavascriptServiceArrayDoubleQuote") {
            if (results[translationKey]) {
              results[translationKey].sourceFiles.push({
                file: file,
                line: lineNumber
              });
            } else {
              results[ translationKey ] = {
                defaultValue: translationDefaultValue,
                sourceFiles: [{
                  file: file,
                  line: lineNumber
                }]
              };
            }
          }
        }
      }
    }
1322506
public static function scripts()
    {
        if (! isset(static::$languages)) {
            static::$languages = json_decode(static::getFile(__DIR__.'/../resources/languages.json'), true);
        }

        return static::pluck(static::$languages, 'script.name', 'script.iso_15924');
    }
1361384
private function syncKeysFromFiles($translationFiles)
    {
        $this->info('Reading translation keys from files...');

        // An array of all translation keys as found in project files.
        $allKeysInFiles = $this->manager->collectFromFiles();

        foreach ($translationFiles as $fileName => $languages) {
            foreach ($languages as $languageKey => $path) {
                $fileContent = $this->manager->getFileContent($path);

                if (isset($allKeysInFiles[$fileName])) {
                    $missingKeys = array_diff($allKeysInFiles[$fileName], array_keys(array_dot($fileContent)));

                    foreach ($missingKeys as $i => $missingKey) {
                        if (Arr::has($fileContent, $missingKey)) {
                            unset($missingKeys[$i]);
                        }
                    }

                    $this->fillMissingKeys($fileName, $missingKeys, $languageKey);
                }
            }
        }
    }
553072
public function script($script) {
        $md5 = md5($script);
        if (in_array($md5, self::$cssScriptHistory))
            return '';
        self::$cssScriptHistory[] = $md5;
        return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n{$script}\n/*]]>*/\n</script>";
    }
295511
public function extractTranslationsFromFolders($folders, $trans_methods, $php_file_extension = 'php')
    {
        $lemmas = [];

        foreach ($folders as $path) {
            foreach ($this->getFilesWithExtension($path, $php_file_extension) as $php_file_path => $dumb) {
                $lemma = [];

                foreach ($this->extractTranslationFromPhpFile($php_file_path, $trans_methods) as $k => $v) {
                    $a = $this->evalString($k);
                    if (is_string($a)) {
                        $real_value         = $a;
                        $lemma[$real_value] = $php_file_path;
                    } else {
                        $this->messageBag->writeError("Unable to understand string $k");
                    }
                }

                $lemmas = array_merge($lemmas, $lemma);
            }
        }

        return $lemmas;
    }
890515
function translate (content, contentTypes) {
  let output = {}
  content.forEach(each => {
    const base = path.parse(each.file).base
    if (base === 'index.md') {
      const type = each.dir.split('/').pop()
      const contentTypeTranslation = contentTypes.find(contentType => contentType[type])
      if (contentTypeTranslation && contentTypeTranslation[type]) {
        output[type] = contentTypeTranslation[type](content, type)
      }
    }
  })
  return output
}
17647
public function delScript($script) {
        if ( ! empty($script)) {
            if ( ! is_array($script)) {
                $script = [$script];
            }
            if ( ! isset($this->obsolete['script'])) {
                $this->obsolete['script'] = [];
            }
            $this->obsolete['script'] = array_merge($this->obsolete['script'], $script);
        }
    }
250391
public static function js_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n// Cannot read JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
                continue;
            }
            $compressed[] = self::js($content);
        }

        return implode(";\n", $compressed);
    }
224259
def process_scripts (out)
      out.gsub /(<script\b[^>]*?>([\s\S]*?)<\/script>)\s*/i do
        js = $2
        m = $1.gsub /^<script\s([^>]+)>/i do |m|
          attrs(m, 'script', true)
        end
        begin
          js_compressed = HtmlPress.js_compressor js, @options[:js_minifier_options]
          m.gsub!(">#{js}<\/script>", ">#{js_compressed}<\/script>")
        rescue MultiJs::ParseError => e
          log e.message
        end
        reserve m
      end
    end
831847
public function loadJsTranslation($langcode = null)
    {
        $strings = $this->loadTranslation($this->getContextJsFile($langcode));

        $translations = array();
        foreach ($strings as $source => $translation) {
            if (isset($translation[0]) && $translation[0] !== '') {
                $translations[$source] = $translation;
            }
        }

        return $translations;
    }
866375
public function translateVars($text, $vars = array())
    {
        return strtr($text, array_merge($this->getParentVars(), $this->getVars(), $vars));
    }
1244165
protected function loadScripts(...$scripts)
    {
        $files = $this->getFilePayload($scripts ?? null);

        if (empty($files)) {
            return;
        }

        foreach ($files as $script) {
            $this->loadScript($script);
        }
    }
1290656
public function objectFilter(&$script)
    {
        $to_string_method = $this->getToStringMethod();
        $get_i18ns_method = $this->getI18nsMethod();
        $i18ns_method_name = 'get'.$this->CamelCase($this->getTable()->getName()).'I18ns';

        $table = $this->getTable();
        $newToStringMethod = sprintf($to_string_method, $table->getName(), $table->getPhpName(), $table->getPhpName());
        $newI18nMethod = sprintf($get_i18ns_method, $table->getName(), $table->getPhpName(), $table->getPhpName());

        $parser = new \PropelPHPParser($script, true);
        $parser->replaceMethod('__toString', $newToStringMethod);
        $parser->replaceMethod($i18ns_method_name, $newI18nMethod);
        $script = $parser->getCode();
    }
939488
public function enqueueScripts($scripts)
    {
        // Check scripts
        if (empty($scripts)) {
            return;
        }

        $defaults = [
            'src'       => false,
            'deps'      => [],
            'ver'       => false,
            'in_footer' => false
        ];

        // Iterate on all
        foreach ($scripts as $handle => $opts) {
            // Special case: de/register handle
            if (!is_array($opts)) {
                // Special case: jQuery-Migrate deregistration
                if ('jquery-migrate' === $handle && !$opts) {
                    add_action('wp_default_scripts', function ($scripts) {
                        if (OL_ZEUS_ISADMIN || empty($scripts->registered['jquery'])) {
                            return;
                        }

                        $jquery_dependencies = $scripts->registered['jquery']->deps;
                        $scripts->registered['jquery']->deps = array_diff($jquery_dependencies, array('jquery-migrate'));
                    });
                } else if (!$opts) {
                    wp_deregister_script($handle);
                } else {
                    wp_enqueue_script($handle);
                }

                continue;
            }

            // Merge options with defaults and enqueue script
            $opts = array_merge($defaults, $opts);
            wp_enqueue_script($handle, $opts['src'], $opts['deps'], $opts['ver'], $opts['in_footer']);
        }
    }