This object is in archive! 
Where in the code can I find the Zend_Translate Bootstrap part
I want to extend UR to have a language picker on top, for that I need to know where the current locale is being setup - probably it is read from the user config or from the default settings of the site. Can you push me into the right direction?
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
Keys from this table could be fetched the next way:
Singular_Core::_('settings')->getSetting('site_default_language');
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
Keys from this table could be fetched the next way:
Singular_Core::_('settings')->getSetting('site_default_language');
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
Keys from this table could be fetched the next way:
Singular_Core::_('settings')->getSetting('site_default_language');
These are stored in database, "settings" table, records where keys are "site_default_language" and "site_default_locale".
Keys from this table could be fetched the next way:
Singular_Core::_('settings')->getSetting('site_default_language');
But where is that being sent to Zend_Translate? I know this is stored in the database, but I need to know where it is being read into the translation handler - so I can have a look how the code for that works.
But where is that being sent to Zend_Translate? I know this is stored in the database, but I need to know where it is being read into the translation handler - so I can have a look how the code for that works.
Please take a look on "/library/Singular/Application/Resource/Translate.php" and "/library/Singular/Translate.php". Let me know if these locations are what you need.
Please take a look on "/library/Singular/Application/Resource/Translate.php" and "/library/Singular/Translate.php". Let me know if these locations are what you need.
Ok that is the direction i was searching for, thanks so far. Now if you just would tell me where all the bootstrapping is done - in the _detectLanguage function he uses options coming from the bootstrapper afaik. Like $options['languageSource'] and so on - sorry to bother you with questions I could solve by reading the manual, but this save me a lot of time
Ok that is the direction i was searching for, thanks so far. Now if you just would tell me where all the bootstrapping is done - in the _detectLanguage function he uses options coming from the bootstrapper afaik. Like $options['languageSource'] and so on - sorry to bother you with questions I could solve by reading the manual, but this save me a lot of time
Maybe i should be a little more precise - what is the best way to override methods in this class without breaking the core?
Maybe i should be a little more precise - what is the best way to override methods in this class without breaking the core?
Language source and few other options are defined in "application/configs/application.ini" (look for "; translate" section). Translate resource is bootstrapped, as usually from "index.php" in DOCUMENT_ROOT - this one looks for resources defined in "application.ini" and loads them.
Language source and few other options are defined in "application/configs/application.ini" (look for "; translate" section). Translate resource is bootstrapped, as usually from "index.php" in DOCUMENT_ROOT - this one looks for resources defined in "application.ini" and loads them.
Correct way to do this would be to create own adapter and then specify it in "; translate" section of application.ini
You can use this example as reference.
Correct way to do this would be to create own adapter and then specify it in "; translate" section of application.ini
You can use this example as reference.
Ok I start to understand this now, all of the bootstrapping is done using application.ini and a clever way of autoloading etc. Ok so I just did this:
resources.translate.languageSource = cookies ;
in application.ini - now i can set the language just by setting the $_GET Param 'lang' to the needed code. Works perfect, but I need to do a force refresh to get the new language - anything that needs to be done now to get this to work?
Ok I start to understand this now, all of the bootstrapping is done using application.ini and a clever way of autoloading etc. Ok so I just did this:
resources.translate.languageSource = cookies ;
in application.ini - now i can set the language just by setting the $_GET Param 'lang' to the needed code. Works perfect, but I need to do a force refresh to get the new language - anything that needs to be done now to get this to work?
Ok i found the reason, maybe you should adopt this in the core, i modified (yes core hack, I know)
library/Singular/Application/Resource/Translate.php
and changed the following in _detectLanguage:
/* get requested language */
$language = $this->_request->getParam(self::LANGUAGES_KEY);
if (true === $this->_validateLanguage($language)) {
$this->_setCookie($language, $cookieExpire);
}
//Commented out the following line, now it works
//$language = $this->_getCookie();
Ok i found the reason, maybe you should adopt this in the core, i modified (yes core hack, I know)
library/Singular/Application/Resource/Translate.php
and changed the following in _detectLanguage:
/* get requested language */
$language = $this->_request->getParam(self::LANGUAGES_KEY);
if (true === $this->_validateLanguage($language)) {
$this->_setCookie($language, $cookieExpire);
}
//Commented out the following line, now it works
//$language = $this->_getCookie();
ok, still investigating - seems like some parts are still being cache. I will further look at this issue - the cookie based handler is what i need but setting the language by request does not refresh all language things there.
ok, still investigating - seems like some parts are still being cache. I will further look at this issue - the cookie based handler is what i need but setting the language by request does not refresh all language things there.
For now I needed to set
resources.cachemanager.default.frontend.options.caching = false
which pulls the performance down, any way to get that to work without this? Isn't this something that might be changed in the core?
For now I needed to set
resources.cachemanager.default.frontend.options.caching = false
which pulls the performance down, any way to get that to work without this? Isn't this something that might be changed in the core?
Alexander, I can advise you to implement that custom translation functionality you're working on currently, then send it's code to us, so we'll take a look on it and decide what will be the best workaround to minimize performance loss.
Alexander, I can advise you to implement that custom translation functionality you're working on currently, then send it's code to us, so we'll take a look on it and decide what will be the best workaround to minimize performance loss.
Well, it's pretty easy - i just switched the 2 variables and added something like this in my header template:
application.ini:
resources.translate.languageSource = cookies
resources.cachemanager.default.frontend.options.caching = false
header.phtml:
<a href="<?php echo $this->url(array('lang' => 'de'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/de.png') ?>"> Deutsch</a> |
<a href="<?php echo $this->url(array('lang' => 'en'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/en.png') ?>"> English</a> |
<a href="<?php echo $this->url(array('lang' => 'ru'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/ru.png') ?>"> русский</a>
As I only have 3 static languages this is fine for me, but having a real language switch when the cookie based method is used would be a good core enhancement. What I really miss with the cookie based one is my frontend cache - it really kills the perfomance. The blocks that are being cached might incorporate the language code in their cache key perhaps?
Well, it's pretty easy - i just switched the 2 variables and added something like this in my header template:
application.ini:
resources.translate.languageSource = cookies
resources.cachemanager.default.frontend.options.caching = false
header.phtml:
<a href="<?php echo $this->url(array('lang' => 'de'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/de.png') ?>"> Deutsch</a> |
<a href="<?php echo $this->url(array('lang' => 'en'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/en.png') ?>"> English</a> |
<a href="<?php echo $this->url(array('lang' => 'ru'), 'default', true) ?>"><img src="<?php echo $this->baseUrl('/public/lang/ru.png') ?>"> русский</a>
As I only have 3 static languages this is fine for me, but having a real language switch when the cookie based method is used would be a good core enhancement. What I really miss with the cookie based one is my frontend cache - it really kills the perfomance. The blocks that are being cached might incorporate the language code in their cache key perhaps?
I was unable to confirm performance loss with changes you've mentioned, I'll schedule this question for later in-depth review.
I was unable to confirm performance loss with changes you've mentioned, I'll schedule this question for later in-depth review.
As far as i know from the docs, the following line disables Zend_Cache_Frontend (http://framework.zend.com/manual/en/zend.cache.frontends.html)
resources.cachemanager.default.frontend.options.caching = false
Which does take impact on the performance, correct me when I'm wrong - I'm pretty new to this topic.
As far as i know from the docs, the following line disables Zend_Cache_Frontend (http://framework.zend.com/manual/en/zend.cache.frontends.html)
resources.cachemanager.default.frontend.options.caching = false
Which does take impact on the performance, correct me when I'm wrong - I'm pretty new to this topic.
Can you measure average page loading time with this option enabled, and then disabled (for example - via FireBug firefox addon's "Network" tab")?
Can you measure average page loading time with this option enabled, and then disabled (for example - via FireBug firefox addon's "Network" tab")?
Just updated to 1.1 - now the whole language switch is broken, does nothing anymore. Deactivated all caches, seems like he does not even hook into _detectLanguage anymore. Was this changed somehow?
Just updated to 1.1 - now the whole language switch is broken, does nothing anymore. Deactivated all caches, seems like he does not even hook into _detectLanguage anymore. Was this changed somehow?
Open /application/configs/application.inc and look for string "$config['resources']['translate']['languageSource']". Change it's value from 'system_settings' to 'cookies'.
Let me know if it helps.
Open /application/configs/application.inc and look for string "$config['resources']['translate']['languageSource']". Change it's value from 'system_settings' to 'cookies'.
Let me know if it helps.
It's currently like that:
resources.translate.languageSource = cookies ;
So this should be fine, or is there something else in there I missed?
It's currently like that:
resources.translate.languageSource = cookies ;
So this should be fine, or is there something else in there I missed?
Since 1.1 release, configuration is stored in "application.inc" instead of "application.ini" so you should check .inc file for configuration item i've mentioned above.
Since 1.1 release, configuration is stored in "application.inc" instead of "application.ini" so you should check .inc file for configuration item i've mentioned above.
Replies have been locked on this page!