<commit_before><?php

namespace Friendica\Console;

/**
 * Extracts translation strings from the Friendica project's files to be exported
 * to Transifex for translation.
 *
 * Outputs a PHP file with language strings used by Friendica
 *
 * @author <NAME> <<EMAIL>>
 */
class Extract extends \Asika\SimpleConsole\Console
{
	protected $helpOptions = ['h', 'help', '?'];

	protected function getHelp()
	{
		$help = <<<HELP
console extract - Generate translation string file for the Friendica project (deprecated)
Usage
	bin/console extract [-h|--help|-?] [-v]

Description
	This script was used to generate the translation string file to be exported to Transifex,
	please use bin/run_xgettext.sh instead

Options
    -h|--help|-? Show help information
    -v           Show more debug information.
HELP;
		return $help;
	}

	protected function doExecute()
	{
		if ($this->getOption('v')) {
			$this->out('Class: ' . __CLASS__);
			$this->out('Arguments: ' . var_export($this->args, true));
			$this->out('Options: ' . var_export($this->options, true));
		}

		if (count($this->args) > 0) {
			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
		}

		$s = '<?php' . PHP_EOL;
		$s .= '
		function string_plural_select($n){
			return ($n != 1);
		}

		';

		$arr = [];

		$files = array_merge(
			['index.php', 'boot.php'],
			glob('mod/*'),
			glob('include/*'),
			glob('addon/*/*'),
			$this->globRecursive('src')
		);

		foreach ($files as $file) {
			$str = file_get_contents($file);

			$pat = '|L10n::t\(([^\)]*+)[\)]|';
			$patt = '|L10n::tt\(([^\)]*+)[\)]|';

			$matches = [];
			$matchestt = [];

			preg_match_all($pat, $str, $matches);
			preg_match_all($patt, $str, $matchestt);

			if (count($matches) || count($matchestt)) {
				$s .= '// ' . $file . PHP_EOL;
			}

			if (!empty($matches[1])) {
				foreach ($matches[1] as $long_match) {<commit_msg>adapt pattern for extract command<commit_after><?php

namespace Friendica\Console;

/**
 * Extracts translation strings from the Friendica project's files to be exported
 * to Transifex for translation.
 *
 * Outputs a PHP file with language strings used by Friendica
 *
 * @author <NAME> <<EMAIL>>
 */
class Extract extends \Asika\SimpleConsole\Console
{
	protected $helpOptions = ['h', 'help', '?'];

	protected function getHelp()
	{
		$help = <<<HELP
console extract - Generate translation string file for the Friendica project (deprecated)
Usage
	bin/console extract [-h|--help|-?] [-v]

Description
	This script was used to generate the translation string file to be exported to Transifex,
	please use bin/run_xgettext.sh instead

Options
    -h|--help|-? Show help information
    -v           Show more debug information.
HELP;
		return $help;
	}

	protected function doExecute()
	{
		if ($this->getOption('v')) {
			$this->out('Class: ' . __CLASS__);
			$this->out('Arguments: ' . var_export($this->args, true));
			$this->out('Options: ' . var_export($this->options, true));
		}

		if (count($this->args) > 0) {
			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
		}

		$s = '<?php' . PHP_EOL;
		$s .= '
		function string_plural_select($n){
			return ($n != 1);
		}

		';

		$arr = [];

		$files = array_merge(
			['index.php', 'boot.php'],
			glob('mod/*'),
			glob('include/*'),
			glob('addon/*/*'),
			$this->globRecursive('src')
		);

		foreach ($files as $file) {
			$str = file_get_contents($file);

			$pat = '|->t\(([^\)]*+)[\)]|';
			$patt = '|->tt\(([^\)]*+)[\)]|';

			$matches = [];
			$matchestt = [];

			preg_match_all($pat, $str, $matches);
			preg_match_all($patt, $str, $matchestt);

			if (count($matches) || count($matchestt)) {
				$s .= '// ' . $file . PHP_EOL;
			}

			if (!empty($matches[1])) {
				foreach ($matches[1] as $long_match) {
{'fraction_non_alphanumeric': 0.18911780243000528, 'fraction_numerical': 0.003169572107765452, 'mean_word_length': 3.4605418138987045, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3065236', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1304, 'n_words': 328}