Parse slugs to create translations

@param string $absoluteTranslationFileName
330440
private function generateSlugs($absoluteTranslationFileName)
    {
        $translations = I18nHelper::generateTranslationsFile($absoluteTranslationFileName);
        foreach ($this->routing as $key => &$info) {
            $keyParts = explode('#|#', $key);
            $keyParts = array_key_exists(1, $keyParts) ? $keyParts[1] : $keyParts[0];
            $slug = RouterHelper::slugify($keyParts);
            if (NULL !== $slug && !array_key_exists($slug, $translations)) {
                $translations[$slug] = $info['label'];
                file_put_contents($absoluteTranslationFileName, "\$translations[\"{$slug}\"] = t(\"{$info['label']}\");\n", FILE_APPEND);
            }
            $this->slugs[$slug] = $key;
            $info['slug'] = $slug;
        }
    }
1210273
protected function normaliseFilename($absolutePath) {
		$regex = sprintf(
			'#^%s#',
			addslashes(BASE_PATH) . DIRECTORY_SEPARATOR
		);
		return preg_replace($regex, '', $absolutePath);
	}
1126457
public function translate($slug = false, $params = [], $language = null)
    {
        return $this->trans($slug, $params, null, $language);
    }
250579
public function parseManual(\Gettext\Translations $translations, $concrete5version)
    {
        $akcNameMap = array(
            'collection' => 'Page attributes',
            'user' => 'User attributes',
            'file' => 'File attributes',
        );
        if (version_compare($concrete5version, '5.7') < 0) {
            $akcClass = '\AttributeKeyCategory';
        } else {
            $akcClass = '\Concrete\Core\Attribute\Key\Category';
        }
        if (class_exists($akcClass, true) && method_exists($akcClass, 'getList')) {
            foreach (call_user_func($akcClass.'::getList') as $akc) {
                $akcHandle = $akc->getAttributeKeyCategoryHandle();
                $this->addTranslation($translations, isset($akcNameMap[$akcHandle]) ? $akcNameMap[$akcHandle] : ucwords(str_replace(array('_', '-', '/'), ' ', $akcHandle)));
            }
        }
    }
297511
protected function generateTranslation()
    {
        $name = $this->qualifyClass($this->getNameInput());
        $path = $this->getTranslationPath($name);

        $this->makeDirectory($path);
        $this->files->put($path, $this->buildTranslation($name));

        $this->info('Translation also generated successfully.');
        $this->warn($path);
    }
1167153
public function getTranslationFile(TransUnitInterface & $transUnit, $locale)
    {
        $file = null;
        foreach ($transUnit->getTranslations() as $translation) {
            if (null !== $file = $translation->getFile()) {
                break;
            }
        }

        //if we found a file
        if ($file !== null) {
            //make sure we got the correct file for this locale and domain
            $name = sprintf('%s.%s.%s', $file->getDomain(), $locale, $file->getExtention());
            $file = $this->fileManager->getFor($name, $this->kernelRootDir.DIRECTORY_SEPARATOR.$file->getPath());
        }

        return $file;
    }
1105270
public function action($action, $parameters = [], $absolute = true)
    {
        $getProjectConfig = Config::get('project');
        //add language if current language
        if($getProjectConfig['multilanguage'] && App::getLocale() != Language::getDefault('slug')) {
            $langParameter = array('lang'=> App::getLocale() );
        }else{
            $langParameter = array('lang'=>"");
        }

        $parameters = array_merge($langParameter, $parameters);
        $method = Theme::getNamespace().$action;
        $url = action($method, $parameters);
        return $url;
    }
1260067
final protected function addTranslation(\Gettext\Translations $translations, $string, $context = '')
    {
        if (is_string($string) && ($string !== '')) {
            $translations->insert($context, $string);
        }
    }
685587
public function loadTranslations()
    {
        $directory = $this->getDirectory().'/../../resources/lang';

        $this->loadTranslationsFrom($directory, 'amethyst-'.$this->getPackageName());

        $this->publishes([
            $directory => resource_path('lang/vendor/amethyst'),
        ], 'resources');
    }
1260242
public void addFileTranslation(String translation) {

        m_fileTranslations.add(translation);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_ADD_FILE_TRANSLATION_1, translation));
        }
    }
