Пример #1
0
 public static function l10n_form()
 {
     if (Input::instance()->get("show_all_l10n_messages")) {
         $calls = array();
         foreach (Database::instance()->select("key", "message")->from("incoming_translations")->where(array("locale" => 'root'))->get()->as_array() as $row) {
             $calls[$row->key] = array(unserialize($row->message), array());
         }
     } else {
         $calls = I18n::instance()->call_log();
     }
     $locale = I18n::instance()->locale();
     if ($calls) {
         $translations = array();
         foreach (Database::instance()->select("key", "translation")->from("incoming_translations")->where(array("locale" => $locale))->get()->as_array() as $row) {
             $translations[$row->key] = unserialize($row->translation);
         }
         // Override incoming with outgoing...
         foreach (Database::instance()->select("key", "translation")->from("outgoing_translations")->where(array("locale" => $locale))->get()->as_array() as $row) {
             $translations[$row->key] = unserialize($row->translation);
         }
         $string_list = array();
         $cache = array();
         foreach ($calls as $key => $call) {
             list($message, $options) = $call;
             // Ensure that the message is in the DB
             l10n_scanner::process_message($message, $cache);
             // Note: Not interpolating placeholders for the actual translation input field.
             // TODO: Might show a preview w/ interpolations (using $options)
             $translation = isset($translations[$key]) ? $translations[$key] : '';
             $string_list[] = array('source' => $message, 'key' => $key, 'translation' => $translation);
         }
         $v = new View('l10n_client.html');
         $v->string_list = $string_list;
         $v->l10n_search_form = self::_l10n_client_search_form();
         $v->plural_forms = l10n_client::plural_forms($locale);
         return $v;
     }
     return '';
 }