method getOptions documentation in bbn\Appui\I18n

Gets the option with the property i18n setted and its items

function() { /** @var ( array) $paths get all options having i18n property setted and its items */ $paths = $this->options->findI18n(); $res = []; foreach ($paths as $p => $val){ $res[$p] = [ 'text' => $paths[$p]['text'], 'opt_language' => $paths[$p]['language'], 'strings' => [], 'id_option' => $paths[$p]['id'] ]; /** @todo AT THE MOMENT I'M NOT CONSIDERING LANGUAGES OF TRANSLATION */ foreach ($paths[$p]['items'] as $i => $value){ /* check if the opt text is in bbn_i18n and takes translations from db */ if ($exp = $this->db->rselect( 'bbn_i18n',['id', 'exp', 'lang'] , [ 'exp' => $paths[$p]['items'][$i]['text'], 'lang' => $paths[$p]['language'] ] ) ) { $translated = $this->db->rselectAll('bbn_i18n_exp', ['id_exp', 'expression', 'lang'], ['id_exp' => $exp['id'] ]); if (!empty($translated)) { /** @var $languages the array of languages found in db for the options*/ $languages = []; $translated_exp = ''; foreach ($translated as $t => $trans){ if (!in_array($translated[$t]['lang'], $translated)) { $languages[] = $translated[$t]['lang']; } $translated_exp = $translated[$t]['expression']; } if (!empty($languages)) { foreach($languages as $lang){ $res[$p]['strings'][] = [ $lang => [ 'id_exp' => $exp['id'], 'exp' => $exp['exp'], 'translation_db' => $translated_exp ] ]; } } } } else { if ($this->db->insert( 'bbn_i18n', [ 'exp' => $paths[$p]['items'][$i]['text'], 'lang' => $paths[$p]['language'], //'id_user'=> $this->user->getId(), //'last_modified' => date('H-m-d H:i:s') ] ) ) { $id = $this->db->lastId(); $this->db->insertIgnore( 'bbn_i18n_exp', [ 'id_exp' => $id, 'expression' => $paths[$p]['items'][$i]['text'], 'lang' => $paths[$p]['language'] ] ); $res[$p]['strings'][] = [ $paths[$p]['language'] => [ 'id_exp' => $id, 'exp' => $paths[$p]['items'][$i]['text'], 'translation_db' => $paths[$p]['items'][$i]['text'] ] ]; }; } } } return $res; }

Gets the option with the property i18n setted and its items 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.