Re: Cakephp 2.0.3: Troubles with Sessions...
SOLVED: removing the ? at the end of the controller solved the problem. Weird. On Nov 27, 7:30 pm, ava avon...@gmx.net wrote: @euromark how is the test case set up? Well, I call it several times by clicking on the link in the view. I don't know if this answers your question... Anyway, I tried to get aSessionID, but this doesn't return a value: function testsession() { if ($scounter = $this-Session-read('scounter')) { $scounter++; } else { $scounter = 1; } $this-Session-write('scounter', $scounter); $this-set('scounter', $scounter); $this-log('SessionID: ' . $this-Session-id()); // no SessionID is outputed... } On Nov 27, 1:57 pm, euromark dereurom...@googlemail.com wrote: you can simplify the condition to if ($scounter = $this-Session-read('scounter')) {} but besides that how is the test case set up? because it is possible that it resets itself after each run therefore thesessionwould always be emptied afterwards... On 27 Nov., 11:38,avaavon...@gmx.net wrote: Hi I'm struggling with sessions in cakephp 2.0.3. In this testcase the counter should be incremented with each click on the link. The counter always remains 1. // CONTROLLER ?php class Test01sController extends AppController { public $components = array('Session'); function testsession() { $scounter = 1; if ($this-Session-check('scounter')) { $scounter = $this-Session-read('scounter'); $scounter++; } $this-Session-write('scounter', $scounter); $this-set('scounter', $scounter); } } //MODEL ?php class Test01 extends AppModel { var $name = 'Test01'; var $useTable = false;} ? // VIEW ?php echo $scounter; ? br/a href=/test01s/testsessiontestsession/a // CORE Configure::write('Session', array( 'defaults' = 'php', 'cookie' = 'vportal', 'ini' = array('session.gc_divisor' = 1000,'session.cookie_httponly' = true), 'timeout' = 4320 //3 days )); I also dumped the $_SESSION array. This array is always empty. Any help or hints are appreciated. -- Andre -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cakephp 2.0.3: Troubles with Sessions...
Hi I'm struggling with sessions in cakephp 2.0.3. In this testcase the counter should be incremented with each click on the link. The counter always remains 1. // CONTROLLER ?php class Test01sController extends AppController { public $components = array('Session'); function testsession() { $scounter = 1; if ($this-Session-check('scounter')) { $scounter = $this-Session-read('scounter'); $scounter++; } $this-Session-write('scounter', $scounter); $this-set('scounter', $scounter); } } //MODEL ?php class Test01 extends AppModel { var $name = 'Test01'; var $useTable = false; } ? // VIEW ?php echo $scounter; ? br/a href=/test01s/testsessiontestsession/a // CORE Configure::write('Session', array( 'defaults' = 'php', 'cookie' = 'vportal', 'ini' = array('session.gc_divisor' = 1000,'session.cookie_httponly' = true), 'timeout' = 4320 //3 days )); I also dumped the $_SESSION array. This array is always empty. Any help or hints are appreciated. -- Andre -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Cakephp 2.0.3: Troubles with Sessions...
@euromark how is the test case set up? Well, I call it several times by clicking on the link in the view. I don't know if this answers your question... Anyway, I tried to get a Session ID, but this doesn't return a value: function testsession() { if ($scounter = $this-Session-read('scounter')) { $scounter++; } else { $scounter = 1; } $this-Session-write('scounter', $scounter); $this-set('scounter', $scounter); $this-log('SessionID: ' . $this-Session-id()); // no SessionID is outputed... } On Nov 27, 1:57 pm, euromark dereurom...@googlemail.com wrote: you can simplify the condition to if ($scounter = $this-Session-read('scounter')) {} but besides that how is the test case set up? because it is possible that it resets itself after each run therefore the session would always be emptied afterwards... On 27 Nov., 11:38, ava avon...@gmx.net wrote: Hi I'm struggling with sessions in cakephp 2.0.3. In this testcase the counter should be incremented with each click on the link. The counter always remains 1. // CONTROLLER ?php class Test01sController extends AppController { public $components = array('Session'); function testsession() { $scounter = 1; if ($this-Session-check('scounter')) { $scounter = $this-Session-read('scounter'); $scounter++; } $this-Session-write('scounter', $scounter); $this-set('scounter', $scounter); } } //MODEL ?php class Test01 extends AppModel { var $name = 'Test01'; var $useTable = false;} ? // VIEW ?php echo $scounter; ? br/a href=/test01s/testsessiontestsession/a // CORE Configure::write('Session', array( 'defaults' = 'php', 'cookie' = 'vportal', 'ini' = array('session.gc_divisor' = 1000,'session.cookie_httponly' = true), 'timeout' = 4320 //3 days )); I also dumped the $_SESSION array. This array is always empty. Any help or hints are appreciated. -- Andre -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: cache action not working
debug 0 Cache.disable Cache.check 1 Cache.disable was set to false. However, I reading it returns empty string On Mar 22, 11:26 pm, gremlin abba.bry...@gmail.com wrote: Do you have debug set to 0? If you are seeing the query log then you likely don't and with a setting of anything higher than 0 the cache is cleared on each call to the action. On Mar 22, 2:27 pm, André von Arx avon...@gmx.net wrote: I've tried to cache a controller action without success. Here are the settings I've used for cakephp 1.3.7: === core.php: Cache::config('default', array( 'engine' = 'File', // required 'duration'= 3600, // optional 'probability'= 100, // opt 'path' = '/usr/local/www/locavores.co/www/dev/app/tmp/cache/', 'prefix' = 'cake_', // optional 'lock' = false, // optional 'serialize' = true // optional )); // path direcotory is writable Configure::write('Cache.check', true); Configure::write('Cache.disable', false); === controller var $helpers = array('Form','Formhint','Time','Cache'); var $cacheAction = array( 'getRandomImagesG24' = '48000' ); function getRandomImagesG24() { $this-cacheAction = true; return $this-Image-getRandomImagesG24(); } According to the SQL-Log the Image-getRandomImagesG24 being called for each controller action call (getRandomInagesG24). Any hints or suggestions? -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro!https://freundschaftswerbung.gmx.de -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: create .po file from database table (multilingual, l10n I18n)
Here's my prototype: feedback is appreciated! (Part1): Model and DDL ?php class Translation extends AppModel { var $name = 'Translation'; var $useTable = 'ax_translation'; function import($filename) { // set the filename to read from if (empty($filename)) $filename='default.pot'; $filename = ROOT . DS . 'app' . DS. 'locale' . DS . $filename; $filename= '/usr/local/www/41max.com/www/dev/app/locale/ default.pot'; // open the file $filehandle = fopen($filename, r); while (($row = fgets($filehandle)) !== FALSE) { if (substr($row,0,7) == 'msgid ') { // parse string in hochkomma: $msgid = substr($row, 7 ,(strpos($row,'',6)-8)); if (!empty($msgid)) { $row = fgets($filehandle); if (substr($row,0,8) == 'msgstr ') { $msgstr = substr($row, 8 ,(strpos($row,'',7)-9)); } // check if exists $trec = $this-find(array(Translation.msgid = $msgid, locale=en)); if (empty($trec)) { $this-create(); $this-data['Translation']['msgid'] = $msgid; $this-data['Translation']['msgstr'] = $msgstr; $this-data['Translation']['locale'] = 'en'; $this-data['Translation']['status'] = 'n'; $this-save($this-data); } else { $this-setLastUsed($trec['Translation']['id']); } } } } fclose($filehandle); } function setLastUsed($id) { $ret = $this-query(update ax_translation ax set last_used = current_timestamp where id = . $id); return $ret; } } ? /* CREATE TABLE ax_translation ( id serial, msgid varchar(255) not null , locale char(2) default 'en', created timestamp with time zone, last_used timestamp with time zone, status char(1),-- (t:translated, n: new, needs translation, r: to be reviewed, u: updated, needs translation msgstr text ); CREATE UNIQUE INDEX ax_translation_msgid ON ax_translation USING btree (msgid, locale); */ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: create .po file from database table (multilingual, l10n I18n)
Part 2: Controller ?php class TranslationsController extends AppController { var $name = 'Translation'; var $components = array('Axtranslate'); var $langarr = array ('de'='ger','es'='spa','el'='gre','fr'='fre','it'='ita','ar'='ara','nl'='dut','zh'='chi'); function import() { // Step 1: import default.pot File $this-Translation-import('default.pot'); } function export() { // Step 3: export default.po file to the relevant directory $filename= 'f' . gmdate('YmdHis'); foreach ($this-langarr as $k = $v): $path = ROOT.DS.'app'.DS.'locale'.DS.$v; if (!file_exists($path)) mkdir($path); $path .= DS.'LC_MESSAGES'; if (!file_exists($path)) mkdir($path); $file = $path.DS.$filename; if (!file_exists($path)) touch($file); $file = new File($path.DS.$filename); $tmprec = $this-Translation-find('all', array('conditions' = array('Translation.locale' = $k))); foreach ($tmprec as $rec): $file-write('msgid ' .$rec['Translation'] ['msgid'] .''.\n); $file-write('msgstr '.$rec['Translation'] ['msgstr'].''.\n); endforeach; $file-close(); if (file_exists($path.DS.'default.po')) rename ($path.DS.'default.po', $path.DS.'default.po.old'.gmdate('YmdHis')); rename ($path.DS.$filename,$path.DS.'default.po'); endforeach; } function trans() { // Step 2: translate to all languages defined in $langarr $trec = $this-Translation-findAllByLocale('en'); foreach ($trec as $rec): foreach ($this-langarr as $k = $v): $tmprec = $this-Translation-find('all', array('conditions' = array('Translation.locale' = $k,'Translation.msgid'= $rec['Translation']['msgid']))); if (count($tmprec) == 0) { $this-data['Translation']['msgstr'] = $this- Axtranslate-translate($rec['Translation']['msgid'], 'en', $k); $this-data['Translation']['msgid'] = $rec ['Translation']['msgid']; $this-data['Translation']['locale'] = $k; $this-data['Translation']['status'] = 'm'; $this-Translation-save($this-data); } endforeach; endforeach; } } ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: create .po file from database table (multilingual, l10n I18n)
Part 3: Axtranslate ?php // copy code from http://code.google.com/p/php-language-api/source/browse/trunk/google.translator.php class AxtranslateComponent extends Object { --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: create .po file from database table (multilingual, l10n I18n)
Summary the above solution does the following: - extract msgid and msgstr from file 'default.po' - automatic translation all messages using google translation (it's a good starting point anyway) - export msgid and msgstr to the relevant directories (default.po) still to to: an edit function to manually edit the translations. feedback is welcome. regards, Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: create .po file from database table (multilingual, l10n I18n)
Hi Marc, as for multilingual I suggest the following procedure: 1. create po file by bake (cake.php i18n extract) 2. load po file into translation table: - flag new records as new (status: n) - set current date for existing records if msgid matches. 3. translation can now take place in the web application: user (translator) flags translated records as translated (status: t) 4. create a new po file for each language, source is the translation table. - take not translated text if the item is not translated. Translation Table: CREATE TABLE `translations` ( `id` int(7) NOT NULL auto_increment, `msgid` varchar(100) , `locale` char(2) default 'en', created timestamp, last_used timestamp, status char(1),-- (t:translated, n: new, needs translation, r: to be reviewed, u: updated, needs translation `msgstr` text , ); create unique index on msgid,locale Housekeeping: - delete translations that are not used for 18 months. ..text extract from pot file: #: /views/feedback/add.ctp:44 #: /views/feedback/bytag.ctp:62 #: /views/feedback/main.ctp:101 #: /views/feedback/view.ctp:29 #: /views/person/contact.ctp:22 msgid your Email msgstr On 15 Aug., 12:46, euromark (munich) dereurom...@googlemail.com wrote: your gmx address does not seem to work i tried to contact you but got a delivery failure (not exists) maybe you want to drop me a line instead mark On 15 Aug., 09:23, ava avon...@gmx.net wrote: Hi Mark, how can I help (testing, reviewing, developing)? Can you provide the code? Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: create .po file from database table (multilingual, l10n I18n)
Hi Mark, how can I help (testing, reviewing, developing)? Can you provide the code? Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
create .po file from database table (multilingual, l10n I18n)
Hello, building multilingual websites is an ongoing process because content of websites often change. Therefore translations have to be done for every new release. Instead of extracting the po files and then translation the file content I wish to do something smarter. - keep translations in a db table - translate only new content - generate .po file from db table - keep translation effort to a minimum. I would still use the console extract and merge the new content in the db table. Has anybody done something similar and could provide some examples? -- Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---