PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » Translation2 » Bug #3105

Using the default Lang with Admin methods

Details

Request #3105Using the default Lang with Admin methods
Submitted2005-01-05 12:41 UTC
Fromylf at xung dot org
Assignedquipo
StatusClosed
PackageTranslation2
PHP Version4.3.4
OSLinux Debian
Roadmaps(Not assigned)

Comments

[2005-01-05 12:41 UTC] ylf at xung dot org

Description:
------------
Hi,

I'm in the following situation :

At first, my Billing_System object creates a Translation2 object, and sets a default lang. Then Billing_System creates a Product object (actually a customized DataObject) and passes the Translation2 object to this Product.

When it comes to querying for translations (like Translation2::get()), this Product can do its job properly. It does not know about the default language that was set by its creator, the Billing_System, but it does not need to know because Translation2::get() handles it transparently.

Now, the Product sometimes need to update translations, by calling Translation2::add(). And there, it needs to know about the default language to fill in the translations array passed as the third argument to add().

Problem : Product respects encapsulation. The default language was set by the Billing_System, but the Product does not know about it...

From here, I see two solutions :
- either to add a getDefaultLang() method, which would be called by Product
- or to enable add()/update() to use the default language, just as get() does it, so that Product does not need to know about it

Or is this already possible by other means ?

[2005-01-05 16:57 UTC] ylf at xung dot org

I understand what you mean, but I don't really like to play with a semi-private property as $lang. Especially because it's an array, it looks like a hack.

Of course I could modify my application design, but I believe that a getDefaultLang() method could be nice and useful...

Don't you think ?