Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smarty3 and gettext

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
stu
Smarty n00b


Joined: 18 Feb 2010
Posts: 1

PostPosted: Thu Feb 18, 2010 9:49 am    Post subject: smarty3 and gettext Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 18, 2010 2:59 pm    Post subject: Reply with quote

read the README
Back to top
View user's profile Send private message Visit poster's website
spinnaker
Smarty Rookie


Joined: 01 Mar 2010
Posts: 6

PostPosted: Thu Jun 24, 2010 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message
ctlajoie
Smarty Rookie


Joined: 20 Nov 2009
Posts: 29

PostPosted: Thu Jun 24, 2010 5:18 pm    Post subject: Reply with quote

Code:
function smarty_translate($params, $content) {
    if ($content) return gettext($content);
}

$smarty->register->block('t', 'smarty_translate');
Back to top
View user's profile Send private message
spinnaker
Smarty Rookie


Joined: 01 Mar 2010
Posts: 6

PostPosted: Tue Jun 29, 2010 7:33 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Jun 29, 2010 3:08 pm    Post subject: Reply with quote

It looks like that $smarty->register->block gets called twice.
Back to top
View user's profile Send private message
ctlajoie
Smarty Rookie


Joined: 20 Nov 2009
Posts: 29

PostPosted: Tue Jun 29, 2010 4:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
spinnaker
Smarty Rookie


Joined: 01 Mar 2010
Posts: 6

PostPosted: Wed Jun 30, 2010 12:54 pm    Post subject: Reply with quote

Thanks. I had found my problem.
Now works.

W Smarty Smile
Back to top
View user's profile Send private message
kosterwoat
Smarty n00b


Joined: 22 Aug 2012
Posts: 1

PostPosted: Wed Aug 22, 2012 9:51 am    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Aug 22, 2012 7:33 pm    Post subject: Reply with quote

For Smarty 2
Code:
if (isset($smarty->_plugins['function']['myname'])) {
   ....
}


For Smarty 3
Code:
if (isset($smarty->registered_plugins['function']['myname'])) {
   ....
}
Back to top
View user's profile Send private message
jebediah
Smarty Rookie


Joined: 28 Jan 2012
Posts: 16

PostPosted: Sat Dec 01, 2012 3:42 pm    Post subject: smarty-gettext Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Dec 02, 2012 8:55 am    Post subject: Reply with quote

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
View user's profile Send private message
jebediah
Smarty Rookie


Joined: 28 Jan 2012
Posts: 16

PostPosted: Sun Dec 02, 2012 1:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Dec 02, 2012 1:38 pm    Post subject: Reply with quote

Sorry it was my fault that the download from SVN didn't work.... Sad
Back to top
View user's profile Send private message
jebediah
Smarty Rookie


Joined: 28 Jan 2012
Posts: 16

PostPosted: Sun Dec 02, 2012 1:40 pm    Post subject: Reply with quote

not a problem Smile. 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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP