Generate lang/app.php file if it doesn't exists

@param  string $langPath Directory path of lang files
@return void
191888
private function createAppLangFile($langPath)
    {
        if (!$this->files->exists($langPath.'/app.php')) {
            $this->generateFile($langPath.'/app.php', $this->getAppLangFileContent());
            $this->command->info('lang/app.php generated.');
        }
    }
22498
protected function generateFolders($path)
    {
        if (! $this->files->isDirectory($path)) {
            $this->files->makeDirectory($path, 0755, true, true);
        }

        $this->files->makeDirectory($path .DS .'Language');
        $this->files->makeDirectory($path .DS .'Support');

        // Generate the Language folders.
        $languages = $this->container['config']->get('languages', array());

        foreach (array_keys($languages) as $code) {
            $directory = $path .DS .'Language' .DS .strtoupper($code);

            $this->files->makeDirectory($directory);
        }
    }
1339805
protected function mergeModuleTranslations($langcode = null)
    {
        $modules = $this->module->getEnabled();

        // Sort modules in descending order
        // More important modules go first so their translations will be added earlier
        gplcart_array_sort($modules, 'weight', false);

        foreach ($modules as $module) {
            $file = $this->getFile($langcode, $module['module_id']);
            if (is_file($file)) {
                $this->mergeTranslation($file, $langcode);
            }
        }
    }
368331
public static function getLanguagePath($basePath = PATH_APP, $language = null)
	{
		$dir = $basePath . DS . 'language';

		if (!empty($language))
		{
			$dir .= DS . $language;
		}

		return $dir;
	}
836894
private function setCompileWithTemplateFile(string $rPath) : string
    {
        $cplBase = $this->compileDir . '/' . $rPath;
        $cplPath = $cplBase . '.php';
        return $cplPath;
    }
1280965
protected function createDirectory($dirPath)
    {
        // $fullPath = $this->app->config()['paths']['root']->expand($dirPath);
        
        if (!is_dir($dirPath)) {
            $this->output->writeln(sprintf(
                "<info>create  <cyan>%s</cyan></info>",
                $this->prettyPath($dirPath)
            ));
            mkdir($dirPath, 0775, true);
        }
    }
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);
        }

    }
8144
public function loadFile($filePath) {
        require_once (substr($filePath, 0, 1) != '/' && substr($filePath, 1, 1) != ':')
            ? $this->basePath . DIRECTORY_SEPARATOR . $filePath : $filePath;
    }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }
313653
public function generate($namespace, $basePath, ClassMetadata $metadata)
    {
        $out = array();
        if (!file_exists($basePath.'/Resources/translations')) {
            mkdir($basePath.'/Resources/translations', 0777, true);
        }
        $out[] = $this->generateLangEn($namespace, $basePath, $metadata);
        $out[] = $this->generateLangfr($namespace, $basePath, $metadata);

        return $out;
    }
1058339
public static function init($lang,$suffix=''){
		$fn=BLANGUAGESPATH.$lang.$suffix.'.php';
		if(!file_exists($fn)){
			self::regeneratecache();
			}
		if(!file_exists($fn)){
			return false;
			}
		self::$suffix=$suffix;
		if(DEBUG_BLANG){
			BLog::addToLog('[BLang]: Initializing language ('.$lang.')');
			BLog::addToLog('[BLang]: Loading file "'.$fn.'"...');
			}
		include($fn);
		self::$langcode=$lang;
		switch(self::$langcode){
			case 'ru':
				self::$langcode_web='ru-RU';
				break;
			case 'ua':
				self::$langcode_web='uk-UA';
				break;
			}
		}
