![]() |
A better language helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: A better language helper (/showthread.php?tid=47653) |
A better language helper - El Forum - 12-16-2011 [eluser]Unknown[/eluser] I am working on integrating with getlocalization.com to crowd-source localization for wookmark.com, and found the CodeIgniter language helper function not very useful. Here's a version that works better for my purposes, that I wanted to share. One difference is that the function returns the passed in text when no localization is available. CodeIgniter's lang function returns false in that case. I prefer this option since it's a better failsave. Second difference is that the function supports templated parameters. Here's an example. Code: trans('Hello {user}', array('user' => 'Peter')); // Returns "Hello Peter" And here's the helper function. Code: function trans($line, $props = null) { |