public function setup()
 {
     $config = array('root_locale' => 'en', 'default_locale' => 'te_ST', 'locale_dir' => VARPATH . 'locale/');
     $this->i18n = Gallery_I18n::instance($config);
     db::build()->delete("incoming_translations")->where("locale", "=", "te_ST")->execute();
     $messages_te_ST = array(array('Hello world', 'Hallo Welt'), array(array('one' => 'One item has been added', 'other' => '%count elements have been added'), array('one' => 'Ein Element wurde hinzugefuegt.', 'other' => '%count Elemente wurden hinzugefuegt.')), array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?'));
     foreach ($messages_te_ST as $data) {
         list($message, $translation) = $data;
         $entry = ORM::factory("incoming_translation");
         $entry->key = Gallery_I18n::get_message_key($message);
         $entry->message = serialize($message);
         $entry->translation = serialize($translation);
         $entry->locale = 'te_ST';
         $entry->revision = null;
         $entry->save();
     }
 }
Exemple #2
0
 static function process_message($message, &$cache)
 {
     if (empty($cache)) {
         foreach (db::build()->select("key")->from("incoming_translations")->where("locale", "=", "root")->execute() as $row) {
             $cache[$row->key] = true;
         }
     }
     $key = Gallery_I18n::get_message_key($message);
     if (array_key_exists($key, $cache)) {
         return $cache[$key];
     }
     $entry = ORM::factory("incoming_translation")->where("key", "=", $key)->find();
     if (!$entry->loaded()) {
         $entry->key = $key;
         $entry->message = serialize($message);
         $entry->locale = "root";
         $entry->save();
     }
 }