method getTranslationsWidget documentation in bbn\Appui\I18n

Gets the widgets initial data

function($id_project, $id_option) { $success = false; $result = []; $locale_dirs = []; if ($id_option && ($o = $this->options->option($id_option)) && isset($o['language']) ) { // @var $to_explore the path to explore $to_explore = $this->getPathToExplore($id_option); // @var $locale_dir the path to locale dir $locale_dir = $this->getLocaleDirPath($id_option); //die(var_dump($locale_dir, $to_explore)); //the txt file in the locale folder $index = $this->getIndexPath($id_option); //the text of the option . the number written in the $index file $domain = $o['text'].(is_file($index) ? file_get_contents($index) : ''); // @var $dirs scans dirs existing in locale folder for this path if (is_dir($locale_dir)) { // @var array $languages dirs in locale folder $dirs = \bbn\File\Dir::getDirs($locale_dir) ?: []; if (!empty($dirs)) { foreach ($dirs as $l){ $languages[] = X::basename($l); } } } $new = 0; $i = 0; // @var array the languages found in locale dir if (!empty($languages)) { $result = []; foreach ($languages as $lng){ // the root to file po & mo $po = $locale_dir.'/'.$lng.'/LC_MESSAGES/'.$domain.'.po'; $mo = $locale_dir.'/'.$lng.'/LC_MESSAGES/'.$domain.'.mo'; // if a file po already exists takes its content if (is_file($po)) { $fileHandler = new \Sepia\PoParser\SourceHandler\FileSystem($po); $poParser = new \Sepia\PoParser\Parser($fileHandler); $Catalog = \Sepia\PoParser\Parser::parseFile($po); $num_translations = 0; if ($translations = $Catalog->getEntries()) { foreach($translations as $tr){ if ($tr->getMsgStr()) { $num_translations ++; } } $result[$lng] = [ 'num' => count($translations), 'num_translations' => $num_translations, 'lang' => $lng, 'num_translations_db' => $this->countTranslationsDb($id_option) ? $this->countTranslationsDb($id_option)[$lng] : 0 ]; } } // if the file po for the $lng doesn't exist $result is an empty object else{ if(!empty($this->countTranslationsDb($id_option)[$lng])) { $count_translations = $this->countTranslationsDb($id_option)[$lng]; } else{ $count_translations = 0; } $result[$lng] = [ 'num' => 0, 'num_translations' => 0, 'lang' => $lng, 'num_translations_db' => $count_translations ]; } } } $i++; $success = true; if (!empty($languages)) { $locale_dirs = $languages; } } return [ 'locale_dirs' => $locale_dirs, 'result' => $result, 'success' => $success, ]; }

Gets the widgets initial data BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.