#6326: Setting dynamic i18n l10n locales (eg. en-au, en-us)
----------------------------------+-----------------------------------------
    Reporter:  rowlandm           |          Type:  Enhancement
      Status:  new                |      Priority:  Low        
   Milestone:  1.2.x.x            |     Component:  i18n/l10n  
     Version:  1.2 Final          |      Severity:  Normal     
    Keywords:  dynamic i18n l10n  |   Php_version:  n/a        
Cake_version:  1.2.1.8004         |  
----------------------------------+-----------------------------------------
 Hi there,

 First of all, thanks for the jobs you guys are doing. I really enjoy
 working with cake.[[BR]]
 [[BR]]

 I needed to have a dynamic way of setting locales (ie en-us, en-au)
 depending on whether the user was logged in or which part of the site they
 were on. Problem was, I would set the locale via l10n->get('en-au') and
 then on another page change it to l10n->get('en-us').  [[BR]]
 [[BR]]


 What would happen is that from then on my
 {{{
 __("Favourite")
 }}}
  kept using en-au instead of en-us.  I did find a way to get this to work,
 but I had to add a public function into /cake/libs/i18n.php to clear the
 variable {{{$_this->__domains}}} as it seems to store the value of the en-
 au's .po file and not reset the variable for en-us' .po file.

 {{{
 ** /cake/libs/i18n.php
 * Clears the $_this->__domains variable to allow dynamic locale changes
 *
 * @return true
 */
 function clearDomains (){
   $_this =& I18n::getInstance();
   unset($_this->__domains);
   return true;
 }

 }}}

 This function then allows me to clear that variable before I call
 l10n->get('en-us'). I've tested this and it does seem to work. Is there
 any chance that this could go into the i18n.php file down the track?

 Ta

-- 
Ticket URL: <https://trac.cakephp.org/ticket/6326>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to