method getTranslationsStrings documentation in bbn\Appui\I18n

Returns the strings contained in the given path

function($id_option, $source_language, $languages) { if (!empty($id_option) && !empty($source_language) // @var string $to_explore The path to explore path of mvc && ($to_explore = $this->getPathToExplore($id_option)) //the position of locale dir && ($locale_dir = $this->getLocaleDirPath($id_option)) ) { //creates the array $to_explore_dirs containing mvc, plugins e components if ($to_explore_dirs = bbn\File\Dir::getDirs($to_explore)) { $current_dirs = array_values( array_filter( $to_explore_dirs, function ($a) { $basename = X::basename($a); if(( strpos($basename, 'locale') !== 0 ) && ( strpos($basename, 'data') !== 0 ) && ( strpos($basename, '.') !== 0 ) ) { return $a; } } ) ); } $res = []; //case of generate called from table if (empty($languages)) { /** @var (array) $languages based on locale dirs found in the path*/ $languages = array_map( function ($a) { return X::basename($a); }, \bbn\File\Dir::getDirs($locale_dir) ) ?: []; } if (!empty($to_explore_dirs)) { foreach ($to_explore_dirs as $c){ if ($ana = $this->analyzeFolder($c, true)) { foreach ($ana as $exp => $an) { if (!isset($res[$exp])) { $res[$exp] = $an; } else { $res[$exp] = array_merge($res[$exp], $an); } } } } } $news = []; $done = 0; foreach ($res as $r => $val){ // for each string create a property 'path' containing the files' name in which the string is contained $res[$r] = ['path' => $val]; // checks if the table bbn_i18n of db already contains the string $r for this $source_lang if (!($id = $this->db->selectOne( 'bbn_i18n', 'id', [ 'exp' => $r, 'lang' => $source_language ] )) ) { // if the string $r is not in 'bbn_i18n' inserts the string $this->db->insertIgnore( 'bbn_i18n', [ 'exp' => stripslashes($r), 'lang' => $source_language, ] ); $id = $this->db->lastId(); } // create the property 'id_exp' for the string $r $res[$r]['id_exp'] = $id; // puts the string $r into the property 'original_exp' (I'll use only array_values at the end) * $res[$r]['original_exp'] = $r; // checks in 'bbn_i18n_exp' if the string $r already exist for this $source_lang if(!( $id_exp = $this->db->selectOne( 'bbn_i18n_exp', 'id_exp', [ 'id_exp' => $id, 'lang' => $source_language ] ) ) ) { // if the string $r is not in 'bbn_i18n_exp' inserts the string // $done will be the number of strings found in the folder $to_explore that haven't been found in the table // 'bbn_i18n_exp' of db, so $done is the number of new strings inserted in in 'bbn_i18n_exp' $done += (int)$this->db->insertIgnore( 'bbn_i18n_exp', [ 'id_exp' => $id, 'lang' => $source_language, 'expression' => stripslashes($r) ] ); //creates an array of new strings found in the folder; $news[] = $r; } // $languages is the array of languages existing in locale dir foreach ($languages as $lng){ // create a property indexed to the code of $lng containing the string $r from 'bbn_i18n_exp' in this $lng $res[$r][$lng] = (string)$this->db->selectOne( 'bbn_i18n_exp', 'expression', [ 'id_exp' => $id, 'lang' => $lng ] ); } } return [ 'news' => $news, 'id_option' => $id_option, 'res' => array_values($res), 'done' => $done, 'languages' => $languages, 'path' => $to_explore, 'success' => true ]; } }

Returns the strings contained in the given path 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.