Extracts all files from the "master" language and takes them as translation groups.
@param string $lang

@return void
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);
        }

    }
975371
public static function load(array $langs, $lang = null)
    {
        static::$langs = $langs;
        static::$lang = $lang ?: key($langs);
    }
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;
	}
1069884
public function getContent($lang = null) {
		if (is_null($lang)) $lang = $this->_language;

		if ($this->_content == null) {
			$file = $this->_language_path . $lang . '/i18n.php';
			$this->_content = $this->_loadFile($file, false);
		}

		return $this->_content;
	}
67269
public function lang($lang = NULL)
	{
		if ( ! func_num_args())
		{
			return $this->_lang;
		}
		$this->_lang = $lang;
		return $this;
	}
1373034
private function syncKeysBetweenLanguages($translationFiles)
    {
        $this->info('Synchronizing language files...');

        $filesResults = [];

        // Here we collect the file results
        foreach ($translationFiles as $fileName => $languageFiles) {
            foreach ($languageFiles as $languageKey => $filePath) {
                $filesResults[$fileName][$languageKey] = $this->manager->getFileContent($filePath);
            }
        }

        $values = Arr::dot($filesResults);

        $missing = $this->manager->getKeysExistingInALanguageButNotTheOther($values);

        foreach ($missing as &$missingKey) {
            list($file, $key) = explode('.', $missingKey, 2);

            list($key, $language) = explode(':', $key, 2);

            $this->fillMissingKeys($file, [$key], $language);
        }
    }
307047
protected function _extract()
    {
        $this->out();
        $this->out();
        $this->out('Extracting...');
        $this->hr();
        $this->out('Paths:');
        foreach ($this->_paths as $path) {
            $this->out('   ' . $path);
        }
        $this->out('Output Directory: ' . $this->_output);
        $this->hr();
        $this->_extractTokens();
        $this->_buildFiles();
        $this->_writeFiles();
        $this->_paths = $this->_files = $this->_storage = [];
        $this->_translations = $this->_tokens = [];
        $this->out();
        if ($this->_countMarkerError) {
            $this->err("{$this->_countMarkerError} marker error(s) detected.");
            $this->err(" => Use the --marker-error option to display errors.");
        }

        $this->out('Done.');
    }
126634
public function synchronize($lang, $area)
    {
        $locale       = $lang->code;
        $translations = $this->translationsFromFiles($locale);
        if (empty($translations)) {
            $translations = $this->translationsFromFiles(lang()->code);
        }
        $items   = Translation::where('locale', $locale)->where('area', $area)->get();
        $grouped = [];
        foreach ($items as $item) {
            $grouped[$item->group][$item->key] = $item->value;
        }
        $deletes = [];

        foreach ($grouped as $name => $group) {
            if (!isset($translations[$name])) {
                continue;
            }
            $deleted = array_diff($group, $translations[$name]);
            if (!empty($deleted)) {
                $deletes[$name] = $deleted;
            }
        }
        $this->delete($lang->id, $area, $deletes);
        $this->insert($locale, $area, $translations);
    }
339229
public static function parse( $lang ) 
	{
		$conf = ClanCats::$config->language;
		
		if ( isset( $lang ) && strlen( $lang ) > 1 ) 
		{
			$lang = explode( ',', strtolower( $lang ) );
			$lang = explode( '-', $lang[0] );
			
			if ( !isset( $lang[1] ) ) 
			{
				$lang[1] = $lang[0];
			}
			
			$available = $conf['available'];
			
			if ( array_key_exists( $lang[0], $available ) ) 
			{
				// does even the region match?
				if ( in_array( $lang[1], $available[$lang[0]] ) ) 
				{
					return $lang[0].'-'.$lang[1];
				}
				// return the first region
				else 
				{
					$locales = $available[$lang[0]];
					return $lang[0].'-'.$locales[key($locales)];
				}
			}
		}
		
		// Return the default language when nothing coul be matched
		return $conf['default'];
	}
519915
private function gatherTranslatableStrings()
    {
        $this->translatables = [];

        $this->scanTwigFiles();
        $this->scanPhpFiles();

        ksort($this->translatables);
    }
374009
public function importTranslationFiles($domain, $dir)
    {
        $translations = $this->getTranslationsFromFiles($domain, $dir);
        $this->writeToStorage($domain, $translations);
    }
1222096
protected function loadStrings(string $language, string $file): void
	{
		if($this->cache !== null)
		{
			if($this->loadFromCache($language, $file))
			{
				return;
			}

			$this->rebuildCache = true;
		}

		$this->strings[$language][$file] = $this->loader->loadStrings($language, $file);
	}
659931
public function validLang($lang)
    {
        if (in_array($lang, $this->validLanguages)) {
            return $lang;
        }
        if ($this->defaultLanguage) {
            return $this->defaultLanguage;
        }
        return false;
    }
1098771
public function langs()
    {
        $langs = [];
        $files = $this->getMLFiles();

        foreach( $files as $file )
        {
            $langs[] = $this->removeExtension($file);
        }
    
        return $langs;
    }
438178
protected function split_lang($lang)
	{
		if ( ! isset($this->_fallback_paths[$lang]))
		{
			$splits = array();
			$lang_parts = explode('-', $lang);
			while ($lang_parts)
			{
				$splits[] = implode('-', $lang_parts);
				array_pop($lang_parts);
			}
			$this->_fallback_paths[$lang] = $splits;
		}
		return $this->_fallback_paths[$lang];
	}
303611
public function getTranslations($lang)
    {
        $path = $this->getTranslationPathBaseDirectory('lang', $lang);

        if (!is_readable($path)) {
            return array();
        }

        $data = file_get_contents($path);
        $translations = json_decode($data, true);

        return $translations;
    }
823002
public function setLang($lang = 'en-us') {
		$this->lang = $lang;

		try {
			$this->messages = parse_ini_file(__DIR__ . '/Lang/' . $this->lang . '.ini');
		} catch (Exception $e) {
			throw $e;
		}
	}