499646
public static function run($rootPath)
    {
        /*
         * Load initialization config needed to bootstrap application.
         *
         * In order for paths to be customized and still have the standard
         * index.php (web) and nut (CLI) work, there needs to be a standard
         * place these are defined. This is ".bolt.yml" or ".bolt.php" in the
         * project root (determined above).
         *
         * Yes, YAML and PHP are supported here (not both). YAML works for
         * simple values and PHP supports any programmatic logic if required.
         */
        $config = [
            'application' => null,
            'resources'   => null,
            'paths'       => [],
            'services'    => [],
            'extensions'  => [],
        ];

        $rootPath = Path::canonicalize($rootPath);

        if (file_exists($rootPath . '/.bolt.yml')) {
            $yaml = Yaml::parse(file_get_contents($rootPath . '/.bolt.yml')) ?: [];
            $config = array_replace_recursive($config, $yaml);
        } elseif (file_exists($rootPath . '/.bolt.php')) {
            $php = include $rootPath . '/.bolt.php';
        }

        // An extra handler if a PHP bootstrap is provided, allow the bootstrap file to return
        // a pre-initialized Bolt Application rather than the config array.
        if (isset($php) && is_array($php)) {
            $config = array_replace_recursive($config, $php);
        } elseif (isset($php) && $php instanceof Silex\Application) {
            return $php;
        }

        // If application object is provided, assume it is ready to go.
        if ($config['application'] instanceof Silex\Application) {
            return $config['application'];
        }

        $pathResolverFactoryFactory = \Pimple::share(function () use ($rootPath, $config) {
            $pathResolverFactory = new PathResolverFactory();
            $pathResolverFactory->setRootPath($rootPath);
            $pathResolverFactory->addPaths((array) $config['paths']);

            return $pathResolverFactory;
        });

        $resourcesClass = func_num_args() > 1 ? func_get_arg(1) : Standard::class;
        $resourcesFactory = \Pimple::share(function () use ($config, $resourcesClass, $rootPath, $pathResolverFactoryFactory) {
            // Use resources from config, or instantiate the class based on mapping above.
            if ($config['resources'] instanceof ResourceManager) {
                $resources = $config['resources'];
            } else {
                if ($config['resources'] !== null && is_a($config['resources'], ResourceManager::class, true)) {
                    $resourcesClass = $config['resources'];
                }

                $passPathResolverFactory = false;
                if ($resourcesClass === Composer::class || $resourcesClass === Standard::class) {
                    $passPathResolverFactory = true;
                } else {
                    $r = (new \ReflectionClass($resourcesClass))->getConstructor();
                    if ($r->getNumberOfParameters() > 2 && $r->getParameters()[2]->getClass()->name === PathResolverFactory::class) {
                        $passPathResolverFactory = true;
                    }
                }

                /** @var \Bolt\Configuration\ResourceManager $resources */
                if ($passPathResolverFactory) {
                    $pathResolverFactory = $pathResolverFactoryFactory(null);
                    $resources = new $resourcesClass($rootPath, null, $pathResolverFactory);
                } else {
                    $resources = new $resourcesClass($rootPath);
                }
            }

            // Set any non-standard paths
            foreach ((array) $config['paths'] as $name => $path) {
                $resources->setPath($name, $path, false);
            }

            $resources->verify();

            return $resources;
        });

        // If resources is already initialized, go ahead and customize it now.
        if ($config['resources'] instanceof ResourceManager) {
            $resourcesFactory = $resourcesFactory(null);
        }

        // Create the 'Bolt application'
        $appClass = Application::class;
        if ($config['application'] !== null && is_a($config['application'], Silex\Application::class, true)) {
            $appClass = $config['application'];
        }
        /** @var Silex\Application $app */
        $app = new $appClass([
            'resources'             => $resourcesFactory,
            'path_resolver_factory' => $pathResolverFactoryFactory,
            'path_resolver.root'    => $rootPath,
            'path_resolver.paths'   => (array) $config['paths'],
            'resources.bootstrap'   => $config['resources'] !== null,
        ]);

        foreach ((array) $config['services'] as $service) {
            $params = [];
            if (is_array($service)) {
                $params = reset($service);
                $service = key($service);
            }

            if (is_string($service) && is_a($service, Silex\ServiceProviderInterface::class, true)) {
                $service = new $service();
            }
            if ($service instanceof Silex\ServiceProviderInterface) {
                $app->register($service, $params);
            }
        }

        if (!$config['extensions']) {
            return $app;
        }
        if (!isset($app['extensions'])) {
            throw new LogicException('Provided application object does not contain an extension service, but extensions are defined in bootstrap.');
        }

        $app['extensions'] = $app->share(
            $app->extend(
                'extensions',
                function ($extensions) use ($config) {
                    foreach ((array) $config['extensions'] as $extensionClass) {
                        if (is_string($extensionClass)) {
                            if (!class_exists($extensionClass)) {
                                throw new LogicException(sprintf('Extension class name "%s" is defined in .bolt.yml or .bolt.php, but the class name is misspelled or not loadable by Composer.', $extensionClass));
                            }
                            if (!is_a($extensionClass, ExtensionInterface::class, true)) {
                                throw new LogicException(sprintf('Extension class "%s" must implement %s', $extensionClass, ExtensionInterface::class));
                            }
                            $extensionClass = new $extensionClass();
                        }
                        if (!$extensionClass instanceof ExtensionInterface) {
                            throw new LogicException(sprintf('Extension class "%s" must be an instance of %s', get_class($extensionClass), ExtensionInterface::class));
                        }
                        $extensions->add($extensionClass);
                    }

                    return $extensions;
                }
            )
        );

        return $app;
    }
595835
public function dump($basepath, $language = null)
    {
        $sitemapData = $this
            ->sitemapBuilder
            ->build($basepath, $language);

        $path = $this->resolvePathWithLanguage(
            $this->path,
            $language
        );

        $this
            ->sitemapDumper
            ->dump($path, $sitemapData);
    }
1106557
public function language($extension, $basePath = PATH_CORE)
	{
		return App::get('language')->load(strtolower($extension), $basePath);
	}
255918
protected function buildServerBundle($langCode)
    {
        $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
        $extensions = helpers_ExtensionHelper::sortByDependencies($extensions);
        $translations = [];
        foreach ($extensions as $extension) {
            $file = $extension->getDir(). 'locales' . DIRECTORY_SEPARATOR . $langCode. DIRECTORY_SEPARATOR . 'messages.po';
            $new = l10n::getPoFile($file);
            if (is_array($new)) {
                $translations = array_merge($translations, $new);
            }
        }
        $cache = $this->getServiceLocator()->get(common_cache_Cache::SERVICE_ID);
        $cache->put($translations, self::TRANSLATION_PREFIX.$langCode);
        return $translations;
    }
155270
public function loadLanguage($extension = '', $basePath = PATH_APP)
	{
		if (empty($extension))
		{
			$extension = 'plg_' . $this->_type . '_' . $this->_name;
		}

		$lang = \App::get('language');
		return $lang->load(strtolower($extension), $basePath, null, false, true)
			|| $lang->load(strtolower($extension), PATH_APP . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true)
			|| $lang->load(strtolower($extension), PATH_CORE . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true);
	}
881383
public function compile($path = null)
    {
        if ($path) {
            $this->setPath($path);
        }

        if (!is_null($this->cachePath)) {
            if (!is_file($path)) {
                throw new \RuntimeException("File does not exist at path {$path}");
            }

            file_put_contents(
                $this->getCompiledPath($path),
                $this->compileString(file_get_contents($path))
            );
        }
    }