View previous topic :: View next topic |
Author |
Message |
stu Smarty n00b
Joined: 18 Feb 2010 Posts: 1
|
Posted: Thu Feb 18, 2010 9:49 am Post subject: smarty3 and gettext |
|
|
hi!
Is there a easy way to use gettext?
In smarty2 all I need to do was
Code: |
$smarty->register_block('t', 'smarty_translate');
|
but now I have
Code: |
Notice: function call 'register_block' is unknown or deprecated.
Fatal error: Uncaught exception 'Exception' with message 'Plugin "t" not callable'
|
Smarty3 beta from svn
After reading readme file:
$smarty->register->block('t','translate');
Quote: |
Uncaught exception 'Exception' with message 'Plugin "translate" not callable' |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 18, 2010 2:59 pm Post subject: |
|
|
read the README |
|
Back to top |
|
spinnaker Smarty Rookie
Joined: 01 Mar 2010 Posts: 6
|
Posted: Thu Jun 24, 2010 9:58 am Post subject: |
|
|
Hi all.
I have a similar problem but I still no found info in the readme, I am sorry but could I ask you how you have solved this problem?
Thanks. |
|
Back to top |
|
ctlajoie Smarty Rookie
Joined: 20 Nov 2009 Posts: 29
|
Posted: Thu Jun 24, 2010 5:18 pm Post subject: |
|
|
Code: | function smarty_translate($params, $content) {
if ($content) return gettext($content);
}
$smarty->register->block('t', 'smarty_translate'); |
|
|
Back to top |
|
spinnaker Smarty Rookie
Joined: 01 Mar 2010 Posts: 6
|
Posted: Tue Jun 29, 2010 7:33 am Post subject: |
|
|
Hi, thank you for the reply.
If I add the plugin register instruction in the smarty-gettext.php file I have in output the warning 'Plugin tag "t" already registered' ...but where?
I can't find it.
Still only a question, I am not sure but have I to replace the code of the function that you have specified? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jun 29, 2010 3:08 pm Post subject: |
|
|
It looks like that $smarty->register->block gets called twice. |
|
Back to top |
|
ctlajoie Smarty Rookie
Joined: 20 Nov 2009 Posts: 29
|
Posted: Tue Jun 29, 2010 4:34 pm Post subject: |
|
|
To find where it is getting called twice, do a global search of your project for "$smarty->register". You should be able to quickly identify where the "t" block is being registered twice. |
|
Back to top |
|
spinnaker Smarty Rookie
Joined: 01 Mar 2010 Posts: 6
|
Posted: Wed Jun 30, 2010 12:54 pm Post subject: |
|
|
Thanks. I had found my problem.
Now works.
W Smarty |
|
Back to top |
|
kosterwoat Smarty n00b
Joined: 22 Aug 2012 Posts: 1
|
Posted: Wed Aug 22, 2012 9:51 am Post subject: |
|
|
How can i check if a smarty plugin function is already registred by register_function() ?
Indeed i have to check this because i am under a Hook Prestashop context which is called many times and causes php fatal error.
Thank you for your help |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Aug 22, 2012 7:33 pm Post subject: |
|
|
For Smarty 2
Code: | if (isset($smarty->_plugins['function']['myname'])) {
....
} |
For Smarty 3
Code: | if (isset($smarty->registered_plugins['function']['myname'])) {
....
} |
|
|
Back to top |
|
jebediah Smarty Rookie
Joined: 28 Jan 2012 Posts: 16
|
Posted: Sat Dec 01, 2012 3:42 pm Post subject: smarty-gettext |
|
|
Hi there,
I found the i18n support of Smarty (not per see, but as the whole process) a bit lacking. That's why I've implemented and released a smarty-gettext project that enables full i18n support for Smarty, including the creation of po files, etc.
Have a look here: http://code.google.com/p/smarty-gettext/
any feedback, etc. would be very much appreciated!
Bests,
Charly |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Dec 02, 2012 8:55 am Post subject: |
|
|
I have tried to load it from the SVN but got an "http://smarty-gettext.googlecode.com/svn/trunk/smarty-gettext-read-only doesn't exist" error |
|
Back to top |
|
jebediah Smarty Rookie
Joined: 28 Jan 2012 Posts: 16
|
Posted: Sun Dec 02, 2012 1:30 pm Post subject: |
|
|
Hi U.Tews,
thanks a lot for trying to checkout the sources.
You've got 2 options to get the sources.
Nr 1. SVN
The command to checkout from SVN is
Code: | svn checkout http://smarty-gettext.googlecode.com/svn/trunk/ smarty-gettext-read-only
|
(please beware of the space between http://.../svn/trunk and smarty-gettext-read-only). You can replace the smarty-gettext-read-only command by whatever you'd like to have the checkout called in your local file-system, e.g.
Code: | svn checkout http://smarty-gettext.googlecode.com/svn/trunk/ smarty-gettext
|
For a generic description of the checkout command please see e.g. here.
Nr 2. zip/tar.gz
The second option would be to download the sources from the zipped/tared files here: http://code.google.com/p/smarty-gettext/downloads/list
I'll ammend the description in the project to make that clearer.
If you experience any more problems, please do let me know.
Bests,
Charly[/url] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Dec 02, 2012 1:38 pm Post subject: |
|
|
Sorry it was my fault that the download from SVN didn't work.... |
|
Back to top |
|
jebediah Smarty Rookie
Joined: 28 Jan 2012 Posts: 16
|
Posted: Sun Dec 02, 2012 1:40 pm Post subject: |
|
|
not a problem . Glad if it's working now...
If you've got ANY comments, I'd really greatly appreciate if you could let me know so I can improve the system.
I really do think that easy i18n support is the only thing missing in the wonderful Smarty templating engine.
Thanks for trying!
cc |
|
Back to top |
|
|