954438
def add_translations(
        self, module_name, translations_dir="translations", domain="messages"
    ):
        
        module = importlib.import_module(module_name)
        for path in (Path(p, translations_dir) for p in module.__path__):
            if not (path.exists() and path.is_dir()):
                continue

            if not os.access(str(path), os.R_OK):
                self.app.logger.warning(
                    "Babel translations: read access not allowed {}, skipping."
                    "".format(repr(str(path).encode("utf-8")))
                )
                continue

            self._translations_paths.append((str(path), domain))
1056477
public function createTranslationFiles($folder, $key)
    {
        //$d=__DIR__ . '/../../../../../../../design/frontend/default/base/custom/quick-burger';

        // Parse the phtml files and find translation phrases. I put them in an array for dedoubloning phrases
        $files = $this->filesFrom($folder, 'phtml');

        $transArray = array();
        foreach ($files as $path => $file) {
            $raw = file_get_contents($path);
            // If filter only words (surrounded by ' or " and don't take var
            preg_match_all('/\$this->translate\([\"\'](.*?)[\"\']\)/', $raw, $matches);
            foreach ($matches[1] as $k => $phrase) {
                $transArray[$phrase]['phrase'] = $phrase;
                $transArray[$phrase]['files'][$file['name']] = (isset($transArray[$phrase]['files'][$file['name']]))? $transArray[$phrase]['files'][$file['name']]+1:1;
            }
        }

        // I create the translation file array and write it to all languages files
        $translation = "<?php\n  return array(\n";
        foreach ($transArray as $k => $v) {
            // add the name of the template containing this phrase
            // foreach($v['files'] as $filename => $count){
            //     $translation .= "    // $filename ($count times)\n";
            // }
            
            $translation .= '    "'.str_replace('"', '\"', stripslashes($v['phrase'])).'" => "'.str_replace('"', '\"', $v['phrase']).'",'."\n";
        }
        $translation .= ");\n";

        $lfiles = $this->filesFrom($folder.'/language', 'php');
        $result = "";
        foreach ($lfiles as $path => $file) {
            file_put_contents($path, $translation);
            $result .= $file['name'] . " updated\n";
        }

        return $result;
        
    }
1238035
public function convertTranslationsToString(Translations $translations)
    {
        \Gettext\Generators\Mo::$includeEmptyTranslations = true;

        return $translations->toMoString();
    }
1358820
protected function importComponentTranslationFiles(array $locales, array $domains)
    {
        $classes = array(
            'Symfony\Component\Validator\Validation'                            => '/Resources/translations',
            'Symfony\Component\Form\Form'                                       => '/Resources/translations',
            'Symfony\Component\Security\Core\Exception\AuthenticationException' => '/../Resources/translations',
        );

        $dirs = array();
        foreach ($classes as $namespace => $translationDir) {
            $reflection = new \ReflectionClass($namespace);
            $dirs[] = dirname($reflection->getFilename()) . $translationDir;
        }

        $finder = new Finder();
        $finder->files()
            ->name($this->getFileNamePattern($locales, $domains))
            ->in($dirs);

        $this->importTranslationFiles($finder->count() > 0 ? $finder : null);
    }
38530
static function ModuleTranslationsFile(ModuleBase $module, $lang)
    {
        $folder = self::ModuleTranslationsFolder($module);
        $file = Path::Combine($folder, $lang);
        return Path::AddExtension($file, 'php');
    }
342741
protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty)
    {
        switch ($relativePath) {
            case '':
                $directoryAlternatives = array('application/config/generated_overrides', 'application/config', 'concrete/config');
                break;
            case 'application':
                $directoryAlternatives = array('config/generated_overrides', 'config');
                break;
            case 'concrete':
                $directoryAlternatives = array('config');
                break;
            default:
                return;
        }
        $prefix = ($relativePath === '') ? '' : "$relativePath/";
        $this->parseFileTypes($translations, $rootDirectory, $prefix, $directoryAlternatives);
        $this->parseTranslatableStrings($translations, $rootDirectory, $prefix, $directoryAlternatives);
    }
519915
private function gatherTranslatableStrings()
    {
        $this->translatables = [];

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

        ksort($this->translatables);
    }