#6470: [PATCH] localization function should support placeholders
----------------------------+-----------------------------------------------
    Reporter:  mikesmullin  |          Type:  Enhancement
      Status:  new          |      Priority:  Low        
   Milestone:  1.3.x.x      |     Component:  Core Libs  
     Version:  1.2 Final    |      Severity:  Normal     
    Keywords:               |   Php_version:  n/a        
Cake_version:               |  
----------------------------+-----------------------------------------------
 Also the localization function should have $return default to TRUE but
 someone in #cakephp said this was already going to be in the next release
 so I'll just mention it here FWIW that this function also takes care of
 that.


 I have attached a patch showing how we defined the function in our
 bootstrap.inc. This may as well be made directly to ./cake/basics.php if
 it is implemented in core. You'll notice the function is from Drupal's
 localization functions:


 http://api.drupal.org/api/function/t/5


 However, for our purposes here in CakePHP, it has been modified as a
 wrapper for the __() function. This also allows the old function to exist
 for backward compatibility.


 There are numerous advantages to allowing placeholders in the localization
 function, and they are explained in the PHPDoc code comment documentation
 above the function in my patch. But the gist of it is that rather than
 trying something like `sprintf(__('You have %d employees.', TRUE),
 count($employees));` every time, you would do something more like `t('You
 have @count employees.', array('@count' => count($employees));` There is a
 big difference and the second form ends up being a lot more convenient.

 Read the patch!

-- 
Ticket URL: <https://trac.cakephp.org/ticket/6470>
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