Themes and localization :: Widgets not finding resources

2 views
Skip to first unread message

Richard Gomes

unread,
Feb 5, 2009, 7:59:35 PM2/5/09
to Pxxo
Hi guys,

I hope you guys understand English.
I'm brazilian and my basic French is lost in the past (and I never had
a rich vocabulary anyway).

Could you guy please help me understand why templates are not being
loaded from the correct places?
The diagnostic is:

1. I have Pxxo installed at /usr/share/php/Pxxo

2. When I instantiate a class, I expect that it auto loads resources
for the corresponding template directoy, for instance...
/usr/share/php/Pxxo/Widget/Identity/Auth/default /i18n
... but what happens is that resources are being looked up under my
widget directory ...
/var/www/provision/classes/Provision/default/i18n

3. At the moment, I have IdentityManager being displayed half English
half French because I copied resources from IdentityManager onto my
widget resource directory but IdentityManager calls Identity/Auth
which is not able to find localization files, as I explained.

Do you have an idea about what I'm doing wrong?
http://idp.jquantlib.com/provision/

Note: You can download my project files at http://idp.jquantlib.com/provision/provision.tar.bz2
At the moment, it only extends IdentityManager and displays it.

Thank you very much.

Richard Gomes
http://www.jquantlib.org/index.php/User:RichardGomes

Stéphane Gully

unread,
Feb 6, 2009, 2:43:26 AM2/6/09
to px...@googlegroups.com
Hello Richard,

We will make an effort to speak few words of english :-)

You created a specific "Provision" class which inherits from
"Pxxo_Widget_IdentityManager" in order to overload the
"Pxxo_Widget_IdentityManager" templates and localization resources.
This will work however it's not the best way to develop with pxxo.
Inheritance will be useful if you need to change the widget behavior
strongly.
Good practices are to avoid widget's inheritance when you only want to
overload theme and localization. Pxxo has a built in way for this
task.
For example, to overload default theme of
"Pxxo_Widget_IdentityManager" you only have to create this directory:
/var/www/provision/templates/Pxxo_Widget_IdentityManager/default/
Then you only have to overload the resource you want to be changed:
image, css, or html.
As i18n resources are just considered as other resources in a pxxo
widget, you can also overload the i18n resources just by creating:
/var/www/provision/templates/Pxxo_Widget_IdentityManager/default/i18n/en_GB.php

However concerning your localization problem, I think there is a bug
in the IdentityManager... (sorry we forgot to test it with other
languages than french)
Here is the description of the bug:
Pxxo_Widget_IdentityManager includes as child other widgets:
Pxxo_Widget_Identity_Auth
Pxxo_Widget_Identity_Register
Pxxo_Widget_Identity_...
These sub widgets are corresponding to the tabs (auth, register...).
The bug is that when they are instantiated by
Pxxo_Widget_IdentityManager, the Lang parameter (Theme param also) is
not forwarded to these children.

To quickly workaround the bug you could define the language globally
using the pxxo registry this way:
require_once 'Pxxo/Registry.php';
$registry = Pxxo_Registry::getInstance();
$registry->language = 'en_GB';
Put this piece of code just after the paths definitions in
/var/www/provision/config.php
Then all the widget (parent and child) should be translated magically
in English :-)
My side, I will patch IdentiyManager to allow Lang and Theme
parameters forwarding to children.

Last thing, you asked me in you last email about pxxo philosophy and
the pxxo design pattern:
- pxxo widgets are able to by hierarchical: one parent widget could
have several children and these children could also have children
(this is the composite design pattern)
- pxxo widgets are able to be decorated by other widgets: it means
that a widget could decide to insert as its direct parent another
widget (decorator design pattern)
- most of the time when developing an application we don't uses
inheritance we try to give priority to widget composition. One
application <=> A (big) widget tree

Hope it will help you.
regards,
Stéphane Gully

Nicolas Thouvenin

unread,
Feb 6, 2009, 5:25:21 AM2/6/09
to px...@googlegroups.com
Hi,

The localization problem was fixed and commited in svn !
The bug was in Pxxo itself.
I will build a new version as soon as possible...

Thank you for your interest to Pxxo

--
Nicolas




2009/2/6 Stéphane Gully <stephan...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages